stable.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: Bob Peterson <rpeterso@redhat.com>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Sasha Levin <sashal@kernel.org>,
	cluster-devel@redhat.com
Subject: [PATCH AUTOSEL 5.6 14/41] gfs2: move privileged user check to gfs2_quota_lock_check
Date: Fri, 22 May 2020 10:49:31 -0400	[thread overview]
Message-ID: <20200522144959.434379-14-sashal@kernel.org> (raw)
In-Reply-To: <20200522144959.434379-1-sashal@kernel.org>

From: Bob Peterson <rpeterso@redhat.com>

[ Upstream commit 4ed0c30811cb4d30ef89850b787a53a84d5d2bcb ]

Before this patch, function gfs2_quota_lock checked if it was called
from a privileged user, and if so, it bypassed the quota check:
superuser can operate outside the quotas.
That's the wrong place for the check because the lock/unlock functions
are separate from the lock_check function, and you can do lock and
unlock without actually checking the quotas.

This patch moves the check to gfs2_quota_lock_check.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/gfs2/quota.c | 3 +--
 fs/gfs2/quota.h | 3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index e9f93045eb01..832d44782f74 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -1040,8 +1040,7 @@ int gfs2_quota_lock(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
 	u32 x;
 	int error = 0;
 
-	if (capable(CAP_SYS_RESOURCE) ||
-	    sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
+	if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
 		return 0;
 
 	error = gfs2_quota_hold(ip, uid, gid);
diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h
index 765627d9a91e..fe68a91dc16f 100644
--- a/fs/gfs2/quota.h
+++ b/fs/gfs2/quota.h
@@ -44,7 +44,8 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip,
 	int ret;
 
 	ap->allowed = UINT_MAX; /* Assume we are permitted a whole lot */
-	if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
+	if (capable(CAP_SYS_RESOURCE) ||
+	    sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
 		return 0;
 	ret = gfs2_quota_lock(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
 	if (ret)
-- 
2.25.1


  parent reply	other threads:[~2020-05-22 14:59 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22 14:49 [PATCH AUTOSEL 5.6 01/41] arm64: dts: qcom: db820c: fix audio configuration Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 02/41] ARM: dts: rockchip: fix phy nodename for rk3228-evb Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 03/41] ARM: dts: rockchip: fix phy nodename for rk3229-xms6 Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 04/41] arm64: dts: rockchip: fix status for &gmac2phy in rk3328-evb.dts Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 05/41] arm64: dts: rockchip: swap interrupts interrupt-names rk3399 gpu node Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 06/41] ARM: dts: rockchip: swap clock-names of gpu nodes Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 07/41] ARM: dts: rockchip: fix pinctrl sub nodename for spi in rk322x.dtsi Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 08/41] gpio: tegra: mask GPIO IRQs during IRQ shutdown Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 09/41] ALSA: usb-audio: add mapping for ASRock TRX40 Creator Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 10/41] ARM: dts: omap4-droid4: Fix flakey wlan by disabling internal pull for gpio Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 11/41] ARM: dts: omap4-droid4: Fix occasional lost wakeirq for uart1 Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 12/41] net: microchip: encx24j600: add missed kthread_stop Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 13/41] kselftests: dmabuf-heaps: Fix confused return value on expected error testing Sasha Levin
2020-05-22 14:49 ` Sasha Levin [this message]
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 15/41] gfs2: don't call quota_unhold if quotas are not locked Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 16/41] gfs2: Grab glock reference sooner in gfs2_add_revoke Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 17/41] drm/amdgpu: drop unnecessary cancel_delayed_work_sync on PG ungate Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 18/41] drm/amd/powerplay: perform PG ungate prior to CG ungate Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 19/41] drm/amdgpu: Use GEM obj reference for KFD BOs Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 20/41] Revert "gfs2: Don't demote a glock until its revokes are written" Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 21/41] cachefiles: Fix race between read_waiter and read_copier involving op->to_do Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 22/41] usb: dwc3: pci: Enable extcon driver for Intel Merrifield Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 23/41] usb: phy: twl6030-usb: Fix a resource leak in an error handling path in 'twl6030_usb_probe()' Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 24/41] usb: gadget: legacy: fix redundant initialization warnings Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 25/41] net: freescale: select CONFIG_FIXED_PHY where needed Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 26/41] drm/amd/amdgpu: Update update_config() logic Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 27/41] IB/i40iw: Remove bogus call to netdev_master_upper_dev_get() Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 28/41] riscv: Fix unmet direct dependencies built based on SOC_VIRT Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 29/41] riscv: stacktrace: Fix undefined reference to `walk_stackframe' Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 30/41] riscv: Add pgprot_writecombine/device and PAGE_SHARED defination if NOMMU Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 31/41] clk: ti: am33xx: fix RTC clock parent Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 32/41] csky: Fixup msa highest 3 bits mask Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 33/41] csky: Fixup perf callchain unwind Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 34/41] csky: Fixup remove duplicate irq_disable Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 35/41] drm/meson: pm resume add return errno branch Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 36/41] hwmon: (nct7904) Fix incorrect range of temperature limit registers Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 37/41] riscv: pgtable: Fix __kernel_map_pages build error if NOMMU Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 38/41] cifs: Fix null pointer check in cifs_read Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 39/41] csky: Fixup raw_copy_from_user() Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 40/41] samples: bpf: Fix build error Sasha Levin
2020-05-22 14:49 ` [PATCH AUTOSEL 5.6 41/41] drivers: net: hamradio: Fix suspicious RCU usage warning in bpqether.c 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=20200522144959.434379-14-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=agruenba@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpeterso@redhat.com \
    --cc=stable@vger.kernel.org \
    /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).