Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit adbbe929 authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust
Browse files

NFSD: If port value written to /proc/fs/nfsd/portlist is invalid, return EINVAL



Make sure port value read from user space by write_ports is valid before
passing it to svc_find_xprt().  If it wasn't, the writer would get ENOENT
instead of EINVAL.

Noticed-by: default avatarJ. Bruce Fields <bfields@fieldses.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent efb3288b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -938,6 +938,8 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size)
		char transport[16];
		int port;
		if (sscanf(buf, "%15s %4d", transport, &port) == 2) {
			if (port < 1 || port > 65535)
				return -EINVAL;
			err = nfsd_create_serv();
			if (!err) {
				err = svc_create_xprt(nfsd_serv,
@@ -960,7 +962,7 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size)
		char transport[16];
		int port;
		if (sscanf(&buf[1], "%15s %4d", transport, &port) == 2) {
			if (port == 0)
			if (port < 1 || port > 65535)
				return -EINVAL;
			if (nfsd_serv) {
				xprt = svc_find_xprt(nfsd_serv, transport,