Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5798437ybp; Tue, 8 Oct 2019 08:27:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIG5kKj/Cfl7FzcZvQfwuUTkSYnYTXHz9E1WltIpsVMiQ9FQx8ONpi464G5J7TYdHwB51i X-Received: by 2002:a50:8b61:: with SMTP id l88mr14083984edl.244.1570548469603; Tue, 08 Oct 2019 08:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570548469; cv=none; d=google.com; s=arc-20160816; b=U676vmAaencoQ6B/BmukPp+RwnLiOPDai9Jkn8Uk5hV6ZDOKD2CZVugwKByZ+01tQs GrgYOnIpEPEindPHzG5Ty84HKqC/dpB4tfQBaC/zW+ESpuhMcy05UY6RMbNgmRooB5lR 7dcq7CRYptig/8Tevuc0j2VMQH9fdNT6A1rRsjvoKCJvcWRl/Gtfu0jMojHb+8rZFSMY KV+1Dh22bVitWfZovg03g3vC6f3c0jJcBafcHdYTN47cK7cvdXYHZDwbGLNpN/qG/M/Z P5Aq7a+Vkq/JqUV3TCn7Xe/dNu8BvfFRw584dVG4jqhb6hTVSC6bMY/U5fcEmHDAYxUA Bzwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=t3WVpIye2qbPDXx8Sdd2GrNZbfoUOE8VXFYi2mhmojY=; b=qHVzzVhD/6T7w4I3rKM0RJpIjsqj0WbXwGqURy9x7XFmsBBlrm3REuN8jz8TXegYiY ob/n0eGxHfZpopTVb0YUNkgRZXTPhiSCrE3wHbnjdtdV2nDoB3Oqwo1YmWanKKSfiawr 1SLTy6Xu4Soma57rpzSo+ab0qBW8o6AaAZmDWdclWP35Jtj8MV/6S/XBvcJYO4bvtKBh xNgYVpNJqH6sf410pGCfsYIDidCADgt4wnD3hNHniFy0KXz7Qe0hbGLpfS5fg/0clCvy 5UUZQBj2liLIe/yZw5RESk3nO6cIUsYw6FVkkMmNYNgR1JS6BoYxPetUyBugHh0eYOK0 w4cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z26si8782802ejw.359.2019.10.08.08.27.25; Tue, 08 Oct 2019 08:27:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727649AbfJHP06 (ORCPT + 99 others); Tue, 8 Oct 2019 11:26:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:47500 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725966AbfJHP06 (ORCPT ); Tue, 8 Oct 2019 11:26:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 495B0AEF1; Tue, 8 Oct 2019 15:26:57 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id A1CA21E4827; Tue, 8 Oct 2019 17:26:56 +0200 (CEST) Date: Tue, 8 Oct 2019 17:26:56 +0200 From: Jan Kara To: Chengguang Xu Cc: Jan Kara , linux-kernel@vger.kernel.org Subject: Re: [PATCH] quota: check quota type in early stage Message-ID: <20191008152656.GA5050@quack2.suse.cz> References: <20191008145059.21402-1-cgxu519@mykernel.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191008145059.21402-1-cgxu519@mykernel.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 08-10-19 22:50:59, Chengguang Xu wrote: > Check quota type in early stage so we can avoid many > unncessary operations when the type is wrong. > > Signed-off-by: Chengguang Xu Yeah, checking earlier makes sense, especially since it consolidates two checks into one. I've added your patch to my tree. Thanks! Honza > --- > fs/quota/quota.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/fs/quota/quota.c b/fs/quota/quota.c > index cb13fb76dbee..5444d3c4d93f 100644 > --- a/fs/quota/quota.c > +++ b/fs/quota/quota.c > @@ -60,8 +60,6 @@ static int quota_sync_all(int type) > { > int ret; > > - if (type >= MAXQUOTAS) > - return -EINVAL; > ret = security_quotactl(Q_SYNC, type, 0, NULL); > if (!ret) > iterate_supers(quota_sync_one, &type); > @@ -686,8 +684,6 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, > { > int ret; > > - if (type >= MAXQUOTAS) > - return -EINVAL; > type = array_index_nospec(type, MAXQUOTAS); > /* > * Quota not supported on this fs? Check this before s_quota_types > @@ -831,6 +827,9 @@ int kernel_quotactl(unsigned int cmd, const char __user *special, > cmds = cmd >> SUBCMDSHIFT; > type = cmd & SUBCMDMASK; > > + if (type >= MAXQUOTAS) > + return -EINVAL; > + > /* > * As a special case Q_SYNC can be called without a specific device. > * It will iterate all superblocks that have quota enabled and call > -- > 2.21.0 > > > > -- Jan Kara SUSE Labs, CR