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, Xiyu Yang <xiyuyang19@fudan.edu.cn>,
	Xin Tan <tanxin.ctf@gmail.com>, Christoph Hellwig <hch@lst.de>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.14 16/59] configfs: fix config_item refcnt leak in configfs_rmdir()
Date: Tue, 26 May 2020 20:53:01 +0200	[thread overview]
Message-ID: <20200526183913.423965027@linuxfoundation.org> (raw)
In-Reply-To: <20200526183907.123822792@linuxfoundation.org>

From: Xiyu Yang <xiyuyang19@fudan.edu.cn>

[ Upstream commit 8aebfffacfa379ba400da573a5bf9e49634e38cb ]

configfs_rmdir() invokes configfs_get_config_item(), which returns a
reference of the specified config_item object to "parent_item" with
increased refcnt.

When configfs_rmdir() returns, local variable "parent_item" becomes
invalid, so the refcount should be decreased to keep refcount balanced.

The reference counting issue happens in one exception handling path of
configfs_rmdir(). When down_write_killable() fails, the function forgets
to decrease the refcnt increased by configfs_get_config_item(), causing
a refcnt leak.

Fix this issue by calling config_item_put() when down_write_killable()
fails.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/configfs/dir.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index c2ef617d2f97..c875f246cb0e 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1537,6 +1537,7 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
 		spin_lock(&configfs_dirent_lock);
 		configfs_detach_rollback(dentry);
 		spin_unlock(&configfs_dirent_lock);
+		config_item_put(parent_item);
 		return -EINTR;
 	}
 	frag->frag_dead = true;
-- 
2.25.1




  parent reply	other threads:[~2020-05-26 19:30 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 18:52 [PATCH 4.14 00/59] 4.14.182-rc1 review Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 01/59] ext4: add cond_resched() to ext4_protect_reserved_inode Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 02/59] watchdog: Fix the race between the release of watchdog_core_data and cdev Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 03/59] i2c: dev: Fix the race between the release of i2c_dev " Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 04/59] padata: ensure the reorder timer callback runs on the correct CPU Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 05/59] padata: ensure padata_do_serial() " Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 06/59] ima: Set file->f_mode instead of file->f_flags in ima_calc_file_hash() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 07/59] evm: Check also if *tfm is an error pointer in init_desc() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 08/59] ima: Fix return value of ima_write_policy() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 09/59] fix multiplication overflow in copy_fdtable() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 10/59] iommu/amd: Fix over-read of ACPI UID from IVRS table Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 11/59] i2c: mux: demux-pinctrl: Fix an error handling path in i2c_demux_pinctrl_probe() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 12/59] ubi: Fix seq_file usage in detailed_erase_block_info debugfs file Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 13/59] gcc-common.h: Update for GCC 10 Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.14 14/59] HID: multitouch: add eGalaxTouch P80H84 support Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 15/59] scsi: qla2xxx: Fix hang when issuing nvme disconnect-all in NPIV Greg Kroah-Hartman
2020-05-26 18:53 ` Greg Kroah-Hartman [this message]
2020-05-26 18:53 ` [PATCH 4.14 17/59] vhost/vsock: fix packet delivery order to monitoring devices Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 18/59] component: Silence bind error on -EPROBE_DEFER Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 19/59] scsi: ibmvscsi: Fix WARN_ON during event pool release Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 20/59] x86/apic: Move TSC deadline timer debug printk Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 21/59] gtp: set NLM_F_MULTI flag in gtp_genl_dump_pdp() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 22/59] ceph: fix double unlock in handle_cap_export() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 23/59] USB: core: Fix misleading driver bug report Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 24/59] platform/x86: asus-nb-wmi: Do not load on Asus T100TA and T200TA Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 25/59] ARM: futex: Address build warning Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 26/59] padata: set cpu_index of unused CPUs to -1 Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 27/59] padata: Replace delayed timer with immediate workqueue in padata_reorder Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 28/59] padata: initialize pd->cpu with effective cpumask Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 29/59] padata: purge get_cpu and reorder_via_wq from padata_do_serial Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 30/59] arm64: fix the flush_icache_range arguments in machine_kexec Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 31/59] l2tp: dont register sessions in l2tp_session_create() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 32/59] l2tp: initialise l2tp_eth sessions before registering them Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 33/59] l2tp: protect sock pointer of struct pppol2tp_session with RCU Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 34/59] l2tp: initialise PPP sessions before registering them Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 35/59] ALSA: iec1712: Initialize STDSP24 properly when using the model=staudio option Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 36/59] ALSA: pcm: fix incorrect hw_base increase Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 37/59] apparmor: Fix aa_label refcnt leak in policy_update Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 38/59] dmaengine: tegra210-adma: Fix an error handling path in tegra_adma_probe() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 39/59] powerpc: restore alphabetic order in Kconfig Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 40/59] powerpc: Remove STRICT_KERNEL_RWX incompatibility with RELOCATABLE Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 41/59] powerpc/64s: Disable STRICT_KERNEL_RWX Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 42/59] x86/uaccess, ubsan: Fix UBSAN vs. SMAP Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 43/59] ubsan: build ubsan.c more conservatively Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 44/59] libnvdimm/btt: Remove unnecessary code in btt_freelist_init Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 45/59] libnvdimm/btt: Fix LBA masking during free list population Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 46/59] media: fdp1: Fix R-Car M3-N naming in debug message Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 47/59] cxgb4: free mac_hlist properly Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 48/59] cxgb4/cxgb4vf: Fix mac_hlist initialization and free Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 49/59] Revert "gfs2: Dont demote a glock until its revokes are written" Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 50/59] staging: iio: ad2s1210: Fix SPI reading Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 51/59] staging: greybus: Fix uninitialized scalar variable Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 52/59] iio: sca3000: Remove an erroneous get_device() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 53/59] iio: dac: vf610: Fix an error handling path in vf610_dac_probe() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 54/59] mei: release me_cl object reference Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 55/59] rapidio: fix an error in get_user_pages_fast() error handling Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 56/59] rxrpc: Fix a memory leak in rxkad_verify_response() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 57/59] x86/unwind/orc: Fix unwind_get_return_address_ptr() for inactive tasks Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 58/59] iio: adc: stm32-adc: Use dma_request_chan() instead dma_request_slave_channel() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.14 59/59] iio: adc: stm32-adc: fix device used to request dma Greg Kroah-Hartman
2020-05-27  8:32 ` [PATCH 4.14 00/59] 4.14.182-rc1 review Jon Hunter
2020-05-27  8:36 ` Naresh Kamboju
2020-05-27 13:51 ` Guenter Roeck
2020-05-27 16:51 ` shuah

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=20200526183913.423965027@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tanxin.ctf@gmail.com \
    --cc=xiyuyang19@fudan.edu.cn \
    /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).