Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp668793ybg; Mon, 1 Jun 2020 11:13:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwkTLCmYEwdq75kOKGmfgoViwgfZqOegks0Bq4kD+PuxovSbNcdmMuBVz+BTt3W3jpjQcg X-Received: by 2002:a05:6402:7c3:: with SMTP id u3mr10241128edy.253.1591035199088; Mon, 01 Jun 2020 11:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591035199; cv=none; d=google.com; s=arc-20160816; b=mUfwYklXmnPNbJlFdAdvmpHD6YpUKUhCZkAoqDVgd/OPchi50ohEwv/XA0p2IKmV7J 2DJxZkF8i0M0upaDpnX5P6FEGVnSwhH4HWNFPrAygfagsSvoae8MFsV4uzkSlBMrCfXU QiY2ufcyrSHaPuA+KTnlx3pxWR3taiXhJ2HoQp/wGiImILBqT1qv4CMfP1KomKz1mGXP HsbDr/rBMi/QeeZyEjj+nd7kq0BEINbiWpW5IXfpRu3Al9z6O4cYRtEt5H13IIhL3hJ9 zjs/SjQcPlHTZxczFHFHbUIgblkBAzRnnzK2HeNWGZQxnSnVLvGeFpNEkePGJkdD7vnA xLNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vRVbypT7+aCV7+lYnacimEVLBJuFMcbJmQFZZBfkvj8=; b=uREtVNJnOTbpnVEpMu81DwESkGH4STplyJvarMwBAwxGjCR/WOzKjlwJQRZuOLBHzg FMETXsu15i8xwWZUavc64EaiLCvAI03Uc67W2e13VbK73Dwnl7RekJXYjrnZAq5pEyuW AwClUCi7sUUUKuQf1atwgOd5qXTpEDZ5BaXjQooFm1oD+UknhRl4Y2wHxDlOZScMvlgx DNZ8k+wX/K6h2Ipg6JjwXA+X4tBsOaKSrBsOZk2TalxNkcgs5LNhoKAII7YIh6jeOJaU hJjJ/mgB3lk8KOHbNPzo30jy73OumG5nxJNPmzcMgnClmvdzMMg9NXC5Q2EQcLRknGAp mAew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="f/Yfwyje"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g31si73670edd.232.2020.06.01.11.12.55; Mon, 01 Jun 2020 11:13:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="f/Yfwyje"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728439AbgFASH6 (ORCPT + 99 others); Mon, 1 Jun 2020 14:07:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:53446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730594AbgFASHc (ORCPT ); Mon, 1 Jun 2020 14:07:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 83DCB21534; Mon, 1 Jun 2020 18:07:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591034852; bh=yrox0QZcIYDU3bUqM6FB7Xb1E77hfNM70fOnG+jZykk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/YfwyjegDumk46y2ZjeZSGbgUgKCgN9XQo1U5N6Amok6iay6bcie2Vn3/ronh5ID pqZiWVUwyAg8MoO6yk9j0pymoGb4pT9jZAEJUxB4fN5dgfIxK/WOrMdEfjPTJVxLHl x8XWFALmeEEwKIJveDTaIvGVYGjvSBuUGqE6fbUE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bob Peterson , Andreas Gruenbacher , Sasha Levin Subject: [PATCH 5.4 041/142] gfs2: move privileged user check to gfs2_quota_lock_check Date: Mon, 1 Jun 2020 19:53:19 +0200 Message-Id: <20200601174042.211849485@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174037.904070960@linuxfoundation.org> References: <20200601174037.904070960@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bob Peterson [ 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 Signed-off-by: Andreas Gruenbacher Signed-off-by: Sasha Levin --- 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 7c016a082aa6..cbee745169b8 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