]> www.infradead.org Git - users/dwmw2/linux.git/commit
nfsd: fix double fget() bug in __write_ports_addfd()
authorDan Carpenter <dan.carpenter@linaro.org>
Mon, 29 May 2023 11:35:55 +0000 (14:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:28 +0000 (16:19 +0200)
commit9b405c0f84d9b3c2a66a829a99a29b7eae5ebcfd
tree7bf3f07718432e1f71fefee45c241b646535c933
parent645c1b4b139b43349ce47a1a5f375c87823809c5
nfsd: fix double fget() bug in __write_ports_addfd()

[ Upstream commit c034203b6a9dae6751ef4371c18cb77983e30c28 ]

The bug here is that you cannot rely on getting the same socket
from multiple calls to fget() because userspace can influence
that.  This is a kind of double fetch bug.

The fix is to delete the svc_alien_sock() function and instead do
the checking inside the svc_addsock() function.

Fixes: 3064639423c4 ("nfsd: check passed socket's net matches NFSd superblock's one")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: NeilBrown <neilb@suse.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfsctl.c
include/linux/sunrpc/svcsock.h
net/sunrpc/svcsock.c