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>,
	John Johansen <john.johansen@canonical.com>
Subject: [PATCH 4.14 37/59] apparmor: Fix aa_label refcnt leak in policy_update
Date: Tue, 26 May 2020 20:53:22 +0200	[thread overview]
Message-ID: <20200526183919.409222748@linuxfoundation.org> (raw)
In-Reply-To: <20200526183907.123822792@linuxfoundation.org>

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

commit c6b39f070722ea9963ffe756bfe94e89218c5e63 upstream.

policy_update() invokes begin_current_label_crit_section(), which
returns a reference of the updated aa_label object to "label" with
increased refcount.

When policy_update() returns, "label" becomes invalid, so the refcount
should be decreased to keep refcount balanced.

The reference counting issue happens in one exception handling path of
policy_update(). When aa_may_manage_policy() returns not NULL, the
refcnt increased by begin_current_label_crit_section() is not decreased,
causing a refcnt leak.

Fix this issue by jumping to "end_section" label when
aa_may_manage_policy() returns not NULL.

Fixes: 5ac8c355ae00 ("apparmor: allow introspecting the loaded policy pre internal transform")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 security/apparmor/apparmorfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -426,7 +426,7 @@ static ssize_t policy_update(u32 mask, c
 	 */
 	error = aa_may_manage_policy(label, ns, mask);
 	if (error)
-		return error;
+		goto end_section;
 
 	data = aa_simple_write_to_buffer(buf, size, size, pos);
 	error = PTR_ERR(data);
@@ -434,6 +434,7 @@ static ssize_t policy_update(u32 mask, c
 		error = aa_replace_profiles(ns, label, mask, data);
 		aa_put_loaddata(data);
 	}
+end_section:
 	end_current_label_crit_section(label);
 
 	return error;



  parent reply	other threads:[~2020-05-26 19:01 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 ` [PATCH 4.14 16/59] configfs: fix config_item refcnt leak in configfs_rmdir() Greg Kroah-Hartman
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 ` Greg Kroah-Hartman [this message]
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=20200526183919.409222748@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=john.johansen@canonical.com \
    --cc=linux-kernel@vger.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).