linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Archie Pusaka <apusaka@chromium.org>,
	syzbot+abfc0f5e668d4099af73@syzkaller.appspotmail.com,
	Alain Michaud <alainm@chromium.org>,
	Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	Marcel Holtmann <marcel@holtmann.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.11 028/104] Bluetooth: check for zapped sk before connecting
Date: Wed,  5 May 2021 12:32:57 -0400	[thread overview]
Message-ID: <20210505163413.3461611-28-sashal@kernel.org> (raw)
In-Reply-To: <20210505163413.3461611-1-sashal@kernel.org>

From: Archie Pusaka <apusaka@chromium.org>

[ Upstream commit 3af70b39fa2d415dc86c370e5b24ddb9fdacbd6f ]

There is a possibility of receiving a zapped sock on
l2cap_sock_connect(). This could lead to interesting crashes, one
such case is tearing down an already tore l2cap_sock as is happened
with this call trace:

__dump_stack lib/dump_stack.c:15 [inline]
dump_stack+0xc4/0x118 lib/dump_stack.c:56
register_lock_class kernel/locking/lockdep.c:792 [inline]
register_lock_class+0x239/0x6f6 kernel/locking/lockdep.c:742
__lock_acquire+0x209/0x1e27 kernel/locking/lockdep.c:3105
lock_acquire+0x29c/0x2fb kernel/locking/lockdep.c:3599
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:137 [inline]
_raw_spin_lock_bh+0x38/0x47 kernel/locking/spinlock.c:175
spin_lock_bh include/linux/spinlock.h:307 [inline]
lock_sock_nested+0x44/0xfa net/core/sock.c:2518
l2cap_sock_teardown_cb+0x88/0x2fb net/bluetooth/l2cap_sock.c:1345
l2cap_chan_del+0xa3/0x383 net/bluetooth/l2cap_core.c:598
l2cap_chan_close+0x537/0x5dd net/bluetooth/l2cap_core.c:756
l2cap_chan_timeout+0x104/0x17e net/bluetooth/l2cap_core.c:429
process_one_work+0x7e3/0xcb0 kernel/workqueue.c:2064
worker_thread+0x5a5/0x773 kernel/workqueue.c:2196
kthread+0x291/0x2a6 kernel/kthread.c:211
ret_from_fork+0x4e/0x80 arch/x86/entry/entry_64.S:604

Signed-off-by: Archie Pusaka <apusaka@chromium.org>
Reported-by: syzbot+abfc0f5e668d4099af73@syzkaller.appspotmail.com
Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/l2cap_sock.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index f1b1edd0b697..c99d65ef13b1 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -179,9 +179,17 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
 	struct l2cap_chan *chan = l2cap_pi(sk)->chan;
 	struct sockaddr_l2 la;
 	int len, err = 0;
+	bool zapped;
 
 	BT_DBG("sk %p", sk);
 
+	lock_sock(sk);
+	zapped = sock_flag(sk, SOCK_ZAPPED);
+	release_sock(sk);
+
+	if (zapped)
+		return -EINVAL;
+
 	if (!addr || alen < offsetofend(struct sockaddr, sa_family) ||
 	    addr->sa_family != AF_BLUETOOTH)
 		return -EINVAL;
-- 
2.30.2


  parent reply	other threads:[~2021-05-05 16:47 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 16:32 [PATCH AUTOSEL 5.11 001/104] ath11k: fix thermal temperature read Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 002/104] ALSA: usb-audio: Add Pioneer DJM-850 to quirks-table Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 003/104] fs: dlm: fix debugfs dump Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 004/104] fs: dlm: fix mark setting deadlock Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 005/104] fs: dlm: add errno handling to check callback Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 006/104] fs: dlm: add check if dlm is currently running Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 007/104] fs: dlm: change allocation limits Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 008/104] fs: dlm: check on minimum msglen size Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 009/104] fs: dlm: flush swork on shutdown Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 010/104] fs: dlm: add shutdown hook Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 011/104] tipc: convert dest node's address to network order Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 012/104] ASoC: Intel: bytcr_rt5640: Enable jack-detect support on Asus T100TAF Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 013/104] net/mlx5e: Use net_prefetchw instead of prefetchw in MPWQE TX datapath Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 014/104] net: stmmac: Set FIFO sizes for ipq806x Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 015/104] ASoC: rsnd: core: Check convert rate in rsnd_hw_params Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 016/104] Documentation: networking: switchdev: fix command for static FDB entries Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 017/104] Bluetooth: Fix incorrect status handling in LE PHY UPDATE event Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 018/104] i2c: bail out early when RDWR parameters are wrong Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 019/104] ALSA: hdsp: don't disable if not enabled Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 020/104] ALSA: hdspm: " Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 021/104] ALSA: rme9652: " Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 022/104] ALSA: bebob: enable to deliver MIDI messages for multiple ports Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 023/104] Bluetooth: Set CONF_NOT_COMPLETE as l2cap_chan default Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 024/104] Bluetooth: verify AMP hci_chan before amp_destroy Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 025/104] Bluetooth: initialize skb_queue_head at l2cap_chan_create() Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 026/104] net/sched: cls_flower: use ntohs for struct flow_dissector_key_ports Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 027/104] net: bridge: when suppression is enabled exclude RARP packets Sasha Levin
2021-05-05 16:32 ` Sasha Levin [this message]
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 029/104] selftests/powerpc: Fix L1D flushing tests for Power10 Sasha Levin
2021-05-05 16:32 ` [PATCH AUTOSEL 5.11 030/104] powerpc/32: Statically initialise first emergency context Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 031/104] net: hns3: remediate a potential overflow risk of bd_num_list Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 032/104] net: hns3: add handling for xmit skb with recursive fraglist Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 033/104] ip6_vti: proper dev_{hold|put} in ndo_[un]init methods Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 034/104] ASoC: Intel: bytcr_rt5640: Add quirk for the Chuwi Hi8 tablet Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 035/104] ice: handle increasing Tx or Rx ring sizes Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 036/104] KVM: arm64: Use BUG and BUG_ON in nVHE hyp Sasha Levin
2021-05-05 16:48   ` Marc Zyngier
2021-05-06  0:14     ` Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 037/104] net: usb: ax88179_178a: initialize local variables before use Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 038/104] Bluetooth: btusb: Enable quirk boolean flag for Mediatek Chip Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 039/104] ASoC: rt5670: Add a quirk for the Dell Venue 10 Pro 5055 Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 040/104] selftests: mptcp: launch mptcp_connect with timeout Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 041/104] i2c: Add I2C_AQ_NO_REP_START adapter quirk Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 042/104] Bluetooth: Do not set cur_adv_instance in adv param MGMT request Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 043/104] MIPS: Loongson64: Use _CACHE_UNCACHED instead of _CACHE_UNCACHED_ACCELERATED Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 044/104] coresight: Do not scan for graph if none is present Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 045/104] IB/hfi1: Correct oversized ring allocation Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 046/104] mac80211: Set priority and queue mapping for injected frames Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 047/104] mac80211: clear the beacon's CRC after channel switch Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 048/104] ASoC: soc-compress: lock pcm_mutex to resolve lockdep error Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 049/104] pinctrl: samsung: use 'int' for register masks in Exynos Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 050/104] rtw88: 8822c: add LC calibration for RTL8822C Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 051/104] mt76: mt7615: fix key set/delete issues Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 052/104] mt76: mt7615: support loading EEPROM for MT7613BE Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 053/104] mt76: mt76x0: disable GTK offloading Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 054/104] mt76: mt7915: always check return value from mt7915_mcu_alloc_wtbl_req Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 055/104] mt76: mt7915: fix key set/delete issue Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 056/104] mt76: mt7915: fix txpower init for TSSI off chips Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 057/104] mt76: mt7915: add wifi subsystem reset Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 058/104] i2c: imx: Fix PM reference leak in i2c_imx_reg_slave() Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 059/104] fuse: invalidate attrs when page writeback completes Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 060/104] virtiofs: fix userns Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 061/104] cuse: prevent clone Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 062/104] iwlwifi: pcie: make cfg vs. trans_cfg more robust Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 063/104] iwlwifi: queue: avoid memory leak in reset flow Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 064/104] powerpc/mm: Add cond_resched() while removing hpte mappings Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 065/104] ASoC: rsnd: call rsnd_ssi_master_clk_start() from rsnd_ssi_init() Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 066/104] Revert "iommu/amd: Fix performance counter initialization" Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 067/104] iommu/amd: Remove performance counter pre-initialization test Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 068/104] drm/amd/display: Force vsync flip when reconfiguring MPCC Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 069/104] selftests: Set CC to clang in lib.mk if LLVM is set Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 070/104] kconfig: nconf: stop endless search loops Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 071/104] ALSA: hda/realtek: Add quirk for Lenovo Ideapad S740 Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 072/104] ASoC: Intel: sof_sdw: add quirk for new ADL-P Rvp Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 073/104] ALSA: hda/hdmi: fix race in handling acomp ELD notification at resume Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 074/104] sctp: Fix out-of-bounds warning in sctp_process_asconf_param() Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 075/104] flow_dissector: Fix out-of-bounds warning in __skb_flow_bpf_to_target() Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 076/104] powerpc/xive: Use the "ibm, chip-id" property only under PowerNV Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 077/104] powerpc/smp: Set numa node before updating mask Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 078/104] wilc1000: Bring MAC address setting in line with typical Linux behavior Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 079/104] mac80211: properly drop the connection in case of invalid CSA IE Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 080/104] ASoC: rt286: Generalize support for ALC3263 codec Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 081/104] ethtool: ioctl: Fix out-of-bounds warning in store_link_ksettings_for_user() Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 082/104] net: sched: tapr: prevent cycle_time == 0 in parse_taprio_schedule Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 083/104] samples/bpf: Fix broken tracex1 due to kprobe argument change Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 084/104] powerpc/pseries: Stop calling printk in rtas_stop_self() Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 085/104] drm/amd/display: fixed divide by zero kernel crash during dsc enablement Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 086/104] drm/amd/display: add handling for hdcp2 rx id list validation Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 087/104] drm/amdgpu: Add mem sync flag for IB allocated by SA Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 088/104] mt76: mt7615: fix entering driver-own state on mt7663 Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 089/104] crypto: ccp: Free SEV device if SEV init fails Sasha Levin
2021-05-05 16:33 ` [PATCH AUTOSEL 5.11 090/104] wl3501_cs: Fix out-of-bounds warnings in wl3501_send_pkt Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 091/104] wl3501_cs: Fix out-of-bounds warnings in wl3501_mgmt_join Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 092/104] qtnfmac: Fix possible buffer overflow in qtnf_event_handle_external_auth Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 093/104] powerpc/iommu: Annotate nested lock for lockdep Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 094/104] iavf: remove duplicate free resources calls Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 095/104] net: ethernet: mtk_eth_soc: fix RX VLAN offload Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 096/104] selftests: mlxsw: Increase the tolerance of backlog buildup Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 097/104] selftests: mlxsw: Fix mausezahn invocation in ERSPAN scale test Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 098/104] kbuild: generate Module.symvers only when vmlinux exists Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 099/104] bnxt_en: Add PCI IDs for Hyper-V VF devices Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 100/104] ia64: module: fix symbolizer crash on fdescr Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 101/104] watchdog: rename __touch_watchdog() to a better descriptive name Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 102/104] watchdog: explicitly update timestamp when reporting softlockup Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 103/104] watchdog/softlockup: remove logic that tried to prevent repeated reports Sasha Levin
2021-05-05 16:34 ` [PATCH AUTOSEL 5.11 104/104] watchdog: fix barriers when printing backtraces from all CPUs Sasha Levin

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=20210505163413.3461611-28-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=abhishekpandit@chromium.org \
    --cc=alainm@chromium.org \
    --cc=apusaka@chromium.org \
    --cc=groeck@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+abfc0f5e668d4099af73@syzkaller.appspotmail.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).