Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* general protection fault in sock_close
@ 2020-08-31 19:48 syzbot
  2020-08-31 20:03 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2020-08-31 19:48 UTC (permalink / raw)
  To: davem, kuba, linux-fsdevel, linux-kernel, maz, netdev,
	syzkaller-bugs, viro

Hello,

syzbot found the following issue on:

HEAD commit:    15bc20c6 Merge tag 'tty-5.9-rc3' of git://git.kernel.org/p..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16a85669900000
kernel config:  https://syzkaller.appspot.com/x/.config?x=891ca5711a9f1650
dashboard link: https://syzkaller.appspot.com/bug?extid=e24baf53dc389927a7c3
compiler:       clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=127d3c99900000

The issue was bisected to:

commit a9ed4a6560b8562b7e2e2bed9527e88001f7b682
Author: Marc Zyngier <maz@kernel.org>
Date:   Wed Aug 19 16:12:17 2020 +0000

    epoll: Keep a reference on files added to the check list

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=1374d7c5900000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=10f4d7c5900000
console output: https://syzkaller.appspot.com/x/log.txt?x=1774d7c5900000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e24baf53dc389927a7c3@syzkaller.appspotmail.com
Fixes: a9ed4a6560b8 ("epoll: Keep a reference on files added to the check list")

general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 1 PID: 10933 Comm: syz-executor.0 Not tainted 5.9.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__sock_release net/socket.c:596 [inline]
RIP: 0010:sock_close+0xc5/0x260 net/socket.c:1277
Code: fc ff df 41 80 3c 04 00 74 08 4c 89 ff e8 e3 cf 49 fb 49 8b 1f 48 83 c3 10 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 48 89 df e8 bd cf 49 fb 4c 89 f7 ff 13 49 8d 5e
RSP: 0018:ffffc9000535fe10 EFLAGS: 00010202
RAX: 0000000000000002 RBX: 0000000000000010 RCX: dffffc0000000000
RDX: 0000000000000001 RSI: 0000000000000004 RDI: 0000000000000001
RBP: ffffffff88bbc748 R08: dffffc0000000000 R09: ffffed1010361edf
R10: ffffed1010361edf R11: 0000000000000000 R12: 1ffff11010361eac
R13: ffff888081b0f6e0 R14: ffff888081b0f540 R15: ffff888081b0f560
FS:  00007fad45047700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fad45025db8 CR3: 0000000084c1d000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 __fput+0x34f/0x7b0 fs/file_table.c:281
 task_work_run+0x137/0x1c0 kernel/task_work.c:141
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:140 [inline]
 exit_to_user_mode_prepare+0xfa/0x1b0 kernel/entry/common.c:167
 syscall_exit_to_user_mode+0x5e/0x1a0 kernel/entry/common.c:242
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45d5b9
Code: 5d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 2b b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fad45046c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000e9
RAX: 0000000000000000 RBX: 0000000000002ac0 RCX: 000000000045d5b9
RDX: 0000000000000004 RSI: 0000000000000001 RDI: 0000000000000005
RBP: 000000000118cf88 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000200003c0 R11: 0000000000000246 R12: 000000000118cf4c
R13: 00007ffd8c03abcf R14: 00007fad450479c0 R15: 000000000118cf4c
Modules linked in:
---[ end trace a8eab99154db8026 ]---
RIP: 0010:__sock_release net/socket.c:596 [inline]
RIP: 0010:sock_close+0xc5/0x260 net/socket.c:1277
Code: fc ff df 41 80 3c 04 00 74 08 4c 89 ff e8 e3 cf 49 fb 49 8b 1f 48 83 c3 10 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 48 89 df e8 bd cf 49 fb 4c 89 f7 ff 13 49 8d 5e
RSP: 0018:ffffc9000535fe10 EFLAGS: 00010202
RAX: 0000000000000002 RBX: 0000000000000010 RCX: dffffc0000000000
RDX: 0000000000000001 RSI: 0000000000000004 RDI: 0000000000000001
RBP: ffffffff88bbc748 R08: dffffc0000000000 R09: ffffed1010361edf
R10: ffffed1010361edf R11: 0000000000000000 R12: 1ffff11010361eac
R13: ffff888081b0f6e0 R14: ffff888081b0f540 R15: ffff888081b0f560
FS:  00007fad45047700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6e37205010 CR3: 0000000084c1d000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
This report 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 issue. 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 issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

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

* Re: general protection fault in sock_close
  2020-08-31 19:48 general protection fault in sock_close syzbot
@ 2020-08-31 20:03 ` Al Viro
  2020-08-31 20:39   ` Marc Zyngier
  0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2020-08-31 20:03 UTC (permalink / raw)
  To: syzbot
  Cc: davem, kuba, linux-fsdevel, linux-kernel, maz, netdev, syzkaller-bugs

On Mon, Aug 31, 2020 at 12:48:13PM -0700, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    15bc20c6 Merge tag 'tty-5.9-rc3' of git://git.kernel.org/p..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=16a85669900000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=891ca5711a9f1650
> dashboard link: https://syzkaller.appspot.com/bug?extid=e24baf53dc389927a7c3
> compiler:       clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=127d3c99900000

> The issue was bisected to:
> 
> commit a9ed4a6560b8562b7e2e2bed9527e88001f7b682
> Author: Marc Zyngier <maz@kernel.org>
> Date:   Wed Aug 19 16:12:17 2020 +0000
> 
>     epoll: Keep a reference on files added to the check list

All of those are essentially duplicates.

The minimal fix is below; I'm not happy with it long-term, but I'm still
digging through the eventpoll locking, and there's a good chance that this
is the least intrusive variant for -stable.  Folks, could you check if the
following patch fixes those suckers?  Again, all reports bisected to that
commit are essentially the same.

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index e0decff22ae2..8107e06d7f6f 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1995,9 +1995,9 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests)
 			 * during ep_insert().
 			 */
 			if (list_empty(&epi->ffd.file->f_tfile_llink)) {
-				get_file(epi->ffd.file);
-				list_add(&epi->ffd.file->f_tfile_llink,
-					 &tfile_check_list);
+				if (get_file_rcu(epi->ffd.file))
+					list_add(&epi->ffd.file->f_tfile_llink,
+						 &tfile_check_list);
 			}
 		}
 	}

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

* Re: general protection fault in sock_close
  2020-08-31 20:03 ` Al Viro
@ 2020-08-31 20:39   ` Marc Zyngier
  0 siblings, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2020-08-31 20:39 UTC (permalink / raw)
  To: Al Viro
  Cc: syzbot, davem, kuba, linux-fsdevel, linux-kernel, netdev, syzkaller-bugs

On 2020-08-31 21:03, Al Viro wrote:
> On Mon, Aug 31, 2020 at 12:48:13PM -0700, syzbot wrote:
>> Hello,
>> 
>> syzbot found the following issue on:
>> 
>> HEAD commit:    15bc20c6 Merge tag 'tty-5.9-rc3' of 
>> git://git.kernel.org/p..
>> git tree:       upstream
>> console output: 
>> https://syzkaller.appspot.com/x/log.txt?x=16a85669900000
>> kernel config:  
>> https://syzkaller.appspot.com/x/.config?x=891ca5711a9f1650
>> dashboard link: 
>> https://syzkaller.appspot.com/bug?extid=e24baf53dc389927a7c3
>> compiler:       clang version 10.0.0 
>> (https://github.com/llvm/llvm-project/ 
>> c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
>> syz repro:      
>> https://syzkaller.appspot.com/x/repro.syz?x=127d3c99900000
> 
>> The issue was bisected to:
>> 
>> commit a9ed4a6560b8562b7e2e2bed9527e88001f7b682
>> Author: Marc Zyngier <maz@kernel.org>
>> Date:   Wed Aug 19 16:12:17 2020 +0000
>> 
>>     epoll: Keep a reference on files added to the check list
> 
> All of those are essentially duplicates.
> 
> The minimal fix is below; I'm not happy with it long-term, but I'm 
> still
> digging through the eventpoll locking, and there's a good chance that 
> this
> is the least intrusive variant for -stable.  Folks, could you check if 
> the
> following patch fixes those suckers?  Again, all reports bisected to 
> that
> commit are essentially the same.
> 
> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> index e0decff22ae2..8107e06d7f6f 100644
> --- a/fs/eventpoll.c
> +++ b/fs/eventpoll.c
> @@ -1995,9 +1995,9 @@ static int ep_loop_check_proc(void *priv, void
> *cookie, int call_nests)
>  			 * during ep_insert().
>  			 */
>  			if (list_empty(&epi->ffd.file->f_tfile_llink)) {
> -				get_file(epi->ffd.file);
> -				list_add(&epi->ffd.file->f_tfile_llink,
> -					 &tfile_check_list);
> +				if (get_file_rcu(epi->ffd.file))
> +					list_add(&epi->ffd.file->f_tfile_llink,
> +						 &tfile_check_list);
>  			}
>  		}
>  	}

I've managed to reproduce the issue using [1] (throw a few in a VM,
see things explode like clockwork).

With this patch on top of -rc3, the VM keep ticking away. FWIW:

Tested-by: Marc Zyngier <maz@kernel.org>
Fixes: a9ed4a6560b8 ("epoll: Keep a reference on files added to the 
check list")

Thanks,

         M.

[1] https://syzkaller.appspot.com/x/repro.c?x=140a19a9900000
-- 
Jazz is not dead. It just smells funny...

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

end of thread, other threads:[~2020-08-31 20:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 19:48 general protection fault in sock_close syzbot
2020-08-31 20:03 ` Al Viro
2020-08-31 20:39   ` Marc Zyngier

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).