io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: general protection fault in override_creds
       [not found] <000000000000da160a0598b2c704@google.com>
@ 2019-12-02  6:40 ` Dmitry Vyukov
  2019-12-02 15:40   ` Jens Axboe
  2019-12-02 15:22 ` syzbot
  1 sibling, 1 reply; 4+ messages in thread
From: Dmitry Vyukov @ 2019-12-02  6:40 UTC (permalink / raw)
  To: syzbot, Jens Axboe, Al Viro, io-uring, linux-fsdevel
  Cc: Anna.Schumaker, Casey Schaufler, David Howells, Jann Horn,
	Kees Cook, Kate Stewart, LKML, NeilBrown, syzkaller-bugs,
	Thomas Gleixner

On Mon, Dec 2, 2019 at 7:35 AM syzbot
<syzbot+5320383e16029ba057ff@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit:    b94ae8ad Merge tag 'seccomp-v5.5-rc1' of git://git.kernel...
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=10f9ffcee00000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=ff560c3de405258c
> dashboard link: https://syzkaller.appspot.com/bug?extid=5320383e16029ba057ff
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12dd682ae00000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16290abce00000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+5320383e16029ba057ff@syzkaller.appspotmail.com

I think this relates to fs/io_uring.c rather than kernel/cred.c.
+io_uring maintainers

> kasan: CONFIG_KASAN_INLINE enabled
> kasan: GPF could be caused by NULL-ptr deref or user memory access
> general protection fault: 0000 [#1] PREEMPT SMP KASAN
> CPU: 0 PID: 9217 Comm: io_uring-sq Not tainted 5.4.0-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> RIP: 0010:creds_are_invalid kernel/cred.c:792 [inline]
> RIP: 0010:__validate_creds include/linux/cred.h:187 [inline]
> RIP: 0010:override_creds+0x9f/0x170 kernel/cred.c:550
> Code: ac 25 00 81 fb 64 65 73 43 0f 85 a3 37 00 00 e8 17 ab 25 00 49 8d 7c
> 24 10 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84
> c0 74 08 3c 03 0f 8e 96 00 00 00 41 8b 5c 24 10 bf
> RSP: 0018:ffff88809c45fda0 EFLAGS: 00010202
> RAX: dffffc0000000000 RBX: 0000000043736564 RCX: ffffffff814f3318
> RDX: 0000000000000002 RSI: ffffffff814f3329 RDI: 0000000000000010
> RBP: ffff88809c45fdb8 R08: ffff8880a3aac240 R09: ffffed1014755849
> R10: ffffed1014755848 R11: ffff8880a3aac247 R12: 0000000000000000
> R13: ffff888098ab1600 R14: 0000000000000000 R15: 0000000000000000
> FS:  0000000000000000(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007ffd51c40664 CR3: 0000000092641000 CR4: 00000000001406f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
>   io_sq_thread+0x1c7/0xa20 fs/io_uring.c:3274
>   kthread+0x361/0x430 kernel/kthread.c:255
>   ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
> Modules linked in:
> ---[ end trace f2e1a4307fbe2245 ]---
> RIP: 0010:creds_are_invalid kernel/cred.c:792 [inline]
> RIP: 0010:__validate_creds include/linux/cred.h:187 [inline]
> RIP: 0010:override_creds+0x9f/0x170 kernel/cred.c:550
> Code: ac 25 00 81 fb 64 65 73 43 0f 85 a3 37 00 00 e8 17 ab 25 00 49 8d 7c
> 24 10 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84
> c0 74 08 3c 03 0f 8e 96 00 00 00 41 8b 5c 24 10 bf
> RSP: 0018:ffff88809c45fda0 EFLAGS: 00010202
> RAX: dffffc0000000000 RBX: 0000000043736564 RCX: ffffffff814f3318
> RDX: 0000000000000002 RSI: ffffffff814f3329 RDI: 0000000000000010
> RBP: ffff88809c45fdb8 R08: ffff8880a3aac240 R09: ffffed1014755849
> R10: ffffed1014755848 R11: ffff8880a3aac247 R12: 0000000000000000
> R13: ffff888098ab1600 R14: 0000000000000000 R15: 0000000000000000
> FS:  0000000000000000(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007ffd51c40664 CR3: 0000000092641000 CR4: 00000000001406f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>
>
> ---
> 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
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/000000000000da160a0598b2c704%40google.com.

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

* Re: general protection fault in override_creds
       [not found] <000000000000da160a0598b2c704@google.com>
  2019-12-02  6:40 ` general protection fault in override_creds Dmitry Vyukov
@ 2019-12-02 15:22 ` syzbot
  1 sibling, 0 replies; 4+ messages in thread
From: syzbot @ 2019-12-02 15:22 UTC (permalink / raw)
  To: Anna.Schumaker, Anna.Schumaker, axboe, casey, dhowells, dvyukov,
	io-uring, jannh, keescook, kstewart, linux-block, linux-fsdevel,
	linux-kernel, neilb, syzkaller-bugs, tglx, viro

syzbot has bisected this bug to:

commit 181e448d8709e517c9c7b523fcd209f24eb38ca7
Author: Jens Axboe <axboe@kernel.dk>
Date:   Mon Nov 25 15:52:30 2019 +0000

     io_uring: async workers should inherit the user creds

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=10424ceae00000
start commit:   b94ae8ad Merge tag 'seccomp-v5.5-rc1' of git://git.kernel...
git tree:       upstream
final crash:    https://syzkaller.appspot.com/x/report.txt?x=12424ceae00000
console output: https://syzkaller.appspot.com/x/log.txt?x=14424ceae00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=ff560c3de405258c
dashboard link: https://syzkaller.appspot.com/bug?extid=5320383e16029ba057ff
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12dd682ae00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16290abce00000

Reported-by: syzbot+5320383e16029ba057ff@syzkaller.appspotmail.com
Fixes: 181e448d8709 ("io_uring: async workers should inherit the user  
creds")

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

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

* Re: general protection fault in override_creds
  2019-12-02  6:40 ` general protection fault in override_creds Dmitry Vyukov
@ 2019-12-02 15:40   ` Jens Axboe
  2019-12-02 15:49     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2019-12-02 15:40 UTC (permalink / raw)
  To: Dmitry Vyukov, syzbot, Al Viro, io-uring, linux-fsdevel
  Cc: Anna.Schumaker, Casey Schaufler, David Howells, Jann Horn,
	Kees Cook, Kate Stewart, LKML, NeilBrown, syzkaller-bugs,
	Thomas Gleixner

On 12/1/19 10:40 PM, Dmitry Vyukov wrote:
> On Mon, Dec 2, 2019 at 7:35 AM syzbot
> <syzbot+5320383e16029ba057ff@syzkaller.appspotmail.com> wrote:
>>
>> Hello,
>>
>> syzbot found the following crash on:
>>
>> HEAD commit:    b94ae8ad Merge tag 'seccomp-v5.5-rc1' of git://git.kernel...
>> git tree:       upstream
>> console output: https://syzkaller.appspot.com/x/log.txt?x=10f9ffcee00000
>> kernel config:  https://syzkaller.appspot.com/x/.config?x=ff560c3de405258c
>> dashboard link: https://syzkaller.appspot.com/bug?extid=5320383e16029ba057ff
>> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
>> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12dd682ae00000
>> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16290abce00000
>>
>> IMPORTANT: if you fix the bug, please add the following tag to the commit:
>> Reported-by: syzbot+5320383e16029ba057ff@syzkaller.appspotmail.com
> 
> I think this relates to fs/io_uring.c rather than kernel/cred.c.
> +io_uring maintainers

Yeah that's my fault, guessing the below will fix it. I'll test and
queue it up.


diff --git a/fs/io_uring.c b/fs/io_uring.c
index ec53aa7cdc94..afafe0463d2d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4361,7 +4361,8 @@ static void io_ring_ctx_free(struct io_ring_ctx *ctx)
  		io_unaccount_mem(ctx->user,
  				ring_pages(ctx->sq_entries, ctx->cq_entries));
  	free_uid(ctx->user);
-	put_cred(ctx->creds);
+	if (ctx->creds)
+		put_cred(ctx->creds);
  	kfree(ctx->completions);
  	kmem_cache_free(req_cachep, ctx->fallback_req);
  	kfree(ctx);
@@ -4759,7 +4760,12 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
  	ctx->compat = in_compat_syscall();
  	ctx->account_mem = account_mem;
  	ctx->user = user;
+
  	ctx->creds = prepare_creds();
+	if (!ctx->creds) {
+		ret = -ENOMEM;
+		goto err;
+	}
  
  	ret = io_allocate_scq_urings(ctx, p);
  	if (ret)

-- 
Jens Axboe


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

* Re: general protection fault in override_creds
  2019-12-02 15:40   ` Jens Axboe
@ 2019-12-02 15:49     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-12-02 15:49 UTC (permalink / raw)
  To: Dmitry Vyukov, syzbot, Al Viro, io-uring, linux-fsdevel
  Cc: Anna.Schumaker, Casey Schaufler, David Howells, Jann Horn,
	Kees Cook, Kate Stewart, LKML, NeilBrown, syzkaller-bugs,
	Thomas Gleixner

On 12/2/19 7:40 AM, Jens Axboe wrote:
> On 12/1/19 10:40 PM, Dmitry Vyukov wrote:
>> On Mon, Dec 2, 2019 at 7:35 AM syzbot
>> <syzbot+5320383e16029ba057ff@syzkaller.appspotmail.com> wrote:
>>>
>>> Hello,
>>>
>>> syzbot found the following crash on:
>>>
>>> HEAD commit:    b94ae8ad Merge tag 'seccomp-v5.5-rc1' of git://git.kernel...
>>> git tree:       upstream
>>> console output: https://syzkaller.appspot.com/x/log.txt?x=10f9ffcee00000
>>> kernel config:  https://syzkaller.appspot.com/x/.config?x=ff560c3de405258c
>>> dashboard link: https://syzkaller.appspot.com/bug?extid=5320383e16029ba057ff
>>> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
>>> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12dd682ae00000
>>> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16290abce00000
>>>
>>> IMPORTANT: if you fix the bug, please add the following tag to the commit:
>>> Reported-by: syzbot+5320383e16029ba057ff@syzkaller.appspotmail.com
>>
>> I think this relates to fs/io_uring.c rather than kernel/cred.c.
>> +io_uring maintainers
> 
> Yeah that's my fault, guessing the below will fix it. I'll test and
> queue it up.

This is cleaner, tested fine.


diff --git a/fs/io-wq.c b/fs/io-wq.c
index 91b85df0861e..74b40506c5d9 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -111,7 +111,7 @@ struct io_wq {
  
  	struct task_struct *manager;
  	struct user_struct *user;
-	struct cred *creds;
+	const struct cred *creds;
  	struct mm_struct *mm;
  	refcount_t refs;
  	struct completion done;
diff --git a/fs/io-wq.h b/fs/io-wq.h
index 600e0158cba7..dd0af0d7376c 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -87,7 +87,7 @@ typedef void (put_work_fn)(struct io_wq_work *);
  struct io_wq_data {
  	struct mm_struct *mm;
  	struct user_struct *user;
-	struct cred *creds;
+	const struct cred *creds;
  
  	get_work_fn *get_work;
  	put_work_fn *put_work;
diff --git a/fs/io_uring.c b/fs/io_uring.c
index ec53aa7cdc94..5cab7a047317 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -238,7 +238,7 @@ struct io_ring_ctx {
  
  	struct user_struct	*user;
  
-	struct cred		*creds;
+	const struct cred	*creds;
  
  	/* 0 is for ctx quiesce/reinit/free, 1 is for sqo_thread started */
  	struct completion	*completions;
@@ -4759,7 +4759,7 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
  	ctx->compat = in_compat_syscall();
  	ctx->account_mem = account_mem;
  	ctx->user = user;
-	ctx->creds = prepare_creds();
+	ctx->creds = get_current_cred();
  
  	ret = io_allocate_scq_urings(ctx, p);
  	if (ret)

-- 
Jens Axboe


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

end of thread, other threads:[~2019-12-02 15:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <000000000000da160a0598b2c704@google.com>
2019-12-02  6:40 ` general protection fault in override_creds Dmitry Vyukov
2019-12-02 15:40   ` Jens Axboe
2019-12-02 15:49     ` Jens Axboe
2019-12-02 15:22 ` 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).