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

Commit 363e0df0 authored by Dan Carpenter's avatar Dan Carpenter Committed by Trond Myklebust
Browse files

nfs: check for integer overflow in decode_devicenotify_args()



On 32 bit, if n is too large then "n * sizeof(*args->devs)" could
overflow and args->devs would be smaller than expected.

Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 13fff2f3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -305,6 +305,10 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
	n = ntohl(*p++);
	if (n <= 0)
		goto out;
	if (n > ULONG_MAX / sizeof(*args->devs)) {
		status = htonl(NFS4ERR_BADXDR);
		goto out;
	}

	args->devs = kmalloc(n * sizeof(*args->devs), GFP_KERNEL);
	if (!args->devs) {