All of lore.kernel.org
 help / color / mirror / Atom feed
* KASAN: null-ptr-deref Write in video_usercopy
@ 2020-01-08  8:54 syzbot
  2020-01-08 10:59 ` [PATCH] media: v4l2-core: Fix Oops in ioctl Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2020-01-08  8:54 UTC (permalink / raw)
  To: arnd, hverkuil-cisco, linux-kernel, linux-media, mchehab+huawei,
	mchehab, sakari.ailus, syzkaller-bugs

Hello,

syzbot found the following crash on:

HEAD commit:    26467385 Add linux-next specific files for 20200107
git tree:       linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=14160915e00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=2265a716722be976
dashboard link: https://syzkaller.appspot.com/bug?extid=9240c422be249a8422bd
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=15d162aee00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16b9c469e00000

The bug was bisected to:

commit c8ef1a6076bfb986052ff8fd8f5eb3b3a3f1048e
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Dec 16 14:15:02 2019 +0000

     media: v4l2-core: split out data copy from video_usercopy

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=13442bc1e00000
final crash:    https://syzkaller.appspot.com/x/report.txt?x=10c42bc1e00000
console output: https://syzkaller.appspot.com/x/log.txt?x=17442bc1e00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+9240c422be249a8422bd@syzkaller.appspotmail.com
Fixes: c8ef1a6076bf ("media: v4l2-core: split out data copy from  
video_usercopy")

==================================================================
BUG: KASAN: null-ptr-deref in memset include/linux/string.h:411 [inline]
BUG: KASAN: null-ptr-deref in video_get_user+0x67f/0x890  
drivers/media/v4l2-core/v4l2-ioctl.c:3053
Write of size 512 at addr 0000000000000000 by task syz-executor806/9573

CPU: 0 PID: 9573 Comm: syz-executor806 Not tainted  
5.5.0-rc5-next-20200107-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:77 [inline]
  dump_stack+0x197/0x210 lib/dump_stack.c:118
  __kasan_report.cold+0x5/0x32 mm/kasan/report.c:510
  kasan_report+0x12/0x20 mm/kasan/common.c:641
  check_memory_region_inline mm/kasan/generic.c:185 [inline]
  check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192
  memset+0x24/0x40 mm/kasan/common.c:108
  memset include/linux/string.h:411 [inline]
  video_get_user+0x67f/0x890 drivers/media/v4l2-core/v4l2-ioctl.c:3053
  video_usercopy+0x21f/0x10b0 drivers/media/v4l2-core/v4l2-ioctl.c:3210
  video_ioctl2+0x2d/0x35 drivers/media/v4l2-core/v4l2-ioctl.c:3274
  v4l2_ioctl+0x1ac/0x230 drivers/media/v4l2-core/v4l2-dev.c:360
  vfs_ioctl fs/ioctl.c:47 [inline]
  ksys_ioctl+0x123/0x180 fs/ioctl.c:747
  __do_sys_ioctl fs/ioctl.c:756 [inline]
  __se_sys_ioctl fs/ioctl.c:754 [inline]
  __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:754
  do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440189
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffffba225e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440189
RDX: 0000000000000000 RSI: 0000001002008914 RDI: 0000000000000003
RBP: 00000000006ca018 R08: 00000000004002c8 R09: 00000000004002c8
R10: 00000000004002c8 R11: 0000000000000246 R12: 0000000000401a10
R13: 0000000000401aa0 R14: 0000000000000000 R15: 0000000000000000
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] media: v4l2-core: Fix Oops in ioctl
  2020-01-08  8:54 KASAN: null-ptr-deref Write in video_usercopy syzbot
@ 2020-01-08 10:59 ` Dan Carpenter
  2020-01-08 11:12   ` Hans Verkuil
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2020-01-08 10:59 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Arnd Bergmann
  Cc: Hans Verkuil, Sakari Ailus, Ezequiel Garcia, Boris Brezillon,
	Vandana BN, linux-media, linux-kernel, syzkaller-bugs

Syzbot reported a crash in video_usercopy().  It turns out when we
broke video_get_user() into a separate function then we accidentally
moved it outside the if block so it tries to memset a user pointer.

Reported-by: syzbot+9240c422be249a8422bd@syzkaller.appspotmail.com
Fixes: c8ef1a6076bf ("media: v4l2-core: split out data copy from video_usercopy")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Not actually tested.  :(  Sorry.

 drivers/media/v4l2-core/v4l2-ioctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index b68ff06009cd..aaf83e254272 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -3205,12 +3205,12 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg,
 			parg = mbuf;
 		}
 
+		err = video_get_user((void __user *)arg, parg, orig_cmd,
+				     &always_copy);
+		if (err)
+			goto out;
 	}
 
-	err = video_get_user((void __user *)arg, parg, orig_cmd, &always_copy);
-	if (err)
-		goto out;
-
 	err = check_array_args(cmd, parg, &array_size, &user_ptr, &kernel_ptr);
 	if (err < 0)
 		goto out;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: v4l2-core: Fix Oops in ioctl
  2020-01-08 10:59 ` [PATCH] media: v4l2-core: Fix Oops in ioctl Dan Carpenter
@ 2020-01-08 11:12   ` Hans Verkuil
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2020-01-08 11:12 UTC (permalink / raw)
  To: Dan Carpenter, Mauro Carvalho Chehab, Arnd Bergmann
  Cc: Sakari Ailus, Ezequiel Garcia, Boris Brezillon, Vandana BN,
	linux-media, linux-kernel, syzkaller-bugs

Hi Dan,

Marking this as Obsoleted in patchwork since Arnd posted an identical patch for
this already.

Regards,

	Hans

On 1/8/20 11:59 AM, Dan Carpenter wrote:
> Syzbot reported a crash in video_usercopy().  It turns out when we
> broke video_get_user() into a separate function then we accidentally
> moved it outside the if block so it tries to memset a user pointer.
> 
> Reported-by: syzbot+9240c422be249a8422bd@syzkaller.appspotmail.com
> Fixes: c8ef1a6076bf ("media: v4l2-core: split out data copy from video_usercopy")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Not actually tested.  :(  Sorry.
> 
>  drivers/media/v4l2-core/v4l2-ioctl.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index b68ff06009cd..aaf83e254272 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -3205,12 +3205,12 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg,
>  			parg = mbuf;
>  		}
>  
> +		err = video_get_user((void __user *)arg, parg, orig_cmd,
> +				     &always_copy);
> +		if (err)
> +			goto out;
>  	}
>  
> -	err = video_get_user((void __user *)arg, parg, orig_cmd, &always_copy);
> -	if (err)
> -		goto out;
> -
>  	err = check_array_args(cmd, parg, &array_size, &user_ptr, &kernel_ptr);
>  	if (err < 0)
>  		goto out;
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-08 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08  8:54 KASAN: null-ptr-deref Write in video_usercopy syzbot
2020-01-08 10:59 ` [PATCH] media: v4l2-core: Fix Oops in ioctl Dan Carpenter
2020-01-08 11:12   ` Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.