From: Chengguang Xu Date: Wed, 17 Jun 2020 01:09:39 +0000 (+0800) Subject: nfs4: strengthen error check to avoid unexpected result X-Git-Tag: v5.15~2618^2~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=82c596ebaa104f994d25256523ae2f9047323fe7;p=platform%2Fkernel%2Flinux-starfive.git nfs4: strengthen error check to avoid unexpected result The variable error is ssize_t, which is signed and will cast to unsigned when comapre with variable size, so add a check to avoid unexpected result in case of negative value of error. Signed-off-by: Chengguang Xu Signed-off-by: Anna Schumaker --- diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 1d23dc6..aca52e5 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -7440,7 +7440,7 @@ nfs4_listxattr_nfs4_label(struct inode *inode, char *list, size_t list_len) if (nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) { len = security_inode_listsecurity(inode, list, list_len); - if (list_len && len > list_len) + if (len >= 0 && list_len && len > list_len) return -ERANGE; } return len;