* [PATCH] quota: check quota type in early stage
@ 2019-10-08 14:50 Chengguang Xu
2019-10-08 15:26 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Chengguang Xu @ 2019-10-08 14:50 UTC (permalink / raw)
To: jack; +Cc: linux-kernel, Chengguang Xu
Check quota type in early stage so we can avoid many
unncessary operations when the type is wrong.
Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] quota: check quota type in early stage
2019-10-08 14:50 [PATCH] quota: check quota type in early stage Chengguang Xu
@ 2019-10-08 15:26 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2019-10-08 15:26 UTC (permalink / raw)
To: Chengguang Xu; +Cc: Jan Kara, linux-kernel
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 <cgxu519@mykernel.net>
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 <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-08 15:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08 14:50 [PATCH] quota: check quota type in early stage Chengguang Xu
2019-10-08 15:26 ` Jan Kara
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).