瀏覽代碼

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: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Dan Carpenter 13 年之前
父節點
當前提交
363e0df057
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      fs/nfs/callback_xdr.c

+ 4 - 0
fs/nfs/callback_xdr.c

@@ -305,6 +305,10 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
 	n = ntohl(*p++);
 	n = ntohl(*p++);
 	if (n <= 0)
 	if (n <= 0)
 		goto out;
 		goto out;
+	if (n > ULONG_MAX / sizeof(*args->devs)) {
+		status = htonl(NFS4ERR_BADXDR);
+		goto out;
+	}
 
 
 	args->devs = kmalloc(n * sizeof(*args->devs), GFP_KERNEL);
 	args->devs = kmalloc(n * sizeof(*args->devs), GFP_KERNEL);
 	if (!args->devs) {
 	if (!args->devs) {