linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] Btrfs-progs: disable qgroupid 0 for quota_tree
       [not found] <509B8053.3080509@cn.fujitsu.com>
@ 2012-11-08  9:55 ` Miao Xie
  2012-11-08 23:33   ` Chris Samuel
  0 siblings, 1 reply; 5+ messages in thread
From: Miao Xie @ 2012-11-08  9:55 UTC (permalink / raw)
  To: Linux Btrfs; +Cc: Arne Jansen, wangshilong

From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>

In kernel, qgroupid 0 is a special number when we run the quota group limit command.

So, we should not be able to create a quota group whose id is 0, otherwise the kernel
can't deal with it. Fix it.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
 cmds-qgroup.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 70019d0..dfff1b9 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -86,6 +86,10 @@ static int qgroup_create(int create, int argc, char **argv)
 	args.create = create;
 	args.qgroupid = parse_qgroupid(argv[1]);
 
+	if (!args.qgroupid) {
+		fprintf(stderr, "ERROR: qgroup 0 is not supported\n");
+		return 30;
+	}
 	fd = open_file_or_dir(path);
 	if (fd < 0) {
 		fprintf(stderr, "ERROR: can't access '%s'\n", path);
-- 1.7.7.6 










^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] Btrfs-progs: disable qgroupid 0 for quota_tree
  2012-11-08  9:55 ` [RFC PATCH] Btrfs-progs: disable qgroupid 0 for quota_tree Miao Xie
@ 2012-11-08 23:33   ` Chris Samuel
  2012-11-12  2:21     ` Miao Xie
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Samuel @ 2012-11-08 23:33 UTC (permalink / raw)
  To: miaox; +Cc: Linux Btrfs, Arne Jansen, wangshilong

On 08/11/12 20:55, Miao Xie wrote:

> In kernel, qgroupid 0 is a special number when we run the quota group
> limit command.
> 
> So, we should not be able to create a quota group whose id is 0,
> otherwise the kernel can't deal with it. Fix it.

This is probably a stupid question - but if its not meant to be possible
to create such a thing shouldn't this be fixed in the kernel (as well as
here) to reject attempts from user space to create it?

Otherwise it's possible for a non-aware program (or a user who is
playing) to still create it.

cheers,
Chris
-- 
 Chris Samuel  :  http://www.csamuel.org/  :  Melbourne, VIC

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] Btrfs-progs: disable qgroupid 0 for quota_tree
  2012-11-08 23:33   ` Chris Samuel
@ 2012-11-12  2:21     ` Miao Xie
  2012-11-12  6:25       ` Jan Schmidt
  0 siblings, 1 reply; 5+ messages in thread
From: Miao Xie @ 2012-11-12  2:21 UTC (permalink / raw)
  To: Chris Samuel; +Cc: Linux Btrfs, Arne Jansen, wangshilong

On fri, 09 Nov 2012 10:33:52 +1100, Chris Samuel wrote:
> On 08/11/12 20:55, Miao Xie wrote:
> 
>> In kernel, qgroupid 0 is a special number when we run the quota group
>> limit command.
>>
>> So, we should not be able to create a quota group whose id is 0,
>> otherwise the kernel can't deal with it. Fix it.
> 
> This is probably a stupid question - but if its not meant to be possible
> to create such a thing shouldn't this be fixed in the kernel (as well as
> here) to reject attempts from user space to create it?
> 
> Otherwise it's possible for a non-aware program (or a user who is
> playing) to still create it.

Right. It also should be fixed in the kernel side, the patch is coming.

But since we know which number is valid or not, it is better that we also check
the arguments in the user tool before they are passed into the kernel. So, we
can avoid trapping into the kernel, which will waste time, and output the error
information as soon as possible.

Thanks
Miao

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] Btrfs-progs: disable qgroupid 0 for quota_tree
  2012-11-12  2:21     ` Miao Xie
@ 2012-11-12  6:25       ` Jan Schmidt
  2012-11-12  7:08         ` Miao Xie
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Schmidt @ 2012-11-12  6:25 UTC (permalink / raw)
  To: miaox; +Cc: Chris Samuel, Linux Btrfs, Arne Jansen, wangshilong

Hi Miao,

On Mon, November 12, 2012 at 03:21 (+0100), Miao Xie wrote:
> On fri, 09 Nov 2012 10:33:52 +1100, Chris Samuel wrote:
>> On 08/11/12 20:55, Miao Xie wrote:
>>
>>> In kernel, qgroupid 0 is a special number when we run the quota group
>>> limit command.
>>>
>>> So, we should not be able to create a quota group whose id is 0,
>>> otherwise the kernel can't deal with it. Fix it.
>>
>> This is probably a stupid question - but if its not meant to be possible
>> to create such a thing shouldn't this be fixed in the kernel (as well as
>> here) to reject attempts from user space to create it?
>>
>> Otherwise it's possible for a non-aware program (or a user who is
>> playing) to still create it.
> 
> Right. It also should be fixed in the kernel side, the patch is coming.
> 
> But since we know which number is valid or not, it is better that we also check
> the arguments in the user tool before they are passed into the kernel. So, we
> can avoid trapping into the kernel, which will waste time, and output the error
> information as soon as possible.

Have the kernel return with errno EINVAL is the way everyone else (I know about)
does this.

I would avoid doing a check more than once where ever possible. Primarily,
because duplicating checks is error prone and in case of a kernel interface it
complicates future changes.

-Jan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] Btrfs-progs: disable qgroupid 0 for quota_tree
  2012-11-12  6:25       ` Jan Schmidt
@ 2012-11-12  7:08         ` Miao Xie
  0 siblings, 0 replies; 5+ messages in thread
From: Miao Xie @ 2012-11-12  7:08 UTC (permalink / raw)
  To: Jan Schmidt; +Cc: Chris Samuel, Linux Btrfs, Arne Jansen, wangshilong

On Mon, 12 Nov 2012 07:25:08 +0100, Jan Schmidt wrote:
>>>> In kernel, qgroupid 0 is a special number when we run the quota group
>>>> limit command.
>>>>
>>>> So, we should not be able to create a quota group whose id is 0,
>>>> otherwise the kernel can't deal with it. Fix it.
>>>
>>> This is probably a stupid question - but if its not meant to be possible
>>> to create such a thing shouldn't this be fixed in the kernel (as well as
>>> here) to reject attempts from user space to create it?
>>>
>>> Otherwise it's possible for a non-aware program (or a user who is
>>> playing) to still create it.
>>
>> Right. It also should be fixed in the kernel side, the patch is coming.
>>
>> But since we know which number is valid or not, it is better that we also check
>> the arguments in the user tool before they are passed into the kernel. So, we
>> can avoid trapping into the kernel, which will waste time, and output the error
>> information as soon as possible.
> 
> Have the kernel return with errno EINVAL is the way everyone else (I know about)
> does this.
> 
> I would avoid doing a check more than once where ever possible. Primarily,
> because duplicating checks is error prone and in case of a kernel interface it
> complicates future changes.

You've got a point there. I'll send out the kernel patch.

Thanks
Miao

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-12  7:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <509B8053.3080509@cn.fujitsu.com>
2012-11-08  9:55 ` [RFC PATCH] Btrfs-progs: disable qgroupid 0 for quota_tree Miao Xie
2012-11-08 23:33   ` Chris Samuel
2012-11-12  2:21     ` Miao Xie
2012-11-12  6:25       ` Jan Schmidt
2012-11-12  7:08         ` Miao Xie

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).