stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, syzbot <syzkaller@googlegroups.com>,
	Christoph Paasch <christophpaasch@icloud.com>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH 6.1 26/42] net: Remove WARN_ON_ONCE(sk->sk_forward_alloc) from sk_stream_kill_queues().
Date: Wed,  1 Mar 2023 19:08:47 +0100	[thread overview]
Message-ID: <20230301180658.213536995@linuxfoundation.org> (raw)
In-Reply-To: <20230301180657.003689969@linuxfoundation.org>

From: Kuniyuki Iwashima <kuniyu@amazon.com>

commit 62ec33b44e0f7168ff2886520fec6fb62d03b5a3 upstream.

Christoph Paasch reported that commit b5fc29233d28 ("inet6: Remove
inet6_destroy_sock() in sk->sk_prot->destroy().") started triggering
WARN_ON_ONCE(sk->sk_forward_alloc) in sk_stream_kill_queues().  [0 - 2]
Also, we can reproduce it by a program in [3].

In the commit, we delay freeing ipv6_pinfo.pktoptions from sk->destroy()
to sk->sk_destruct(), so sk->sk_forward_alloc is no longer zero in
inet_csk_destroy_sock().

The same check has been in inet_sock_destruct() from at least v2.6,
we can just remove the WARN_ON_ONCE().  However, among the users of
sk_stream_kill_queues(), only CAIF is not calling inet_sock_destruct().
Thus, we add the same WARN_ON_ONCE() to caif_sock_destructor().

[0]: https://lore.kernel.org/netdev/39725AB4-88F1-41B3-B07F-949C5CAEFF4F@icloud.com/
[1]: https://github.com/multipath-tcp/mptcp_net-next/issues/341
[2]:
WARNING: CPU: 0 PID: 3232 at net/core/stream.c:212 sk_stream_kill_queues+0x2f9/0x3e0
Modules linked in:
CPU: 0 PID: 3232 Comm: syz-executor.0 Not tainted 6.2.0-rc5ab24eb4698afbe147b424149c529e2a43ec24eb5 #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
RIP: 0010:sk_stream_kill_queues+0x2f9/0x3e0
Code: 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e ec 00 00 00 8b ab 08 01 00 00 e9 60 ff ff ff e8 d0 5f b6 fe 0f 0b eb 97 e8 c7 5f b6 fe <0f> 0b eb a0 e8 be 5f b6 fe 0f 0b e9 6a fe ff ff e8 02 07 e3 fe e9
RSP: 0018:ffff88810570fc68 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff888101f38f40 RSI: ffffffff8285e529 RDI: 0000000000000005
RBP: 0000000000000ce0 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000ce0 R11: 0000000000000001 R12: ffff8881009e9488
R13: ffffffff84af2cc0 R14: 0000000000000000 R15: ffff8881009e9458
FS:  00007f7fdfbd5800(0000) GS:ffff88811b600000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b32923000 CR3: 00000001062fc006 CR4: 0000000000170ef0
Call Trace:
 <TASK>
 inet_csk_destroy_sock+0x1a1/0x320
 __tcp_close+0xab6/0xe90
 tcp_close+0x30/0xc0
 inet_release+0xe9/0x1f0
 inet6_release+0x4c/0x70
 __sock_release+0xd2/0x280
 sock_close+0x15/0x20
 __fput+0x252/0xa20
 task_work_run+0x169/0x250
 exit_to_user_mode_prepare+0x113/0x120
 syscall_exit_to_user_mode+0x1d/0x40
 do_syscall_64+0x48/0x90
 entry_SYSCALL_64_after_hwframe+0x72/0xdc
RIP: 0033:0x7f7fdf7ae28d
Code: c1 20 00 00 75 10 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 ee fb ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 37 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
RSP: 002b:00000000007dfbb0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000004 RCX: 00007f7fdf7ae28d
RDX: 0000000000000000 RSI: ffffffffffffffff RDI: 0000000000000003
RBP: 0000000000000000 R08: 000000007f338e0f R09: 0000000000000e0f
R10: 000000007f338e13 R11: 0000000000000293 R12: 00007f7fdefff000
R13: 00007f7fdefffcd8 R14: 00007f7fdefffce0 R15: 00007f7fdefffcd8
 </TASK>

[3]: https://lore.kernel.org/netdev/20230208004245.83497-1-kuniyu@amazon.com/

Fixes: b5fc29233d28 ("inet6: Remove inet6_destroy_sock() in sk->sk_prot->destroy().")
Reported-by: syzbot <syzkaller@googlegroups.com>
Reported-by: Christoph Paasch <christophpaasch@icloud.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/caif/caif_socket.c |    1 +
 net/core/stream.c      |    1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -1015,6 +1015,7 @@ static void caif_sock_destructor(struct
 		return;
 	}
 	sk_stream_kill_queues(&cf_sk->sk);
+	WARN_ON_ONCE(sk->sk_forward_alloc);
 	caif_free_client(&cf_sk->layer);
 }
 
--- a/net/core/stream.c
+++ b/net/core/stream.c
@@ -209,7 +209,6 @@ void sk_stream_kill_queues(struct sock *
 	sk_mem_reclaim_final(sk);
 
 	WARN_ON_ONCE(sk->sk_wmem_queued);
-	WARN_ON_ONCE(sk->sk_forward_alloc);
 
 	/* It is _impossible_ for the backlog to contain anything
 	 * when we get here.  All user references to this socket



  parent reply	other threads:[~2023-03-01 18:12 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01 18:08 [PATCH 6.1 00/42] 6.1.15-rc1 review Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 01/42] Fix XFRM-I support for nested ESP tunnels Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 02/42] arm64: dts: rockchip: reduce thermal limits on rk3399-pinephone-pro Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 03/42] arm64: dts: rockchip: drop unused LED mode property from rk3328-roc-cc Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 04/42] ARM: dts: rockchip: add power-domains property to dp node on rk3288 Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 05/42] arm64: dts: rockchip: add missing #interrupt-cells to rk356x pcie2x1 Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 06/42] arm64: dts: rockchip: fix probe of analog sound card on rock-3a Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 07/42] HID: elecom: add support for TrackBall 056E:011C Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 08/42] HID: Ignore battery for Elan touchscreen on Asus TP420IA Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 09/42] ACPI: NFIT: fix a potential deadlock during NFIT teardown Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 10/42] pinctrl: amd: Fix debug output for debounce time Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 11/42] btrfs: send: limit number of clones and allocated memory size Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 12/42] arm64: dts: rockchip: align rk3399 DMC OPP table with bindings Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 13/42] ASoC: rt715-sdca: fix clock stop prepare timeout issue Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 14/42] IB/hfi1: Assign npages earlier Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 15/42] powerpc: Dont select ARCH_WANTS_NO_INSTR Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 16/42] ASoC: SOF: amd: Fix for handling spurious interrupts from DSP Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 17/42] ARM: dts: stihxxx-b2120: fix polarity of reset line of tsin0 port Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 18/42] neigh: make sure used and confirmed times are valid Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 19/42] HID: core: Fix deadloop in hid_apply_multiplier Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 20/42] ASoC: codecs: es8326: Fix DTS properties reading Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 21/42] HID: Ignore battery for ELAN touchscreen 29DF on HP Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 22/42] selftests: ocelot: tc_flower_chains: make test_vlan_ingress_modify() more comprehensive Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 23/42] x86/cpu: Add Lunar Lake M Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 24/42] PM: sleep: Avoid using pr_cont() in the tasks freezing code Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 25/42] bpf: bpf_fib_lookup should not return neigh in NUD_FAILED state Greg Kroah-Hartman
2023-03-01 18:08 ` Greg Kroah-Hartman [this message]
2023-03-01 18:08 ` [PATCH 6.1 27/42] vc_screen: dont clobber return value in vcs_read Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 28/42] drm/amd/display: Move DCN314 DOMAIN power control to DMCUB Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 29/42] drm/amd/display: Fix race condition in DPIA AUX transfer Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 30/42] usb: dwc3: pci: add support for the Intel Meteor Lake-M Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 31/42] USB: serial: option: add support for VW/Skoda "Carstick LTE" Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 32/42] usb: gadget: u_serial: Add null pointer check in gserial_resume Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 33/42] arm64: dts: uniphier: Fix property name in PXs3 USB node Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 34/42] usb: typec: pd: Remove usb_suspend_supported sysfs from sink PDO Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 35/42] drm/amd/display: Properly reuse completion structure Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 36/42] attr: add in_group_or_capable() Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 37/42] fs: move should_remove_suid() Greg Kroah-Hartman
2023-03-01 18:08 ` [PATCH 6.1 38/42] attr: add setattr_should_drop_sgid() Greg Kroah-Hartman
2023-03-01 18:09 ` [PATCH 6.1 39/42] attr: use consistent sgid stripping checks Greg Kroah-Hartman
2023-03-01 18:09 ` [PATCH 6.1 40/42] fs: use consistent setgid checks in is_sxid() Greg Kroah-Hartman
2023-03-01 18:09 ` [PATCH 6.1 41/42] scripts/tags.sh: fix incompatibility with PCRE2 Greg Kroah-Hartman
2023-03-01 18:09 ` [PATCH 6.1 42/42] USB: core: Dont hold device lock while reading the "descriptors" sysfs file Greg Kroah-Hartman
2023-03-01 20:33 ` [PATCH 6.1 00/42] 6.1.15-rc1 review Conor Dooley
2023-03-01 22:16 ` Florian Fainelli
2023-03-01 23:43 ` Justin Forbes
2023-03-02  1:44 ` Shuah Khan
2023-03-02  4:27 ` Bagas Sanjaya
2023-03-02 10:19 ` Naresh Kamboju
2023-03-02 10:29   ` Greg Kroah-Hartman
2023-03-02 11:00     ` Naresh Kamboju
2023-03-02 20:02       ` Naresh Kamboju
2023-03-03  7:01         ` Greg Kroah-Hartman
2023-03-03  9:00           ` Naresh Kamboju
2023-03-03  8:04         ` Paolo Abeni
2023-03-03  9:04           ` Naresh Kamboju
2023-03-03  9:23             ` Greg Kroah-Hartman
2023-03-03  9:47               ` Matthieu Baerts
2023-03-03 10:26                 ` Greg Kroah-Hartman
2023-03-03 10:56                   ` Matthieu Baerts
2023-03-03 11:31                     ` Greg Kroah-Hartman
2023-03-03 11:39               ` Paolo Abeni
2023-03-03 11:44                 ` Greg Kroah-Hartman
2023-03-03 12:41                   ` Paolo Abeni
2023-03-03 13:35                     ` Greg Kroah-Hartman
2023-03-02 11:37 ` Sudip Mukherjee (Codethink)
2023-03-02 23:16 ` Slade Watkins
2023-03-02 23:25 ` Rudi Heitbaum
2023-03-03  1:31 ` Guenter Roeck
2023-03-03  2:55 ` Ron Economos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230301180658.213536995@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=christophpaasch@icloud.com \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=syzkaller@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).