All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [ext4?] general protection fault in ext4_finish_bio
@ 2023-07-04  1:00 syzbot
  2023-07-07  5:10 ` syzbot
  0 siblings, 1 reply; 6+ messages in thread
From: syzbot @ 2023-07-04  1:00 UTC (permalink / raw)
  To: adilger.kernel, linux-ext4, linux-fsdevel, linux-kernel, netdev,
	syzkaller-bugs, tytso

Hello,

syzbot found the following issue on:

HEAD commit:    ae230642190a Merge branch 'af_unix-followup-fixes-for-so_p..
git tree:       net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=11fe4cb8a80000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c9bf1936936ca698
dashboard link: https://syzkaller.appspot.com/bug?extid=689ec3afb1ef07b766b2
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=136b9d48a80000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10223cb8a80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8c060db03f09/disk-ae230642.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1b9b937ece91/vmlinux-ae230642.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0c7eb1c82bf0/bzImage-ae230642.xz

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

general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
CPU: 1 PID: 2858 Comm: kworker/u4:5 Not tainted 6.4.0-rc7-syzkaller-01948-gae230642190a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
Workqueue: ext4-rsv-conversion ext4_end_io_rsv_work
RIP: 0010:_compound_head include/linux/page-flags.h:245 [inline]
RIP: 0010:bio_first_folio include/linux/bio.h:284 [inline]
RIP: 0010:ext4_finish_bio+0xdc/0x1090 fs/ext4/page-io.c:104
Code: c1 ea 03 80 3c 02 00 0f 85 43 0f 00 00 48 8b 45 00 48 8d 78 08 48 89 04 24 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 4c 0f 00 00 48 8b 04 24 31 ff 4c 8b 60 08 4c 89
RSP: 0018:ffffc9000d047b60 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000001 RSI: ffffffff8234c972 RDI: 0000000000000008
RBP: ffff88807d609100 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000094001 R12: ffff888074f111e0
R13: dffffc0000000000 R14: 0000000000000001 R15: ffff888074c416b0
FS:  0000000000000000(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020241040 CR3: 0000000024e17000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 ext4_release_io_end+0x118/0x3b0 fs/ext4/page-io.c:160
 ext4_end_io_end fs/ext4/page-io.c:194 [inline]
 ext4_do_flush_completed_IO fs/ext4/page-io.c:259 [inline]
 ext4_end_io_rsv_work+0x156/0x670 fs/ext4/page-io.c:273
 process_one_work+0x99a/0x15e0 kernel/workqueue.c:2405
 worker_thread+0x67d/0x10c0 kernel/workqueue.c:2552
 kthread+0x344/0x440 kernel/kthread.c:379
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:_compound_head include/linux/page-flags.h:245 [inline]
RIP: 0010:bio_first_folio include/linux/bio.h:284 [inline]
RIP: 0010:ext4_finish_bio+0xdc/0x1090 fs/ext4/page-io.c:104
Code: c1 ea 03 80 3c 02 00 0f 85 43 0f 00 00 48 8b 45 00 48 8d 78 08 48 89 04 24 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 4c 0f 00 00 48 8b 04 24 31 ff 4c 8b 60 08 4c 89
RSP: 0018:ffffc9000d047b60 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000001 RSI: ffffffff8234c972 RDI: 0000000000000008
RBP: ffff88807d609100 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000094001 R12: ffff888074f111e0
R13: dffffc0000000000 R14: 0000000000000001 R15: ffff888074c416b0
FS:  0000000000000000(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020241040 CR3: 000000007a4d9000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	c1 ea 03             	shr    $0x3,%edx
   3:	80 3c 02 00          	cmpb   $0x0,(%rdx,%rax,1)
   7:	0f 85 43 0f 00 00    	jne    0xf50
   d:	48 8b 45 00          	mov    0x0(%rbp),%rax
  11:	48 8d 78 08          	lea    0x8(%rax),%rdi
  15:	48 89 04 24          	mov    %rax,(%rsp)
  19:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  20:	fc ff df
  23:	48 89 fa             	mov    %rdi,%rdx
  26:	48 c1 ea 03          	shr    $0x3,%rdx
* 2a:	80 3c 02 00          	cmpb   $0x0,(%rdx,%rax,1) <-- trapping instruction
  2e:	0f 85 4c 0f 00 00    	jne    0xf80
  34:	48 8b 04 24          	mov    (%rsp),%rax
  38:	31 ff                	xor    %edi,%edi
  3a:	4c 8b 60 08          	mov    0x8(%rax),%r12
  3e:	4c                   	rex.WR
  3f:	89                   	.byte 0x89


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

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

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

* Re: [syzbot] [ext4?] general protection fault in ext4_finish_bio
  2023-07-04  1:00 [syzbot] [ext4?] general protection fault in ext4_finish_bio syzbot
@ 2023-07-07  5:10 ` syzbot
  2023-07-07  8:06   ` David Howells
  2023-07-07  8:13   ` David Howells
  0 siblings, 2 replies; 6+ messages in thread
From: syzbot @ 2023-07-07  5:10 UTC (permalink / raw)
  To: adilger.kernel, boqun.feng, dhowells, herbert, kuba, linux-ext4,
	linux-fsdevel, linux-kernel, longman, mingo, netdev, peterz,
	syzkaller-bugs, tytso, will

syzbot has bisected this issue to:

commit b6d972f6898308fbe7e693bf8d44ebfdb1cd2dc4
Author: David Howells <dhowells@redhat.com>
Date:   Fri Jun 16 11:10:32 2023 +0000

    crypto: af_alg/hash: Fix recvmsg() after sendmsg(MSG_MORE)

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=17e4fa88a80000
start commit:   ae230642190a Merge branch 'af_unix-followup-fixes-for-so_p..
git tree:       net-next
final oops:     https://syzkaller.appspot.com/x/report.txt?x=1414fa88a80000
console output: https://syzkaller.appspot.com/x/log.txt?x=1014fa88a80000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c9bf1936936ca698
dashboard link: https://syzkaller.appspot.com/bug?extid=689ec3afb1ef07b766b2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=136b9d48a80000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10223cb8a80000

Reported-by: syzbot+689ec3afb1ef07b766b2@syzkaller.appspotmail.com
Fixes: b6d972f68983 ("crypto: af_alg/hash: Fix recvmsg() after sendmsg(MSG_MORE)")

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

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

* Re: [syzbot] [ext4?] general protection fault in ext4_finish_bio
  2023-07-07  5:10 ` syzbot
@ 2023-07-07  8:06   ` David Howells
  2023-07-07  8:20     ` syzbot
  2023-07-07  8:13   ` David Howells
  1 sibling, 1 reply; 6+ messages in thread
From: David Howells @ 2023-07-07  8:06 UTC (permalink / raw)
  To: syzbot
  Cc: dhowells, adilger.kernel, boqun.feng, herbert, kuba, linux-ext4,
	linux-fsdevel, linux-kernel, longman, mingo, netdev, peterz,
	syzkaller-bugs, tytso, will

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git main

    crypto: algif/hash: Fix race between MORE and non-MORE sends
    
    The 'MSG_MORE' state of the previous sendmsg() is fetched without the
    socket lock held, so two sendmsg calls can race.  This can be seen with a
    large sendfile() as that now does a series of sendmsg() calls, and if a
    write() comes in on the same socket at an inopportune time, it can flip the
    state.
    
    Fix this by moving the fetch of ctx->more inside the socket lock.
    
    Fixes: c662b043cdca ("crypto: af_alg/hash: Support MSG_SPLICE_PAGES")
    Reported-by: syzbot+689ec3afb1ef07b766b2@syzkaller.appspotmail.com
    Link: https://lore.kernel.org/r/000000000000554b8205ffdea64e@google.com/
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Herbert Xu <herbert@gondor.apana.org.au>
    cc: Paolo Abeni <pabeni@redhat.com>
    cc: "David S. Miller" <davem@davemloft.net>
    cc: Eric Dumazet <edumazet@google.com>
    cc: Jakub Kicinski <kuba@kernel.org>
    cc: linux-crypto@vger.kernel.org
    cc: netdev@vger.kernel.org

diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 0ab43e149f0e..82c44d4899b9 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -68,13 +68,15 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
 	struct hash_ctx *ctx = ask->private;
 	ssize_t copied = 0;
 	size_t len, max_pages, npages;
-	bool continuing = ctx->more, need_init = false;
+	bool continuing, need_init = false;
 	int err;
 
 	max_pages = min_t(size_t, ALG_MAX_PAGES,
 			  DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE));
 
 	lock_sock(sk);
+	continuing = ctx->more;
+
 	if (!continuing) {
 		/* Discard a previous request that wasn't marked MSG_MORE. */
 		hash_free_result(sk, ctx);


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

* Re: [syzbot] [ext4?] general protection fault in ext4_finish_bio
  2023-07-07  5:10 ` syzbot
  2023-07-07  8:06   ` David Howells
@ 2023-07-07  8:13   ` David Howells
  2023-07-07  8:55     ` syzbot
  1 sibling, 1 reply; 6+ messages in thread
From: David Howells @ 2023-07-07  8:13 UTC (permalink / raw)
  To: syzbot
  Cc: dhowells, adilger.kernel, boqun.feng, herbert, kuba, linux-ext4,
	linux-fsdevel, linux-kernel, longman, mingo, netdev, peterz,
	syzkaller-bugs, tytso, will

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

    crypto: algif/hash: Fix race between MORE and non-MORE sends
    
    The 'MSG_MORE' state of the previous sendmsg() is fetched without the
    socket lock held, so two sendmsg calls can race.  This can be seen with a
    large sendfile() as that now does a series of sendmsg() calls, and if a
    write() comes in on the same socket at an inopportune time, it can flip the
    state.
    
    Fix this by moving the fetch of ctx->more inside the socket lock.
    
    Fixes: c662b043cdca ("crypto: af_alg/hash: Support MSG_SPLICE_PAGES")
    Reported-by: syzbot+689ec3afb1ef07b766b2@syzkaller.appspotmail.com
    Link: https://lore.kernel.org/r/000000000000554b8205ffdea64e@google.com/
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Herbert Xu <herbert@gondor.apana.org.au>
    cc: Paolo Abeni <pabeni@redhat.com>
    cc: "David S. Miller" <davem@davemloft.net>
    cc: Eric Dumazet <edumazet@google.com>
    cc: Jakub Kicinski <kuba@kernel.org>
    cc: linux-crypto@vger.kernel.org
    cc: netdev@vger.kernel.org

diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 0ab43e149f0e..82c44d4899b9 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -68,13 +68,15 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
 	struct hash_ctx *ctx = ask->private;
 	ssize_t copied = 0;
 	size_t len, max_pages, npages;
-	bool continuing = ctx->more, need_init = false;
+	bool continuing, need_init = false;
 	int err;
 
 	max_pages = min_t(size_t, ALG_MAX_PAGES,
 			  DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE));
 
 	lock_sock(sk);
+	continuing = ctx->more;
+
 	if (!continuing) {
 		/* Discard a previous request that wasn't marked MSG_MORE. */
 		hash_free_result(sk, ctx);


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

* Re: [syzbot] [ext4?] general protection fault in ext4_finish_bio
  2023-07-07  8:06   ` David Howells
@ 2023-07-07  8:20     ` syzbot
  0 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2023-07-07  8:20 UTC (permalink / raw)
  To: adilger.kernel, boqun.feng, dhowells, herbert, kuba, linux-ext4,
	linux-fsdevel, linux-kernel, longman, mingo, netdev, peterz,
	syzkaller-bugs, tytso, will

Hello,

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

failed to checkout kernel repo git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/main: failed to run ["git" "fetch" "--force" "f569e972c8e9057ee9c286220c83a480ebf30cc5" "main"]: exit status 128
fatal: couldn't find remote ref main



Tested on:

commit:         [unknown 
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git main
dashboard link: https://syzkaller.appspot.com/bug?extid=689ec3afb1ef07b766b2
compiler:       
patch:          https://syzkaller.appspot.com/x/patch.diff?x=136ff1b4a80000


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

* Re: [syzbot] [ext4?] general protection fault in ext4_finish_bio
  2023-07-07  8:13   ` David Howells
@ 2023-07-07  8:55     ` syzbot
  0 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2023-07-07  8:55 UTC (permalink / raw)
  To: adilger.kernel, boqun.feng, dhowells, herbert, kuba, linux-ext4,
	linux-fsdevel, linux-kernel, longman, mingo, netdev, peterz,
	syzkaller-bugs, tytso, will

Hello,

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

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

Tested on:

commit:         5133c9e5 Merge tag 'drm-next-2023-07-07' of git://anon..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=124f34d8a80000
kernel config:  https://syzkaller.appspot.com/x/.config?x=8f6b0c7ae2c9c303
dashboard link: https://syzkaller.appspot.com/bug?extid=689ec3afb1ef07b766b2
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1624cf4f280000

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

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

end of thread, other threads:[~2023-07-07  8:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04  1:00 [syzbot] [ext4?] general protection fault in ext4_finish_bio syzbot
2023-07-07  5:10 ` syzbot
2023-07-07  8:06   ` David Howells
2023-07-07  8:20     ` syzbot
2023-07-07  8:13   ` David Howells
2023-07-07  8:55     ` syzbot

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.