qrtr: Fix ZERO_SIZE_PTR deref in qrtr_tun_write_iter()
Subsystems (3)
PATCH 1/1 qrtr: Fix ZERO_SIZE_PTR deref in qrtr_tun_write_iter()
qrtr_tun_write_iter() is dereferencing ZERO_SIZE_PTRs when from->count equals to zero. Fix it by rejecting zero-length kzalloc() requests.
This patch fixes the following syzbot bug:
https://syzkaller.appspot.com/bug?id=f56bbe6668873ee245986bbd23312b895fa5a50a
--- net/qrtr/tun.c | 3 +++ 1 file changed, 3 insertions(+)
net/qrtr/tun.c +3 -0
@@ -80,6 +80,9 @@ static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from)ssize_t ret;void *kbuf; +if (!len) +return -EINVAL ; + kbuf =kzalloc (len,GFP_KERNEL );if (!kbuf)return -ENOMEM ;
Signature · 1 line
2.25.1
Quoted 18 lines · Peilin Ye
qrtr_tun_write_iter()is dereferencingZERO_SIZE_PTRs whenfrom->countequals to zero. Fix it by rejecting zero-lengthkzalloc()requests.This patch fixes the following syzbot bug:
https://syzkaller.appspot.com/bug?id=f56bbe6668873ee245986bbd23312b895fa5a50aReported-by [email protected]Signed-off-by Peilin Ye <[email protected]>--- net/qrtr/tun.c | 3 +++ 1 file changed, 3 insertions(+)net/qrtr/tun.c +0
-0
net/qrtr/tun.c static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 88
Quoted 9 lines
net/qrtr/tun.c +3
-0@@ -80,6 +80,9 @@ static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from)ssize_t ret;void *kbuf; +if (!len) +return -EINVAL ; + kbuf =kzalloc (len,GFP_KERNEL );if (!kbuf)return -ENOMEM ;
Wasn't this already fixed by:
commit 8ff41cc21714704ef0158a546c3c4d07fae2c952
Author: Dan Carpenter <[email protected]>
Date: Tue Jun 30 14:46:15 2020 +0300
net: qrtr: Fix an out of bounds read qrtr_endpoint_post()
Quoted 31 lines · Eric Biggers
Quoted 18 lines · Peilin Ye
qrtr_tun_write_iter()is dereferencingZERO_SIZE_PTRs whenfrom->countequals to zero. Fix it by rejecting zero-lengthkzalloc()requests.This patch fixes the following syzbot bug:
https://syzkaller.appspot.com/bug?id=f56bbe6668873ee245986bbd23312b895fa5a50aReported-by [email protected]Signed-off-by Peilin Ye <[email protected]>--- net/qrtr/tun.c | 3 +++ 1 file changed, 3 insertions(+)net/qrtr/tun.c +0
-0net/qrtr/tun.c static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 88
Quoted 9 lines
net/qrtr/tun.c +3
-0@@ -80,6 +80,9 @@ static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from)ssize_t ret;void *kbuf; +if (!len) +return -EINVAL ; + kbuf =kzalloc (len,GFP_KERNEL );if (!kbuf)return -ENOMEM ;Wasn't this already fixed by:
Quoted 5 lines
commit
8ff41cc21714704ef0158a546c3c4d07fae2c952
Author: Dan Carpenter <[email protected]>
Date: Tue Jun 30 14:46:15 2020 +0300net: qrtr: Fix an out of bounds read
qrtr_endpoint_post()
Yep. If you're using kmalloc() you can allocate a zero byte buffer but you just can't access the array. for (i = 0; i < 0; i++) works.
It's interesting because at the time, I wrote the patch I thought "len" probably couldn't be zero but I just checked it for completeness and readability.
regards,
dan carpenter
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees