lkml.org 
[lkml]   [2019]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.4 059/230] sockfs: getxattr: Fail with -EOPNOTSUPP for invalid attribute names
    Date
    4.4-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Andreas Gruenbacher <agruenba@redhat.com>

    commit 971df15bd54ad46e907046ff33750a137b2f0096 upstream.

    The standard return value for unsupported attribute names is
    -EOPNOTSUPP, as opposed to undefined but supported attributes
    (-ENODATA).

    Also, fail for attribute names like "system.sockprotonameXXX" and
    simplify the code a bit.

    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    [removes a build warning on 4.4.y - gregkh]
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    net/socket.c | 24 ++++++------------------
    1 file changed, 6 insertions(+), 18 deletions(-)

    --- a/net/socket.c
    +++ b/net/socket.c
    @@ -470,27 +470,15 @@ static struct socket *sockfd_lookup_ligh
    static ssize_t sockfs_getxattr(struct dentry *dentry,
    const char *name, void *value, size_t size)
    {
    - const char *proto_name;
    - size_t proto_size;
    - int error;
    -
    - error = -ENODATA;
    - if (!strncmp(name, XATTR_NAME_SOCKPROTONAME, XATTR_NAME_SOCKPROTONAME_LEN)) {
    - proto_name = dentry->d_name.name;
    - proto_size = strlen(proto_name);
    -
    + if (!strcmp(name, XATTR_NAME_SOCKPROTONAME)) {
    if (value) {
    - error = -ERANGE;
    - if (proto_size + 1 > size)
    - goto out;
    -
    - strncpy(value, proto_name, proto_size + 1);
    + if (dentry->d_name.len + 1 > size)
    + return -ERANGE;
    + memcpy(value, dentry->d_name.name, dentry->d_name.len + 1);
    }
    - error = proto_size + 1;
    + return dentry->d_name.len + 1;
    }
    -
    -out:
    - return error;
    + return -EOPNOTSUPP;
    }

    static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer,

    \
     
     \ /
      Last update: 2019-03-22 14:14    [W:4.159 / U:0.108 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site