linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
@ 2019-03-28 16:14 syzbot
  2019-03-28 16:32 ` Todd Kjos
  2019-03-28 23:46 ` syzbot
  0 siblings, 2 replies; 12+ messages in thread
From: syzbot @ 2019-03-28 16:14 UTC (permalink / raw)
  To: arve, christian, devel, gregkh, joel, linux-kernel, maco,
	syzkaller-bugs, tkjos

Hello,

syzbot found the following crash on:

HEAD commit:    1a9df9e2 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11fed11f200000
kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
dashboard link: https://syzkaller.appspot.com/bug?extid=f9f3f388440283da2965
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=17d05637200000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1677e62f200000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com

binder: 7824:7824 DecRefs 0 refcount change on invalid ref 1 ret -22
------------[ cut here ]------------
kernel BUG at drivers/android/binder_alloc.c:1141!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 7824 Comm: syz-executor570 Not tainted 5.1.0-rc2+ #40
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
RIP: 0010:binder_alloc_do_buffer_copy+0xd6/0x510  
drivers/android/binder_alloc.c:1141
Code: 02 00 0f 85 20 04 00 00 4d 8b 64 24 58 49 29 dc e8 4f f4 23 fc 4c 89  
e6 4c 89 ef e8 64 f5 23 fc 4d 39 e5 76 07 e8 3a f4 23 fc <0f> 0b e8 33 f4  
23 fc 4c 8b 75 d0 4d 29 ec 4c 89 e6 4c 89 f7 e8 41
RSP: 0018:ffff88808b497550 EFLAGS: 00010293
RAX: ffff88808620e540 RBX: 0000000020001000 RCX: ffffffff854c7d3c
RDX: 0000000000000000 RSI: ffffffff854c7d46 RDI: 0000000000000006
RBP: ffff88808b4975d0 R08: ffff88808620e540 R09: 0000000000000028
R10: ffffed1011692f01 R11: ffff88808b49780f R12: 0000000000000008
R13: 0000000000000028 R14: ffff888088a0cb10 R15: 0000000000000000
FS:  00000000006de940(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000004c4d28 CR3: 0000000090d8e000 CR4: 00000000001406e0
Call Trace:
  binder_alloc_copy_from_buffer+0x37/0x42 drivers/android/binder_alloc.c:1187
  binder_get_object+0xc3/0x200 drivers/android/binder.c:2062
  binder_transaction+0x2b4a/0x6690 drivers/android/binder.c:3231
  binder_thread_write+0x87e/0x2820 drivers/android/binder.c:3781
  binder_ioctl_write_read drivers/android/binder.c:4825 [inline]
  binder_ioctl+0x1033/0x183b drivers/android/binder.c:5002
  vfs_ioctl fs/ioctl.c:46 [inline]
  file_ioctl fs/ioctl.c:509 [inline]
  do_vfs_ioctl+0xd6e/0x1390 fs/ioctl.c:696
  ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
  __do_sys_ioctl fs/ioctl.c:720 [inline]
  __se_sys_ioctl fs/ioctl.c:718 [inline]
  __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
  do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x445f19
Code: e8 7c e7 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 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 db cb fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fffeaa7b578 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000445f19
RDX: 0000000020000240 RSI: 00000000c0306201 RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000403010
R10: 00007fffeaa7b0d0 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000403010 R14: 0000000000000000 R15: 0000000000000000
Modules linked in:
---[ end trace 0f3d90ce4ca56ff6 ]---
RIP: 0010:binder_alloc_do_buffer_copy+0xd6/0x510  
drivers/android/binder_alloc.c:1141
Code: 02 00 0f 85 20 04 00 00 4d 8b 64 24 58 49 29 dc e8 4f f4 23 fc 4c 89  
e6 4c 89 ef e8 64 f5 23 fc 4d 39 e5 76 07 e8 3a f4 23 fc <0f> 0b e8 33 f4  
23 fc 4c 8b 75 d0 4d 29 ec 4c 89 e6 4c 89 f7 e8 41
RSP: 0018:ffff88808b497550 EFLAGS: 00010293
RAX: ffff88808620e540 RBX: 0000000020001000 RCX: ffffffff854c7d3c
RDX: 0000000000000000 RSI: ffffffff854c7d46 RDI: 0000000000000006
RBP: ffff88808b4975d0 R08: ffff88808620e540 R09: 0000000000000028
R10: ffffed1011692f01 R11: ffff88808b49780f R12: 0000000000000008
R13: 0000000000000028 R14: ffff888088a0cb10 R15: 0000000000000000
FS:  00000000006de940(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000004c4d28 CR3: 0000000090d8e000 CR4: 00000000001406f0


---
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.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-03-28 16:14 kernel BUG at drivers/android/binder_alloc.c:LINE! (3) syzbot
@ 2019-03-28 16:32 ` Todd Kjos
  2019-03-28 19:27   ` syzbot
  2019-03-28 23:46 ` syzbot
  1 sibling, 1 reply; 12+ messages in thread
From: Todd Kjos @ 2019-03-28 16:32 UTC (permalink / raw)
  To: syzbot
  Cc: Arve Hjønnevåg, Christian Brauner,
	open list:ANDROID DRIVERS, Greg Kroah-Hartman,
	Joel Fernandes (Google),
	LKML, Martijn Coenen, syzkaller-bugs, Todd Kjos

[-- Attachment #1: Type: text/plain, Size: 5096 bytes --]

The fix for this is in Greg KH's char-misc-linus branch. Pointing
syzbot at it to verify:

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
char-misc-linus


On Thu, Mar 28, 2019 at 9:14 AM syzbot
<syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit:    1a9df9e2 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=11fed11f200000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
> dashboard link: https://syzkaller.appspot.com/bug?extid=f9f3f388440283da2965
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=17d05637200000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1677e62f200000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com
>
> binder: 7824:7824 DecRefs 0 refcount change on invalid ref 1 ret -22
> ------------[ cut here ]------------
> kernel BUG at drivers/android/binder_alloc.c:1141!
> invalid opcode: 0000 [#1] PREEMPT SMP KASAN
> CPU: 1 PID: 7824 Comm: syz-executor570 Not tainted 5.1.0-rc2+ #40
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> RIP: 0010:binder_alloc_do_buffer_copy+0xd6/0x510
> drivers/android/binder_alloc.c:1141
> Code: 02 00 0f 85 20 04 00 00 4d 8b 64 24 58 49 29 dc e8 4f f4 23 fc 4c 89
> e6 4c 89 ef e8 64 f5 23 fc 4d 39 e5 76 07 e8 3a f4 23 fc <0f> 0b e8 33 f4
> 23 fc 4c 8b 75 d0 4d 29 ec 4c 89 e6 4c 89 f7 e8 41
> RSP: 0018:ffff88808b497550 EFLAGS: 00010293
> RAX: ffff88808620e540 RBX: 0000000020001000 RCX: ffffffff854c7d3c
> RDX: 0000000000000000 RSI: ffffffff854c7d46 RDI: 0000000000000006
> RBP: ffff88808b4975d0 R08: ffff88808620e540 R09: 0000000000000028
> R10: ffffed1011692f01 R11: ffff88808b49780f R12: 0000000000000008
> R13: 0000000000000028 R14: ffff888088a0cb10 R15: 0000000000000000
> FS:  00000000006de940(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00000000004c4d28 CR3: 0000000090d8e000 CR4: 00000000001406e0
> Call Trace:
>   binder_alloc_copy_from_buffer+0x37/0x42 drivers/android/binder_alloc.c:1187
>   binder_get_object+0xc3/0x200 drivers/android/binder.c:2062
>   binder_transaction+0x2b4a/0x6690 drivers/android/binder.c:3231
>   binder_thread_write+0x87e/0x2820 drivers/android/binder.c:3781
>   binder_ioctl_write_read drivers/android/binder.c:4825 [inline]
>   binder_ioctl+0x1033/0x183b drivers/android/binder.c:5002
>   vfs_ioctl fs/ioctl.c:46 [inline]
>   file_ioctl fs/ioctl.c:509 [inline]
>   do_vfs_ioctl+0xd6e/0x1390 fs/ioctl.c:696
>   ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
>   __do_sys_ioctl fs/ioctl.c:720 [inline]
>   __se_sys_ioctl fs/ioctl.c:718 [inline]
>   __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
>   do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
>   entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x445f19
> Code: e8 7c e7 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 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 db cb fb ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:00007fffeaa7b578 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000445f19
> RDX: 0000000020000240 RSI: 00000000c0306201 RDI: 0000000000000003
> RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000403010
> R10: 00007fffeaa7b0d0 R11: 0000000000000246 R12: 0000000000000000
> R13: 0000000000403010 R14: 0000000000000000 R15: 0000000000000000
> Modules linked in:
> ---[ end trace 0f3d90ce4ca56ff6 ]---
> RIP: 0010:binder_alloc_do_buffer_copy+0xd6/0x510
> drivers/android/binder_alloc.c:1141
> Code: 02 00 0f 85 20 04 00 00 4d 8b 64 24 58 49 29 dc e8 4f f4 23 fc 4c 89
> e6 4c 89 ef e8 64 f5 23 fc 4d 39 e5 76 07 e8 3a f4 23 fc <0f> 0b e8 33 f4
> 23 fc 4c 8b 75 d0 4d 29 ec 4c 89 e6 4c 89 f7 e8 41
> RSP: 0018:ffff88808b497550 EFLAGS: 00010293
> RAX: ffff88808620e540 RBX: 0000000020001000 RCX: ffffffff854c7d3c
> RDX: 0000000000000000 RSI: ffffffff854c7d46 RDI: 0000000000000006
> RBP: ffff88808b4975d0 R08: ffff88808620e540 R09: 0000000000000028
> R10: ffffed1011692f01 R11: ffff88808b49780f R12: 0000000000000008
> R13: 0000000000000028 R14: ffff888088a0cb10 R15: 0000000000000000
> FS:  00000000006de940(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00000000004c4d28 CR3: 0000000090d8e000 CR4: 00000000001406f0
>
>
> ---
> 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.
> syzbot can test patches for this bug, for details see:
> https://goo.gl/tpsmEJ#testing-patches

[-- Attachment #2: 0001-binder-fix-crash-in-binder_alloc_do_buffer_copy.patch --]
[-- Type: text/x-patch, Size: 1391 bytes --]

From d49c95c944c15732ef57f1c876e24838b2ddf34b Mon Sep 17 00:00:00 2001
From: Todd Kjos <tkjos@google.com>
Date: Tue, 19 Mar 2019 09:53:01 -0700
Subject: [PATCH] binder: fix BUG_ON found by selinux-testsuite

The selinux-testsuite found an issue resulting in a BUG_ON()
where a conditional relied on a size_t going negative when
checking the validity of a buffer offset.

Fixes: 7a67a39320df ("binder: add function to copy binder object from buffer")
Reported-by: Paul Moore <paul@paul-moore.com>
Tested-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Todd Kjos <tkjos@google.com>
---
Please add to 5.1 (fixes problem introduced in 5.1-rc1)

 drivers/android/binder.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 8685882da64cd..4b9c7ca492e6d 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2057,7 +2057,8 @@ static size_t binder_get_object(struct binder_proc *proc,
 	size_t object_size = 0;
 
 	read_size = min_t(size_t, sizeof(*object), buffer->data_size - offset);
-	if (read_size < sizeof(*hdr) || !IS_ALIGNED(offset, sizeof(u32)))
+	if (offset > buffer->data_size || read_size < sizeof(*hdr) ||
+	    !IS_ALIGNED(offset, sizeof(u32)))
 		return 0;
 	binder_alloc_copy_from_buffer(&proc->alloc, object, buffer,
 				      offset, read_size);
-- 
2.21.0.225.g810b269d1ac-goog


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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-03-28 16:32 ` Todd Kjos
@ 2019-03-28 19:27   ` syzbot
  2019-03-28 20:01     ` Todd Kjos
  0 siblings, 1 reply; 12+ messages in thread
From: syzbot @ 2019-03-28 19:27 UTC (permalink / raw)
  To: arve, christian, devel, gregkh, joel, linux-kernel, maco,
	syzkaller-bugs, tkjos, tkjos

Hello,

syzbot tried to test the proposed patch but build/boot failed:

patch is already applied


Tested on:

commit:         0532a1b0 virt: vbox: Implement passing requestor info to t..
git tree:        
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git  
char-misc-linus
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1577678b200000


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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-03-28 19:27   ` syzbot
@ 2019-03-28 20:01     ` Todd Kjos
  2019-03-29  0:20       ` syzbot
  0 siblings, 1 reply; 12+ messages in thread
From: Todd Kjos @ 2019-03-28 20:01 UTC (permalink / raw)
  To: syzbot
  Cc: Arve Hjønnevåg, Christian Brauner,
	open list:ANDROID DRIVERS, Greg Kroah-Hartman,
	Joel Fernandes (Google),
	LKML, Martijn Coenen, syzkaller-bugs, Todd Kjos

On Thu, Mar 28, 2019 at 12:27 PM syzbot
<syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot tried to test the proposed patch but build/boot failed:
>
> patch is already applied
>
>
> Tested on:
>
> commit:         0532a1b0 virt: vbox: Implement passing requestor info to t..
> git tree:
> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
> char-misc-linus
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> patch:          https://syzkaller.appspot.com/x/patch.diff?x=1577678b200000
>

Trying again without (redundantly) attaching the patch...

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
char-misc-linus

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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-03-28 16:14 kernel BUG at drivers/android/binder_alloc.c:LINE! (3) syzbot
  2019-03-28 16:32 ` Todd Kjos
@ 2019-03-28 23:46 ` syzbot
  1 sibling, 0 replies; 12+ messages in thread
From: syzbot @ 2019-03-28 23:46 UTC (permalink / raw)
  To: a, arve, b.a.t.m.a.n, christian, davem, devel, gregkh, joel,
	linux-kernel, maco, mareklindner, netdev, sw, syzkaller-bugs,
	tkjos, tkjos

syzbot has bisected this bug to:

commit 1a7c3d9bb7a926e88d5f57643e75ad1abfc55013
Author: Todd Kjos <tkjos@android.com>
Date:   Fri Feb 8 18:35:14 2019 +0000

     binder: create userspace-to-binder-buffer copy function

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=15b9383f200000
start commit:   1a9df9e2 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
git tree:       upstream
final crash:    https://syzkaller.appspot.com/x/report.txt?x=17b9383f200000
console output: https://syzkaller.appspot.com/x/log.txt?x=13b9383f200000
kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
dashboard link: https://syzkaller.appspot.com/bug?extid=f9f3f388440283da2965
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=17d05637200000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1677e62f200000

Reported-by: syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com
Fixes: 1a7c3d9bb7a9 ("binder: create userspace-to-binder-buffer copy  
function")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-03-28 20:01     ` Todd Kjos
@ 2019-03-29  0:20       ` syzbot
  2019-03-29  0:59         ` Todd Kjos
  0 siblings, 1 reply; 12+ messages in thread
From: syzbot @ 2019-03-29  0:20 UTC (permalink / raw)
  To: arve, christian, devel, gregkh, joel, linux-kernel, maco,
	syzkaller-bugs, tkjos, tkjos

Hello,

syzbot tried to test the proposed patch but build/boot failed:

timed out






Tested on:

commit:         0532a1b0 virt: vbox: Implement passing requestor info to t..
git tree:        
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git  
char-misc-linus
kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)


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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-03-29  0:20       ` syzbot
@ 2019-03-29  0:59         ` Todd Kjos
  2019-03-29  9:55           ` syzbot
  0 siblings, 1 reply; 12+ messages in thread
From: Todd Kjos @ 2019-03-29  0:59 UTC (permalink / raw)
  To: syzbot
  Cc: Arve Hjønnevåg, Christian Brauner,
	open list:ANDROID DRIVERS, Greg Kroah-Hartman,
	Joel Fernandes (Google),
	LKML, Martijn Coenen, syzkaller-bugs, Todd Kjos

[-- Attachment #1: Type: text/plain, Size: 764 bytes --]

Sigh. One more try... master with the same patch as an attachment.
(the patch is already queued up in gregkh's 'char-misc-linus' branch).

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
master

On Thu, Mar 28, 2019 at 5:20 PM syzbot
<syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot tried to test the proposed patch but build/boot failed:
>
> timed out
>
>
>
>
>
>
> Tested on:
>
> commit:         0532a1b0 virt: vbox: Implement passing requestor info to t..
> git tree:
> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
> char-misc-linus
> kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
>

[-- Attachment #2: 0001-binder-fix-crash-in-binder_alloc_do_buffer_copy.patch --]
[-- Type: text/x-patch, Size: 1391 bytes --]

From d49c95c944c15732ef57f1c876e24838b2ddf34b Mon Sep 17 00:00:00 2001
From: Todd Kjos <tkjos@google.com>
Date: Tue, 19 Mar 2019 09:53:01 -0700
Subject: [PATCH] binder: fix BUG_ON found by selinux-testsuite

The selinux-testsuite found an issue resulting in a BUG_ON()
where a conditional relied on a size_t going negative when
checking the validity of a buffer offset.

Fixes: 7a67a39320df ("binder: add function to copy binder object from buffer")
Reported-by: Paul Moore <paul@paul-moore.com>
Tested-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Todd Kjos <tkjos@google.com>
---
Please add to 5.1 (fixes problem introduced in 5.1-rc1)

 drivers/android/binder.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 8685882da64cd..4b9c7ca492e6d 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2057,7 +2057,8 @@ static size_t binder_get_object(struct binder_proc *proc,
 	size_t object_size = 0;
 
 	read_size = min_t(size_t, sizeof(*object), buffer->data_size - offset);
-	if (read_size < sizeof(*hdr) || !IS_ALIGNED(offset, sizeof(u32)))
+	if (offset > buffer->data_size || read_size < sizeof(*hdr) ||
+	    !IS_ALIGNED(offset, sizeof(u32)))
 		return 0;
 	binder_alloc_copy_from_buffer(&proc->alloc, object, buffer,
 				      offset, read_size);
-- 
2.21.0.225.g810b269d1ac-goog


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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-03-29  0:59         ` Todd Kjos
@ 2019-03-29  9:55           ` syzbot
  2019-05-17 10:08             ` Dmitry Vyukov
  0 siblings, 1 reply; 12+ messages in thread
From: syzbot @ 2019-03-29  9:55 UTC (permalink / raw)
  To: arve, christian, devel, gregkh, joel, linux-kernel, maco,
	syzkaller-bugs, tkjos, tkjos

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger  
crash:

Reported-and-tested-by:  
syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com

Tested on:

commit:         8c2ffd91 Linux 5.1-rc2
git tree:        
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master
kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
patch:          https://syzkaller.appspot.com/x/patch.diff?x=10fed663200000

Note: testing is done by a robot and is best-effort only.

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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-03-29  9:55           ` syzbot
@ 2019-05-17 10:08             ` Dmitry Vyukov
  2019-05-17 15:26               ` Todd Kjos
  0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Vyukov @ 2019-05-17 10:08 UTC (permalink / raw)
  To: syzbot
  Cc: Arve Hjønnevåg, Christian Brauner,
	open list:ANDROID DRIVERS, Greg Kroah-Hartman, Joel Fernandes,
	LKML, Martijn Coenen, syzkaller-bugs, Todd Kjos, Todd Kjos

On Fri, Mar 29, 2019 at 10:55 AM syzbot
<syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot has tested the proposed patch and the reproducer did not trigger
> crash:
>
> Reported-and-tested-by:
> syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com
>
> Tested on:
>
> commit:         8c2ffd91 Linux 5.1-rc2
> git tree:
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master
> kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> patch:          https://syzkaller.appspot.com/x/patch.diff?x=10fed663200000
>
> Note: testing is done by a robot and is best-effort only.


Todd,

Should this patch fix the bug? Should we close the bug as fixed then?
In my local testing I see this BUG still fires, but if we will leave
old fixed bugs open, we will not get notifications about new crashes.

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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-05-17 10:08             ` Dmitry Vyukov
@ 2019-05-17 15:26               ` Todd Kjos
  2019-05-17 15:33                 ` Dmitry Vyukov
  0 siblings, 1 reply; 12+ messages in thread
From: Todd Kjos @ 2019-05-17 15:26 UTC (permalink / raw)
  To: Dmitry Vyukov
  Cc: syzbot, Arve Hjønnevåg, Christian Brauner,
	open list:ANDROID DRIVERS, Greg Kroah-Hartman, Joel Fernandes,
	LKML, Martijn Coenen, syzkaller-bugs, Todd Kjos

Yes (and syzbot seemed to confirm the fix). I didn't realize I needed
to manually close the issue. I guess you closed it yesterday.

From: Dmitry Vyukov <dvyukov@google.com>
Date: Fri, May 17, 2019 at 3:08 AM
To: syzbot
Cc: Arve Hjønnevåg, Christian Brauner, open list:ANDROID DRIVERS, Greg
Kroah-Hartman, Joel Fernandes, LKML, Martijn Coenen, syzkaller-bugs,
Todd Kjos <tkjos@android.com>, Todd Kjos <tkjos@google.com>

> On Fri, Mar 29, 2019 at 10:55 AM syzbot
> <syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com> wrote:
> >
> > Hello,
> >
> > syzbot has tested the proposed patch and the reproducer did not trigger
> > crash:
> >
> > Reported-and-tested-by:
> > syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com
> >
> > Tested on:
> >
> > commit:         8c2ffd91 Linux 5.1-rc2
> > git tree:
> > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
> > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > patch:          https://syzkaller.appspot.com/x/patch.diff?x=10fed663200000
> >
> > Note: testing is done by a robot and is best-effort only.
>
>
> Todd,
>
> Should this patch fix the bug? Should we close the bug as fixed then?
> In my local testing I see this BUG still fires, but if we will leave
> old fixed bugs open, we will not get notifications about new crashes.

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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-05-17 15:26               ` Todd Kjos
@ 2019-05-17 15:33                 ` Dmitry Vyukov
  2019-05-17 17:24                   ` Todd Kjos
  0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Vyukov @ 2019-05-17 15:33 UTC (permalink / raw)
  To: Todd Kjos
  Cc: syzbot, Arve Hjønnevåg, Christian Brauner,
	open list:ANDROID DRIVERS, Greg Kroah-Hartman, Joel Fernandes,
	LKML, Martijn Coenen, syzkaller-bugs, Todd Kjos

On Fri, May 17, 2019 at 5:26 PM Todd Kjos <tkjos@google.com> wrote:
>
> Yes (and syzbot seemed to confirm the fix). I didn't realize I needed
> to manually close the issue. I guess you closed it yesterday.

This is required to auto-close the bug when the commit is merged:

> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com

Otherwise somebody needs to say:

#syz fix: binder: fix BUG_ON found by selinux-testsuite


> From: Dmitry Vyukov <dvyukov@google.com>
> Date: Fri, May 17, 2019 at 3:08 AM
> To: syzbot
> Cc: Arve Hjønnevåg, Christian Brauner, open list:ANDROID DRIVERS, Greg
> Kroah-Hartman, Joel Fernandes, LKML, Martijn Coenen, syzkaller-bugs,
> Todd Kjos <tkjos@android.com>, Todd Kjos <tkjos@google.com>
>
> > On Fri, Mar 29, 2019 at 10:55 AM syzbot
> > <syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com> wrote:
> > >
> > > Hello,
> > >
> > > syzbot has tested the proposed patch and the reproducer did not trigger
> > > crash:
> > >
> > > Reported-and-tested-by:
> > > syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com
> > >
> > > Tested on:
> > >
> > > commit:         8c2ffd91 Linux 5.1-rc2
> > > git tree:
> > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master
> > > kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
> > > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > > patch:          https://syzkaller.appspot.com/x/patch.diff?x=10fed663200000
> > >
> > > Note: testing is done by a robot and is best-effort only.
> >
> >
> > Todd,
> >
> > Should this patch fix the bug? Should we close the bug as fixed then?
> > In my local testing I see this BUG still fires, but if we will leave
> > old fixed bugs open, we will not get notifications about new crashes.

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

* Re: kernel BUG at drivers/android/binder_alloc.c:LINE! (3)
  2019-05-17 15:33                 ` Dmitry Vyukov
@ 2019-05-17 17:24                   ` Todd Kjos
  0 siblings, 0 replies; 12+ messages in thread
From: Todd Kjos @ 2019-05-17 17:24 UTC (permalink / raw)
  To: Dmitry Vyukov
  Cc: syzbot, Arve Hjønnevåg, Christian Brauner,
	open list:ANDROID DRIVERS, Greg Kroah-Hartman, Joel Fernandes,
	LKML, Martijn Coenen, syzkaller-bugs, Todd Kjos

On Fri, May 17, 2019 at 8:33 AM Dmitry Vyukov <dvyukov@google.com> wrote:
>
> On Fri, May 17, 2019 at 5:26 PM Todd Kjos <tkjos@google.com> wrote:
> >
> > Yes (and syzbot seemed to confirm the fix). I didn't realize I needed
> > to manually close the issue. I guess you closed it yesterday.
>
> This is required to auto-close the bug when the commit is merged:
>
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com
>
> Otherwise somebody needs to say:
>
> #syz fix: binder: fix BUG_ON found by selinux-testsuite

It looks like you closed it with your #sys comment ^^^

>
>
> > From: Dmitry Vyukov <dvyukov@google.com>
> > Date: Fri, May 17, 2019 at 3:08 AM
> > To: syzbot
> > Cc: Arve Hjønnevåg, Christian Brauner, open list:ANDROID DRIVERS, Greg
> > Kroah-Hartman, Joel Fernandes, LKML, Martijn Coenen, syzkaller-bugs,
> > Todd Kjos <tkjos@android.com>, Todd Kjos <tkjos@google.com>
> >
> > > On Fri, Mar 29, 2019 at 10:55 AM syzbot
> > > <syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com> wrote:
> > > >
> > > > Hello,
> > > >
> > > > syzbot has tested the proposed patch and the reproducer did not trigger
> > > > crash:
> > > >
> > > > Reported-and-tested-by:
> > > > syzbot+f9f3f388440283da2965@syzkaller.appspotmail.com
> > > >
> > > > Tested on:
> > > >
> > > > commit:         8c2ffd91 Linux 5.1-rc2
> > > > git tree:
> > > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master
> > > > kernel config:  https://syzkaller.appspot.com/x/.config?x=8dcdce25ea72bedf
> > > > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > > > patch:          https://syzkaller.appspot.com/x/patch.diff?x=10fed663200000
> > > >
> > > > Note: testing is done by a robot and is best-effort only.
> > >
> > >
> > > Todd,
> > >
> > > Should this patch fix the bug? Should we close the bug as fixed then?
> > > In my local testing I see this BUG still fires, but if we will leave
> > > old fixed bugs open, we will not get notifications about new crashes.

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

end of thread, other threads:[~2019-05-17 17:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-28 16:14 kernel BUG at drivers/android/binder_alloc.c:LINE! (3) syzbot
2019-03-28 16:32 ` Todd Kjos
2019-03-28 19:27   ` syzbot
2019-03-28 20:01     ` Todd Kjos
2019-03-29  0:20       ` syzbot
2019-03-29  0:59         ` Todd Kjos
2019-03-29  9:55           ` syzbot
2019-05-17 10:08             ` Dmitry Vyukov
2019-05-17 15:26               ` Todd Kjos
2019-05-17 15:33                 ` Dmitry Vyukov
2019-05-17 17:24                   ` Todd Kjos
2019-03-28 23:46 ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).