Skip to content

Commit 0f28337

Browse files
glivtergregkh
authored andcommitted
nfsd: check get_user() return when reading princhashlen
commit e186fa1 upstream. In __cld_pipe_inprogress_downcall(), the get_user() that reads princhashlen from the userspace cld_msg_v2 buffer does not check its return value. A failing copy leaves princhashlen with uninitialised stack contents, which are then used to drive memdup_user() and stored as princhash.len on the resulting reclaim record. The other get_user() calls in this function all check the return; only this one is missed, which is most likely a copy-paste oversight from when v2 upcalls were introduced. Mirror the existing pattern used a few lines above for namelen. namecopy is declared with __free(kfree) so the early return cleans up the already-allocated buffer automatically. Fixes: 6ee95d1 ("nfsd: add support for upcall version 2") Cc: stable@vger.kernel.org Signed-off-by: Dominik Woźniak <stalion@gmail.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dba7da4 commit 0f28337

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/nfsd/nfs4recover.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg,
800800
if (IS_ERR(name.data))
801801
return PTR_ERR(name.data);
802802
name.len = namelen;
803-
get_user(princhashlen, &ci->cc_princhash.cp_len);
803+
if (get_user(princhashlen, &ci->cc_princhash.cp_len))
804+
return -EFAULT;
804805
if (princhashlen > 0) {
805806
princhash.data = memdup_user(
806807
&ci->cc_princhash.cp_data,

0 commit comments

Comments
 (0)