Skip to content

Commit 5559c15

Browse files
scottmayhewchucklever
authored andcommitted
nfsd: enforce upper limit for namelen in __cld_pipe_inprogress_downcall()
This patch is intended to go on top of "nfsd: return -EINVAL when namelen is 0" from Li Lingfeng. Li's patch checks for 0, but we should be enforcing an upper bound as well. Note that if nfsdcld somehow gets an id > NFS4_OPAQUE_LIMIT in its database, it'll truncate it to NFS4_OPAQUE_LIMIT when it does the downcall anyway. Signed-off-by: Scott Mayhew <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 22451a1 commit 5559c15

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/nfsd/nfs4recover.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,8 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg,
809809
ci = &cmsg->cm_u.cm_clntinfo;
810810
if (get_user(namelen, &ci->cc_name.cn_len))
811811
return -EFAULT;
812-
if (!namelen) {
813-
dprintk("%s: namelen should not be zero", __func__);
812+
if (namelen == 0 || namelen > NFS4_OPAQUE_LIMIT) {
813+
dprintk("%s: invalid namelen (%u)", __func__, namelen);
814814
return -EINVAL;
815815
}
816816
name.data = memdup_user(&ci->cc_name.cn_id, namelen);
@@ -835,8 +835,8 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg,
835835
cnm = &cmsg->cm_u.cm_name;
836836
if (get_user(namelen, &cnm->cn_len))
837837
return -EFAULT;
838-
if (!namelen) {
839-
dprintk("%s: namelen should not be zero", __func__);
838+
if (namelen == 0 || namelen > NFS4_OPAQUE_LIMIT) {
839+
dprintk("%s: invalid namelen (%u)", __func__, namelen);
840840
return -EINVAL;
841841
}
842842
name.data = memdup_user(&cnm->cn_id, namelen);

0 commit comments

Comments
 (0)