All of lore.kernel.org
 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>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Eric Dumazet <edumazet@google.com>,
	Michal Kubiak <michal.kubiak@intel.com>,
	Jakub Kicinski <kuba@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.14 05/86] af_unix: Fix a data race of sk->sk_receive_queue->qlen.
Date: Sun, 28 May 2023 20:09:39 +0100	[thread overview]
Message-ID: <20230528190828.755150621@linuxfoundation.org> (raw)
In-Reply-To: <20230528190828.564682883@linuxfoundation.org>

From: Kuniyuki Iwashima <kuniyu@amazon.com>

[ Upstream commit 679ed006d416ea0cecfe24a99d365d1dea69c683 ]

KCSAN found a data race of sk->sk_receive_queue->qlen where recvmsg()
updates qlen under the queue lock and sendmsg() checks qlen under
unix_state_sock(), not the queue lock, so the reader side needs
READ_ONCE().

BUG: KCSAN: data-race in __skb_try_recv_from_queue / unix_wait_for_peer

write (marked) to 0xffff888019fe7c68 of 4 bytes by task 49792 on cpu 0:
 __skb_unlink include/linux/skbuff.h:2347 [inline]
 __skb_try_recv_from_queue+0x3de/0x470 net/core/datagram.c:197
 __skb_try_recv_datagram+0xf7/0x390 net/core/datagram.c:263
 __unix_dgram_recvmsg+0x109/0x8a0 net/unix/af_unix.c:2452
 unix_dgram_recvmsg+0x94/0xa0 net/unix/af_unix.c:2549
 sock_recvmsg_nosec net/socket.c:1019 [inline]
 ____sys_recvmsg+0x3a3/0x3b0 net/socket.c:2720
 ___sys_recvmsg+0xc8/0x150 net/socket.c:2764
 do_recvmmsg+0x182/0x560 net/socket.c:2858
 __sys_recvmmsg net/socket.c:2937 [inline]
 __do_sys_recvmmsg net/socket.c:2960 [inline]
 __se_sys_recvmmsg net/socket.c:2953 [inline]
 __x64_sys_recvmmsg+0x153/0x170 net/socket.c:2953
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x72/0xdc

read to 0xffff888019fe7c68 of 4 bytes by task 49793 on cpu 1:
 skb_queue_len include/linux/skbuff.h:2127 [inline]
 unix_recvq_full net/unix/af_unix.c:229 [inline]
 unix_wait_for_peer+0x154/0x1a0 net/unix/af_unix.c:1445
 unix_dgram_sendmsg+0x13bc/0x14b0 net/unix/af_unix.c:2048
 sock_sendmsg_nosec net/socket.c:724 [inline]
 sock_sendmsg+0x148/0x160 net/socket.c:747
 ____sys_sendmsg+0x20e/0x620 net/socket.c:2503
 ___sys_sendmsg+0xc6/0x140 net/socket.c:2557
 __sys_sendmmsg+0x11d/0x370 net/socket.c:2643
 __do_sys_sendmmsg net/socket.c:2672 [inline]
 __se_sys_sendmmsg net/socket.c:2669 [inline]
 __x64_sys_sendmmsg+0x58/0x70 net/socket.c:2669
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x72/0xdc

value changed: 0x0000000b -> 0x00000001

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 49793 Comm: syz-executor.0 Not tainted 6.3.0-rc7-02330-gca6270c12e20 #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/unix/af_unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 0e494902fadaa..375d4e20efd6b 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1236,7 +1236,7 @@ static long unix_wait_for_peer(struct sock *other, long timeo)
 
 	sched = !sock_flag(other, SOCK_DEAD) &&
 		!(other->sk_shutdown & RCV_SHUTDOWN) &&
-		unix_recvq_full(other);
+		unix_recvq_full_lockless(other);
 
 	unix_state_unlock(other);
 
-- 
2.39.2




  parent reply	other threads:[~2023-05-28 19:13 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-28 19:09 [PATCH 4.14 00/86] 4.14.316-rc1 review Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 01/86] net: Fix load-tearing on sk->sk_stamp in sock_recv_cmsgs() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 02/86] netlink: annotate accesses to nlk->cb_running Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 03/86] net: annotate sk->sk_err write from do_recvmmsg() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 04/86] ipvlan:Fix out-of-bounds caused by unclear skb->cb Greg Kroah-Hartman
2023-05-28 19:09 ` Greg Kroah-Hartman [this message]
2023-05-28 19:09 ` [PATCH 4.14 06/86] fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 07/86] regmap: cache: Return error in cache sync operations for REGCACHE_NONE Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 08/86] memstick: r592: Fix UAF bug in r592_remove due to race condition Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 09/86] ACPI: EC: Fix oops when removing custom query handlers Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 10/86] drm/tegra: Avoid potential 32-bit integer overflow Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 11/86] ACPICA: Avoid undefined behavior: applying zero offset to null pointer Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 12/86] ACPICA: ACPICA: check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 13/86] wifi: brcmfmac: cfg80211: Pass the PMK in binary instead of hex Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 14/86] ext2: Check block size validity during mount Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 15/86] net: pasemi: Fix return type of pasemi_mac_start_tx() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 16/86] net: Catch invalid index in XPS mapping Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 17/86] lib: cpu_rmap: Avoid use after free on rmap->obj array entries Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 18/86] scsi: message: mptlan: Fix use after free bug in mptlan_remove() due to race condition Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 19/86] gfs2: Fix inode height consistency check Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 20/86] ext4: set goal start correctly in ext4_mb_normalize_request Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 21/86] ext4: Fix best extent lstart adjustment logic in ext4_mb_new_inode_pa() Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 22/86] null_blk: Always check queue mode setting from configfs Greg Kroah-Hartman
2023-05-29 16:46   ` Harshit Mogalapalli
2023-05-29 19:00     ` Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 23/86] wifi: iwlwifi: dvm: Fix memcpy: detected field-spanning write backtrace Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 24/86] Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp Greg Kroah-Hartman
2023-05-28 19:09 ` [PATCH 4.14 25/86] staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 26/86] HID: logitech-hidpp: Dont use the USB serial for USB devices Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 27/86] HID: logitech-hidpp: Reconcile USB and Unifying serials Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 28/86] spi: spi-imx: fix MX51_ECSPI_* macros when cs > 3 Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 29/86] HID: wacom: generic: Set battery quirk only when we see battery data Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 30/86] serial: 8250: Reinit port->pm on port specific driver unbind Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 31/86] mcb-pci: Reallocate memory region to avoid memory overlapping Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 32/86] sched: Fix KCSAN noinstr violation Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 33/86] recordmcount: Fix memory leaks in the uwrite function Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 34/86] clk: tegra20: fix gcc-7 constant overflow warning Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 35/86] Input: xpad - add constants for GIP interface numbers Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 36/86] phy: st: miphy28lp: use _poll_timeout functions for waits Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 37/86] mfd: dln2: Fix memory leak in dln2_probe() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 38/86] cpupower: Make TSC read per CPU for Mperf monitor Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 39/86] af_key: Reject optional tunnel/BEET mode templates in outbound policies Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 40/86] net: fec: Better handle pm_runtime_get() failing in .remove() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 41/86] vsock: avoid to close connected socket after the timeout Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 42/86] media: netup_unidvb: fix use-after-free at del_timer() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 43/86] net: nsh: Use correct mac_offset to unwind gso skb in nsh_gso_segment() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 44/86] cassini: Fix a memory leak in the error handling path of cas_init_one() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 45/86] igb: fix bit_shift to be in [1..8] range Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 46/86] vlan: fix a potential uninit-value in vlan_dev_hard_start_xmit() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 47/86] usb-storage: fix deadlock when a scsi command timeouts more than once Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 48/86] ALSA: hda: Fix Oops by 9.1 surround channel names Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 49/86] ALSA: hda: Add NVIDIA codec IDs a3 through a7 to patch table Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 50/86] statfs: enforce statfs[64] structure initialization Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 51/86] serial: Add support for Advantech PCI-1611U card Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 52/86] ceph: force updating the msg pointer in non-split case Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 53/86] nilfs2: fix use-after-free bug of nilfs_root in nilfs_evict_inode() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 54/86] netfilter: nf_tables: bogus EBUSY in helper removal from transaction Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 55/86] spi: spi-fsl-spi: automatically adapt bits-per-word in cpu mode Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 56/86] spi: fsl-spi: Re-organise transfer bits_per_word adaptation Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 57/86] spi: fsl-cpm: Use 16 bit mode for large transfers with even size Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 58/86] m68k: Move signal frame following exception on 68020/030 Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 59/86] parisc: Allow to reboot machine after system halt Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 60/86] netfilter: nftables: add nft_parse_register_load() and use it Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 61/86] netfilter: nftables: add nft_parse_register_store() " Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 62/86] netfilter: nftables: statify nft_parse_register() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 63/86] netfilter: nf_tables: validate registers coming from userspace Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 64/86] netfilter: nf_tables: add nft_setelem_parse_key() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 65/86] netfilter: nf_tables: allow up to 64 bytes in the set element data area Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 66/86] netfilter: nf_tables: stricter validation of element data Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 67/86] netfilter: nft_dynset: do not reject set updates with NFT_SET_EVAL Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 68/86] netfilter: nf_tables: do not allow RULE_ID to refer to another chain Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 69/86] netfilter: nf_tables: do not allow SET_ID to refer to another table Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 70/86] netfilter: nf_tables: fix register ordering Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 71/86] x86/mm: Avoid incomplete Global INVLPG flushes Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 72/86] selftests/memfd: Fix unknown type name build failure Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 73/86] USB: core: Add routines for endpoint checks in old drivers Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 74/86] USB: sisusbvga: Add endpoint checks Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 75/86] media: radio-shark: " Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 76/86] net: fix skb leak in __skb_tstamp_tx() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 77/86] ipv6: Fix out-of-bounds access in ipv6_find_tlv() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 78/86] power: supply: leds: Fix blink to LED on transition Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 79/86] power: supply: bq27xxx: Fix bq27xxx_battery_update() race condition Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 80/86] power: supply: bq27xxx: Fix I2C IRQ race on remove Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 81/86] power: supply: bq27xxx: Fix poll_interval handling and races " Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 82/86] power: supply: sbs-charger: Fix INHIBITED bit for Status reg Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 83/86] xen/pvcalls-back: fix double frees with pvcalls_new_active_socket() Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 84/86] x86/show_trace_log_lvl: Ensure stack pointer is aligned, again Greg Kroah-Hartman
2023-05-28 19:10 ` [PATCH 4.14 85/86] forcedeth: Fix an error handling path in nv_probe() Greg Kroah-Hartman
2023-05-28 19:11 ` [PATCH 4.14 86/86] 3c589_cs: Fix an error handling path in tc589_probe() Greg Kroah-Hartman
2023-05-29 16:04 ` [PATCH 4.14 00/86] 4.14.316-rc1 review Guenter Roeck
2023-05-29 17:55 ` Naresh Kamboju
2023-05-30  5:17 ` Harshit Mogalapalli
2023-05-30  9:19 ` Jon Hunter
2023-05-30 10:26 ` Pavel Machek
2023-05-30 11:53 ` Chris Paterson

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=20230528190828.755150621@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=michal.kubiak@intel.com \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --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 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.