linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Shyam Prasad N <sprasad@microsoft.com>,
	Ronnie Sahlberg <lsahlber@redhat.com>,
	Steve French <stfrench@microsoft.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.4 07/64] cifs: fix double free race when mount fails in cifs_get_root()
Date: Mon,  7 Mar 2022 10:18:40 +0100	[thread overview]
Message-ID: <20220307091639.350910668@linuxfoundation.org> (raw)
In-Reply-To: <20220307091639.136830784@linuxfoundation.org>

From: Ronnie Sahlberg <lsahlber@redhat.com>

[ Upstream commit 3d6cc9898efdfb062efb74dc18cfc700e082f5d5 ]

When cifs_get_root() fails during cifs_smb3_do_mount() we call
deactivate_locked_super() which eventually will call delayed_free() which
will free the context.
In this situation we should not proceed to enter the out: section in
cifs_smb3_do_mount() and free the same resources a second time.

[Thu Feb 10 12:59:06 2022] BUG: KASAN: use-after-free in rcu_cblist_dequeue+0x32/0x60
[Thu Feb 10 12:59:06 2022] Read of size 8 at addr ffff888364f4d110 by task swapper/1/0

[Thu Feb 10 12:59:06 2022] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G           OE     5.17.0-rc3+ #4
[Thu Feb 10 12:59:06 2022] Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.0 12/17/2019
[Thu Feb 10 12:59:06 2022] Call Trace:
[Thu Feb 10 12:59:06 2022]  <IRQ>
[Thu Feb 10 12:59:06 2022]  dump_stack_lvl+0x5d/0x78
[Thu Feb 10 12:59:06 2022]  print_address_description.constprop.0+0x24/0x150
[Thu Feb 10 12:59:06 2022]  ? rcu_cblist_dequeue+0x32/0x60
[Thu Feb 10 12:59:06 2022]  kasan_report.cold+0x7d/0x117
[Thu Feb 10 12:59:06 2022]  ? rcu_cblist_dequeue+0x32/0x60
[Thu Feb 10 12:59:06 2022]  __asan_load8+0x86/0xa0
[Thu Feb 10 12:59:06 2022]  rcu_cblist_dequeue+0x32/0x60
[Thu Feb 10 12:59:06 2022]  rcu_core+0x547/0xca0
[Thu Feb 10 12:59:06 2022]  ? call_rcu+0x3c0/0x3c0
[Thu Feb 10 12:59:06 2022]  ? __this_cpu_preempt_check+0x13/0x20
[Thu Feb 10 12:59:06 2022]  ? lock_is_held_type+0xea/0x140
[Thu Feb 10 12:59:06 2022]  rcu_core_si+0xe/0x10
[Thu Feb 10 12:59:06 2022]  __do_softirq+0x1d4/0x67b
[Thu Feb 10 12:59:06 2022]  __irq_exit_rcu+0x100/0x150
[Thu Feb 10 12:59:06 2022]  irq_exit_rcu+0xe/0x30
[Thu Feb 10 12:59:06 2022]  sysvec_hyperv_stimer0+0x9d/0xc0
...
[Thu Feb 10 12:59:07 2022] Freed by task 58179:
[Thu Feb 10 12:59:07 2022]  kasan_save_stack+0x26/0x50
[Thu Feb 10 12:59:07 2022]  kasan_set_track+0x25/0x30
[Thu Feb 10 12:59:07 2022]  kasan_set_free_info+0x24/0x40
[Thu Feb 10 12:59:07 2022]  ____kasan_slab_free+0x137/0x170
[Thu Feb 10 12:59:07 2022]  __kasan_slab_free+0x12/0x20
[Thu Feb 10 12:59:07 2022]  slab_free_freelist_hook+0xb3/0x1d0
[Thu Feb 10 12:59:07 2022]  kfree+0xcd/0x520
[Thu Feb 10 12:59:07 2022]  cifs_smb3_do_mount+0x149/0xbe0 [cifs]
[Thu Feb 10 12:59:07 2022]  smb3_get_tree+0x1a0/0x2e0 [cifs]
[Thu Feb 10 12:59:07 2022]  vfs_get_tree+0x52/0x140
[Thu Feb 10 12:59:07 2022]  path_mount+0x635/0x10c0
[Thu Feb 10 12:59:07 2022]  __x64_sys_mount+0x1bf/0x210
[Thu Feb 10 12:59:07 2022]  do_syscall_64+0x5c/0xc0
[Thu Feb 10 12:59:07 2022]  entry_SYSCALL_64_after_hwframe+0x44/0xae

[Thu Feb 10 12:59:07 2022] Last potentially related work creation:
[Thu Feb 10 12:59:07 2022]  kasan_save_stack+0x26/0x50
[Thu Feb 10 12:59:07 2022]  __kasan_record_aux_stack+0xb6/0xc0
[Thu Feb 10 12:59:07 2022]  kasan_record_aux_stack_noalloc+0xb/0x10
[Thu Feb 10 12:59:07 2022]  call_rcu+0x76/0x3c0
[Thu Feb 10 12:59:07 2022]  cifs_umount+0xce/0xe0 [cifs]
[Thu Feb 10 12:59:07 2022]  cifs_kill_sb+0xc8/0xe0 [cifs]
[Thu Feb 10 12:59:07 2022]  deactivate_locked_super+0x5d/0xd0
[Thu Feb 10 12:59:07 2022]  cifs_smb3_do_mount+0xab9/0xbe0 [cifs]
[Thu Feb 10 12:59:07 2022]  smb3_get_tree+0x1a0/0x2e0 [cifs]
[Thu Feb 10 12:59:07 2022]  vfs_get_tree+0x52/0x140
[Thu Feb 10 12:59:07 2022]  path_mount+0x635/0x10c0
[Thu Feb 10 12:59:07 2022]  __x64_sys_mount+0x1bf/0x210
[Thu Feb 10 12:59:07 2022]  do_syscall_64+0x5c/0xc0
[Thu Feb 10 12:59:07 2022]  entry_SYSCALL_64_after_hwframe+0x44/0xae

Reported-by: Shyam Prasad N <sprasad@microsoft.com>
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/cifs/cifsfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 41b3c5fc958c7..f44b6f9d07776 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -855,6 +855,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
 
 out_super:
 	deactivate_locked_super(sb);
+	return root;
 out:
 	cifs_cleanup_volume_info(volume_info);
 	return root;
-- 
2.34.1




  parent reply	other threads:[~2022-03-07  9:35 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07  9:18 [PATCH 5.4 00/64] 5.4.183-rc1 review Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 01/64] mac80211_hwsim: report NOACK frames in tx_status Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 02/64] mac80211_hwsim: initialize ieee80211_tx_info at hw_scan_work Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 03/64] i2c: bcm2835: Avoid clock stretching timeouts Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 04/64] ASoC: rt5668: do not block workqueue if card is unbound Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 05/64] ASoC: rt5682: " Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 06/64] Input: clear BTN_RIGHT/MIDDLE on buttonpads Greg Kroah-Hartman
2022-03-07  9:18 ` Greg Kroah-Hartman [this message]
2022-03-07  9:18 ` [PATCH 5.4 08/64] dmaengine: shdma: Fix runtime PM imbalance on error Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 09/64] i2c: cadence: allow COMPILE_TEST Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 10/64] i2c: qup: " Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 11/64] net: usb: cdc_mbim: avoid altsetting toggling for Telit FN990 Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 12/64] usb: gadget: dont release an existing dev->buf Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 13/64] usb: gadget: clear related members when goto fail Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 14/64] ata: pata_hpt37x: fix PCI clock detection Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 15/64] ALSA: intel_hdmi: Fix reference to PCM buffer address Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 16/64] ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 17/64] xfrm: fix MTU regression Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 18/64] netfilter: fix use-after-free in __nf_register_net_hook() Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 19/64] xfrm: fix the if_id check in changelink Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 20/64] xfrm: enforce validity of offload input flags Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 21/64] netfilter: nf_queue: dont assume sk is full socket Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 22/64] netfilter: nf_queue: fix possible use-after-free Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 23/64] batman-adv: Request iflink once in batadv-on-batadv check Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 24/64] batman-adv: Request iflink once in batadv_get_real_netdevice Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 25/64] batman-adv: Dont expect inter-netns unique iflink indices Greg Kroah-Hartman
2022-03-07  9:18 ` [PATCH 5.4 26/64] net: dcb: flush lingering app table entries for unregistered devices Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 27/64] net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error generated by client Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 28/64] net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error cause by server Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 29/64] block: Fix fsync always failed if once failed Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 30/64] xen/netfront: destroy queues before real_num_tx_queues is zeroed Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 31/64] sched/topology: Make sched_init_numa() use a set for the deduplicating sort Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 32/64] sched/topology: Fix sched_domain_topology_level alloc in sched_init_numa() Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 33/64] ia64: ensure proper NUMA distance and possible map initialization Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 34/64] mac80211: fix forwarded mesh frames AC & queue selection Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 35/64] net: stmmac: fix return value of __setup handler Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 36/64] iavf: Fix missing check for running netdev Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 37/64] net: sxgbe: fix return value of __setup handler Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 38/64] net: arcnet: com20020: Fix null-ptr-deref in com20020pci_probe() Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 39/64] ixgbe: xsk: change !netif_carrier_ok() handling in ixgbe_xmit_zc() Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 40/64] efivars: Respect "block" flag in efivar_entry_set_safe() Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 41/64] firmware: arm_scmi: Remove space in MODULE_ALIAS name Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 42/64] ASoC: cs4265: Fix the duplicated control name Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 43/64] can: gs_usb: change active_channelss type from atomic_t to u8 Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 44/64] arm64: dts: rockchip: Switch RK3399-Gru DP to SPDIF output Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 45/64] igc: igc_read_phy_reg_gpy: drop premature return Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 46/64] ARM: Fix kgdb breakpoint for Thumb2 Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 47/64] ARM: 9182/1: mmu: fix returns from early_param() and __setup() functions Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 48/64] igc: igc_write_phy_reg_gpy: drop premature return Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 49/64] ibmvnic: free reset-work-item when flushing Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 50/64] memfd: fix F_SEAL_WRITE after shmem huge page allocated Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 51/64] soc: fsl: qe: Check of ioremap return value Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 52/64] net: chelsio: cxgb3: check the return value of pci_find_capability() Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 53/64] nl80211: Handle nla_memdup failures in handle_nan_filter Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 54/64] Input: elan_i2c - move regulator_[en|dis]able() out of elan_[en|dis]able_power() Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 55/64] Input: elan_i2c - fix regulator enable count imbalance after suspend/resume Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 56/64] HID: add mapping for KEY_DICTATE Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 57/64] HID: add mapping for KEY_ALL_APPLICATIONS Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 58/64] tracing/histogram: Fix sorting on old "cpu" value Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 59/64] tracing: Fix return value of __setup handlers Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 60/64] btrfs: fix lost prealloc extents beyond eof after full fsync Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 61/64] btrfs: qgroup: fix deadlock between rescan worker and remove qgroup Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 62/64] btrfs: add missing run of delayed items after unlink during log replay Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 63/64] Revert "xfrm: xfrm_state_mtu should return at least 1280 for ipv6" Greg Kroah-Hartman
2022-03-07  9:19 ` [PATCH 5.4 64/64] net: dcb: disable softirqs in dcbnl_flush_dev() Greg Kroah-Hartman
2022-03-07 18:46 ` [PATCH 5.4 00/64] 5.4.183-rc1 review Florian Fainelli
2022-03-07 23:47 ` Shuah Khan
2022-03-08  0:53 ` Samuel Zou
2022-03-08 15:19 ` Naresh Kamboju
2022-03-08 15:46 ` Sudip Mukherjee

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=20220307091639.350910668@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=sashal@kernel.org \
    --cc=sprasad@microsoft.com \
    --cc=stable@vger.kernel.org \
    --cc=stfrench@microsoft.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).