linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] afs: proc cells and rootcell are writeable
@ 2013-11-20 13:30 Pali Rohár
  2013-12-10  8:02 ` Pali Rohár
  2013-12-16  7:00 ` Andrew Morton
  0 siblings, 2 replies; 31+ messages in thread
From: Pali Rohár @ 2013-11-20 13:30 UTC (permalink / raw)
  To: David Howells; +Cc: linux-afs, linux-kernel

[-- Attachment #1: Type: Text/Plain, Size: 817 bytes --]

Both proc files are writeable and used for configuring cells. But
there is missing correct mode flag for writeable files. Without
this patch both proc files are read only.

diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 526e4bb..276cb6e 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -147,11 +147,11 @@ int afs_proc_init(void)
 	if (!proc_afs)
 		goto error_dir;
 
-	p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
+	p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
 	if (!p)
 		goto error_cells;
 
-	p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
+	p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
 	if (!p)
 		goto error_rootcell;
 
-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2013-11-20 13:30 [PATCH] afs: proc cells and rootcell are writeable Pali Rohár
@ 2013-12-10  8:02 ` Pali Rohár
  2013-12-16  7:00 ` Andrew Morton
  1 sibling, 0 replies; 31+ messages in thread
From: Pali Rohár @ 2013-12-10  8:02 UTC (permalink / raw)
  To: David Howells; +Cc: linux-afs, linux-kernel

[-- Attachment #1: Type: Text/Plain, Size: 954 bytes --]

On Wednesday 20 November 2013 14:30:55 Pali Rohár wrote:
> Both proc files are writeable and used for configuring cells.
> But there is missing correct mode flag for writeable files.
> Without this patch both proc files are read only.
> 
> diff --git a/fs/afs/proc.c b/fs/afs/proc.c
> index 526e4bb..276cb6e 100644
> --- a/fs/afs/proc.c
> +++ b/fs/afs/proc.c
> @@ -147,11 +147,11 @@ int afs_proc_init(void)
>  	if (!proc_afs)
>  		goto error_dir;
> 
> -	p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> +	p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR,
> proc_afs, &afs_proc_cells_fops); if (!p)
>  		goto error_cells;
> 
> -	p = proc_create("rootcell", 0, proc_afs,
> &afs_proc_rootcell_fops); +	p = proc_create("rootcell",
> S_IFREG | S_IRUGO | S_IWUSR, proc_afs,
> &afs_proc_rootcell_fops); if (!p)
>  		goto error_rootcell;

Hello, can somebody review my patch?

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2013-11-20 13:30 [PATCH] afs: proc cells and rootcell are writeable Pali Rohár
  2013-12-10  8:02 ` Pali Rohár
@ 2013-12-16  7:00 ` Andrew Morton
  2013-12-17 13:19   ` Pali Rohár
  2013-12-17 18:31   ` David Howells
  1 sibling, 2 replies; 31+ messages in thread
From: Andrew Morton @ 2013-12-16  7:00 UTC (permalink / raw)
  To: Pali Rohár; +Cc: David Howells, linux-afs, linux-kernel

On Wed, 20 Nov 2013 14:30:55 +0100 Pali Roh__r <pali.rohar@gmail.com> wrote:

> Both proc files are writeable and used for configuring cells. But
> there is missing correct mode flag for writeable files. Without
> this patch both proc files are read only.
> 
> diff --git a/fs/afs/proc.c b/fs/afs/proc.c
> index 526e4bb..276cb6e 100644
> --- a/fs/afs/proc.c
> +++ b/fs/afs/proc.c
> @@ -147,11 +147,11 @@ int afs_proc_init(void)
>  	if (!proc_afs)
>  		goto error_dir;
>  
> -	p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> +	p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
>  	if (!p)
>  		goto error_cells;
>  
> -	p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> +	p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
>  	if (!p)
>  		goto error_rootcell;

Please send a signed-off-by: for this, as per
Documentation/SubmittingPatches, section 12.

David ack?

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2013-12-16  7:00 ` Andrew Morton
@ 2013-12-17 13:19   ` Pali Rohár
  2013-12-17 18:31   ` David Howells
  1 sibling, 0 replies; 31+ messages in thread
From: Pali Rohár @ 2013-12-17 13:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Howells, linux-afs, linux-kernel

[-- Attachment #1: Type: Text/Plain, Size: 1320 bytes --]

On Monday 16 December 2013 08:00:04 Andrew Morton wrote:
> On Wed, 20 Nov 2013 14:30:55 +0100 Pali Roh__r 
<pali.rohar@gmail.com> wrote:
> > Both proc files are writeable and used for configuring
> > cells. But there is missing correct mode flag for writeable
> > files. Without this patch both proc files are read only.
> > 
> > diff --git a/fs/afs/proc.c b/fs/afs/proc.c
> > index 526e4bb..276cb6e 100644
> > --- a/fs/afs/proc.c
> > +++ b/fs/afs/proc.c
> > @@ -147,11 +147,11 @@ int afs_proc_init(void)
> > 
> >  	if (!proc_afs)
> >  	
> >  		goto error_dir;
> > 
> > -	p = proc_create("cells", 0, proc_afs,
> > &afs_proc_cells_fops); +	p = proc_create("cells", S_IFREG |
> > S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
> > 
> >  	if (!p)
> >  	
> >  		goto error_cells;
> > 
> > -	p = proc_create("rootcell", 0, proc_afs,
> > &afs_proc_rootcell_fops); +	p = proc_create("rootcell",
> > S_IFREG | S_IRUGO | S_IWUSR, proc_afs,
> > &afs_proc_rootcell_fops);
> > 
> >  	if (!p)
> >  	
> >  		goto error_rootcell;
> 
> Please send a signed-off-by: for this, as per
> Documentation/SubmittingPatches, section 12.
> 
> David ack?

Sorry, I forgot to add Signed-off-by. Here it is:

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2013-12-16  7:00 ` Andrew Morton
  2013-12-17 13:19   ` Pali Rohár
@ 2013-12-17 18:31   ` David Howells
  2013-12-31  9:59     ` Pali Rohár
  1 sibling, 1 reply; 31+ messages in thread
From: David Howells @ 2013-12-17 18:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: dhowells, Pali Rohár, linux-afs, linux-kernel

Andrew Morton <akpm@linux-foundation.org> wrote:

> David ack?

I've signed it off and added here:

	http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/commit/?h=afs&id=8de69dbba9012693d4f9e7a7e3c12a0b467f85f3

David

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2013-12-17 18:31   ` David Howells
@ 2013-12-31  9:59     ` Pali Rohár
  0 siblings, 0 replies; 31+ messages in thread
From: Pali Rohár @ 2013-12-31  9:59 UTC (permalink / raw)
  To: David Howells; +Cc: Andrew Morton, linux-afs, linux-kernel

[-- Attachment #1: Type: Text/Plain, Size: 638 bytes --]

On Tuesday 17 December 2013 19:31:05 David Howells wrote:
> Andrew Morton <akpm@linux-foundation.org> wrote:
> > David ack?
> 
> I've signed it off and added here:
> 
> 	http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs
> .git/commit/?h=afs&id=8de69dbba9012693d4f9e7a7e3c12a0b467f85f3
> 
> David

Can you propose this patch also for stable branches? Without this 
patch it is not possible to write to cells and rootcell files 
which means that it is not possible to add new servers to cells, 
so it is not possible to access afs disks and afs driver is 
unusable...

-- 
Pali Rohár
pali.rohar@gmail.com


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* [PATCH] afs: proc cells and rootcell are writeable
@ 2014-01-26 12:27 David Howells
  2014-01-26 19:23 ` Linus Torvalds
  2014-01-30 21:48 ` Eric W. Biederman
  0 siblings, 2 replies; 31+ messages in thread
From: David Howells @ 2014-01-26 12:27 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, linux-afs, Pali Rohár

From: Pali Rohár <pali.rohar@gmail.com>

Both proc files are writeable and used for configuring cells. But
there is missing correct mode flag for writeable files. Without
this patch both proc files are read only.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/afs/proc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 526e4bbbde59..276cb6ed0b93 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -147,11 +147,11 @@ int afs_proc_init(void)
 	if (!proc_afs)
 		goto error_dir;
 
-	p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
+	p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
 	if (!p)
 		goto error_cells;
 
-	p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
+	p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
 	if (!p)
 		goto error_rootcell;
 


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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-26 12:27 David Howells
@ 2014-01-26 19:23 ` Linus Torvalds
  2014-01-26 20:19   ` Ingo Molnar
  2014-01-28 20:20   ` David Howells
  2014-01-30 21:48 ` Eric W. Biederman
  1 sibling, 2 replies; 31+ messages in thread
From: Linus Torvalds @ 2014-01-26 19:23 UTC (permalink / raw)
  To: David Howells; +Cc: Linux Kernel Mailing List, linux-afs, Pali Rohár

On Sun, Jan 26, 2014 at 4:27 AM, David Howells <dhowells@redhat.com> wrote:
>
> -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
> -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);

So the S_IFREG isn't necessary.

And quite frankly, I personally think S_IRUGO | S_IWUSR is _less_
readable than 0644. It's damn hard to parse those random letter
combinations, and at least I have to really think about it, in a way
that the octal representation does *not* make me go "I have to think
about that".

So my personal preference would be to just see that simple 0644 in
proc_create. Hmm?

                Linus

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-26 19:23 ` Linus Torvalds
@ 2014-01-26 20:19   ` Ingo Molnar
  2014-01-26 20:22     ` Ingo Molnar
  2014-01-26 20:25     ` Ingo Molnar
  2014-01-28 20:20   ` David Howells
  1 sibling, 2 replies; 31+ messages in thread
From: Ingo Molnar @ 2014-01-26 20:19 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: David Howells, Linux Kernel Mailing List, linux-afs,
	Pali Rohár


* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Sun, Jan 26, 2014 at 4:27 AM, David Howells <dhowells@redhat.com> wrote:
> >
> > -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> > +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
> > -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> > +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
> 
> So the S_IFREG isn't necessary.
> 
> And quite frankly, I personally think S_IRUGO | S_IWUSR is _less_ 
> readable than 0644. It's damn hard to parse those random letter 
> combinations, and at least I have to really think about it, in a way 
> that the octal representation does *not* make me go "I have to think 
> about that".
> 
> So my personal preference would be to just see that simple 0644 in 
> proc_create. Hmm?

Perhaps we could also generate the most common variants as:

 #define PERM__rw_r__r__		0644
 #define PERM__r________		0400
 #define PERM__r__r__r__		0444
 #define PERM__r_xr_xr_x		0555

etc.

or something similar, more or less matching the output of 'ls -l'?

That would also make security bugs in this area apparent at first 
sight. The number of people who can recognize during review that 
PERM_rw__w__w is probably unwise is probably two orders of magnitude 
than those who can interpret octal 0622 at a glance.

Thanks,

	Ingo

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-26 20:19   ` Ingo Molnar
@ 2014-01-26 20:22     ` Ingo Molnar
  2014-01-26 20:25     ` Ingo Molnar
  1 sibling, 0 replies; 31+ messages in thread
From: Ingo Molnar @ 2014-01-26 20:22 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: David Howells, Linux Kernel Mailing List, linux-afs,
	Pali Rohár


* Ingo Molnar <mingo@kernel.org> wrote:

> Perhaps we could also generate the most common variants as:
> 
>  #define PERM__rw_r__r__		0644
>  #define PERM__r________		0400
>  #define PERM__r__r__r__		0444
>  #define PERM__r_xr_xr_x		0555
> 
> etc.
> 
> or something similar, more or less matching the output of 'ls -l'?
> 
> That would also make security bugs in this area apparent at first 
> sight. The number of people who can recognize during review that 
> PERM_rw__w__w is probably unwise is probably two orders of magnitude 
> than those who can interpret octal 0622 at a glance.
 ^--higher

Thanks,

	Ingo

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-26 20:19   ` Ingo Molnar
  2014-01-26 20:22     ` Ingo Molnar
@ 2014-01-26 20:25     ` Ingo Molnar
  2014-01-28  8:39       ` Geert Uytterhoeven
  1 sibling, 1 reply; 31+ messages in thread
From: Ingo Molnar @ 2014-01-26 20:25 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: David Howells, Linux Kernel Mailing List, linux-afs,
	Pali Rohár


* Ingo Molnar <mingo@kernel.org> wrote:

> 
> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
> 
> > On Sun, Jan 26, 2014 at 4:27 AM, David Howells <dhowells@redhat.com> wrote:
> > >
> > > -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> > > +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
> > > -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> > > +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
> > 
> > So the S_IFREG isn't necessary.
> > 
> > And quite frankly, I personally think S_IRUGO | S_IWUSR is _less_ 
> > readable than 0644. It's damn hard to parse those random letter 
> > combinations, and at least I have to really think about it, in a way 
> > that the octal representation does *not* make me go "I have to think 
> > about that".
> > 
> > So my personal preference would be to just see that simple 0644 in 
> > proc_create. Hmm?
> 
> Perhaps we could also generate the most common variants as:
> 
>  #define PERM__rw_r__r__		0644
>  #define PERM__r________		0400
>  #define PERM__r__r__r__		0444
>  #define PERM__r_xr_xr_x		0555
> 
> etc.
> 
> or something similar, more or less matching the output of 'ls -l'?

Another variant of this would be to do the following macro:

	PERM(R_X, R_X, R_X)
	PERM(R__, R__, R__)
	PERM(RW_, R__, R__)

With the advantage of separating the groups better and reducing the 
number of constants needed.

Thanks,

	Ingo

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
@ 2014-01-27 12:33 Alexey Dobriyan
  0 siblings, 0 replies; 31+ messages in thread
From: Alexey Dobriyan @ 2014-01-27 12:33 UTC (permalink / raw)
  To: mingo; +Cc: Linus Torvalds, David Howells, pali.rohar, Linux Kernel

Ingo wrote:
> Perhaps we could also generate the most common variants as:
>
>  #define PERM__rw_r__r__ 0644

You're not alone!
http://lkml.indiana.edu/hypermail/linux/kernel/0607.3/1325.html

But I think 0644 is obvious and the most right way.

Of course, proc should detect those (->write vs ->mode) and complain.
Something I never sent.

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-26 20:25     ` Ingo Molnar
@ 2014-01-28  8:39       ` Geert Uytterhoeven
  2014-01-28 12:04         ` Ingo Molnar
  0 siblings, 1 reply; 31+ messages in thread
From: Geert Uytterhoeven @ 2014-01-28  8:39 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Linus Torvalds, David Howells, Linux Kernel Mailing List,
	linux-afs, Pali Rohár, Alexey Dobriyan

On Sun, Jan 26, 2014 at 9:25 PM, Ingo Molnar <mingo@kernel.org> wrote:
> * Ingo Molnar <mingo@kernel.org> wrote:
>> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
>> > On Sun, Jan 26, 2014 at 4:27 AM, David Howells <dhowells@redhat.com> wrote:
>> > > -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
>> > > +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
>> > > -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
>> > > +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
>> >
>> > So the S_IFREG isn't necessary.
>> >
>> > And quite frankly, I personally think S_IRUGO | S_IWUSR is _less_
>> > readable than 0644. It's damn hard to parse those random letter
>> > combinations, and at least I have to really think about it, in a way
>> > that the octal representation does *not* make me go "I have to think
>> > about that".
>> >
>> > So my personal preference would be to just see that simple 0644 in
>> > proc_create. Hmm?
>>
>> Perhaps we could also generate the most common variants as:
>>
>>  #define PERM__rw_r__r__              0644
>>  #define PERM__r________              0400
>>  #define PERM__r__r__r__              0444
>>  #define PERM__r_xr_xr_x              0555

I like it (also without the PERM prefix, cfr. Alexey's old patch).

>> or something similar, more or less matching the output of 'ls -l'?
>
> Another variant of this would be to do the following macro:
>
>         PERM(R_X, R_X, R_X)
>         PERM(R__, R__, R__)
>         PERM(RW_, R__, R__)

IMHO, this is again less outstanding.

> With the advantage of separating the groups better and reducing the
> number of constants needed.

Only a limited number of combinations is in active use, right?
It should be difficult to create e.g. world-writable files that are
not accessable
by the owner.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-28  8:39       ` Geert Uytterhoeven
@ 2014-01-28 12:04         ` Ingo Molnar
  2014-01-28 12:17           ` Geert Uytterhoeven
  0 siblings, 1 reply; 31+ messages in thread
From: Ingo Molnar @ 2014-01-28 12:04 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Torvalds, David Howells, Linux Kernel Mailing List,
	linux-afs, Pali Rohár, Alexey Dobriyan


* Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> On Sun, Jan 26, 2014 at 9:25 PM, Ingo Molnar <mingo@kernel.org> wrote:
> > * Ingo Molnar <mingo@kernel.org> wrote:
> >> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
> >> > On Sun, Jan 26, 2014 at 4:27 AM, David Howells <dhowells@redhat.com> wrote:
> >> > > -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> >> > > +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
> >> > > -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> >> > > +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
> >> >
> >> > So the S_IFREG isn't necessary.
> >> >
> >> > And quite frankly, I personally think S_IRUGO | S_IWUSR is _less_
> >> > readable than 0644. It's damn hard to parse those random letter
> >> > combinations, and at least I have to really think about it, in a way
> >> > that the octal representation does *not* make me go "I have to think
> >> > about that".
> >> >
> >> > So my personal preference would be to just see that simple 0644 in
> >> > proc_create. Hmm?
> >>
> >> Perhaps we could also generate the most common variants as:
> >>
> >>  #define PERM__rw_r__r__              0644
> >>  #define PERM__r________              0400
> >>  #define PERM__r__r__r__              0444
> >>  #define PERM__r_xr_xr_x              0555
> 
> I like it (also without the PERM prefix, cfr. Alexey's old patch).
> 
> >> or something similar, more or less matching the output of 'ls -l'?
> >
> > Another variant of this would be to do the following macro:
> >
> >         PERM(R_X, R_X, R_X)
> >         PERM(R__, R__, R__)
> >         PERM(RW_, R__, R__)
> 
> IMHO, this is again less outstanding.
> 
> > With the advantage of separating the groups better and reducing the
> > number of constants needed.
> 
> Only a limited number of combinations is in active use, right?

Correct - and in fact that kind of limitation is also a security 
feature: using patterns _outside_ of the typical, already defined 
group of permission patterns would in itself be a 'is that really 
justified?' red flag during review.

I'm fine with Alexey's shorter variant as well.

Would someone be interested in sending a real patch for it, defining a 
usable set of initial flags such as 0644, 0444, 0555 and 0600?

  comet:~/tip> for N in $(git grep -E '\.\<mode\>.*=.*0' arch/x86/ kernel/ | cut -d: -f2-); do echo $N; done | sort | grep ^0[0-7] | cut -c1-4 | uniq -c | sort -n
      1 0200
      1 0666
      5 0600
     15 0555
     16 0444
    148 0644

I'd definitely convert most of kernel/ and arch/x86/ to use them.

Thanks,

	Ingo

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-28 12:04         ` Ingo Molnar
@ 2014-01-28 12:17           ` Geert Uytterhoeven
  2014-01-28 12:20             ` Ingo Molnar
  2014-01-28 17:34             ` Joe Perches
  0 siblings, 2 replies; 31+ messages in thread
From: Geert Uytterhoeven @ 2014-01-28 12:17 UTC (permalink / raw)
  To: Ingo Molnar, Joe Perches
  Cc: Linus Torvalds, David Howells, Linux Kernel Mailing List,
	linux-afs, Pali Rohár, Alexey Dobriyan

On Tue, Jan 28, 2014 at 1:04 PM, Ingo Molnar <mingo@kernel.org> wrote:
> * Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> On Sun, Jan 26, 2014 at 9:25 PM, Ingo Molnar <mingo@kernel.org> wrote:
>> > * Ingo Molnar <mingo@kernel.org> wrote:
>> >> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
>> >> > On Sun, Jan 26, 2014 at 4:27 AM, David Howells <dhowells@redhat.com> wrote:
>> >> > > -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
>> >> > > +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
>> >> > > -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
>> >> > > +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
>> >> >
>> >> > So the S_IFREG isn't necessary.
>> >> >
>> >> > And quite frankly, I personally think S_IRUGO | S_IWUSR is _less_
>> >> > readable than 0644. It's damn hard to parse those random letter
>> >> > combinations, and at least I have to really think about it, in a way
>> >> > that the octal representation does *not* make me go "I have to think
>> >> > about that".
>> >> >
>> >> > So my personal preference would be to just see that simple 0644 in
>> >> > proc_create. Hmm?
>> >>
>> >> Perhaps we could also generate the most common variants as:
>> >>
>> >>  #define PERM__rw_r__r__              0644
>> >>  #define PERM__r________              0400
>> >>  #define PERM__r__r__r__              0444
>> >>  #define PERM__r_xr_xr_x              0555
>>
>> I like it (also without the PERM prefix, cfr. Alexey's old patch).
>>
>> >> or something similar, more or less matching the output of 'ls -l'?
>> >
>> > Another variant of this would be to do the following macro:
>> >
>> >         PERM(R_X, R_X, R_X)
>> >         PERM(R__, R__, R__)
>> >         PERM(RW_, R__, R__)
>>
>> IMHO, this is again less outstanding.
>>
>> > With the advantage of separating the groups better and reducing the
>> > number of constants needed.
>>
>> Only a limited number of combinations is in active use, right?
>
> Correct - and in fact that kind of limitation is also a security
> feature: using patterns _outside_ of the typical, already defined
> group of permission patterns would in itself be a 'is that really
> justified?' red flag during review.

Then Joe (CCed :-) can write a checkpatch rule to flag all new users of the
I_S[RWX}* flags..,

> I'm fine with Alexey's shorter variant as well.
>
> Would someone be interested in sending a real patch for it, defining a
> usable set of initial flags such as 0644, 0444, 0555 and 0600?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-28 12:17           ` Geert Uytterhoeven
@ 2014-01-28 12:20             ` Ingo Molnar
  2014-01-28 17:34             ` Joe Perches
  1 sibling, 0 replies; 31+ messages in thread
From: Ingo Molnar @ 2014-01-28 12:20 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Joe Perches, Linus Torvalds, David Howells,
	Linux Kernel Mailing List, linux-afs, Pali Rohár,
	Alexey Dobriyan


* Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> On Tue, Jan 28, 2014 at 1:04 PM, Ingo Molnar <mingo@kernel.org> wrote:
> > * Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> >> On Sun, Jan 26, 2014 at 9:25 PM, Ingo Molnar <mingo@kernel.org> wrote:
> >> > * Ingo Molnar <mingo@kernel.org> wrote:
> >> >> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
> >> >> > On Sun, Jan 26, 2014 at 4:27 AM, David Howells <dhowells@redhat.com> wrote:
> >> >> > > -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> >> >> > > +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
> >> >> > > -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> >> >> > > +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
> >> >> >
> >> >> > So the S_IFREG isn't necessary.
> >> >> >
> >> >> > And quite frankly, I personally think S_IRUGO | S_IWUSR is _less_
> >> >> > readable than 0644. It's damn hard to parse those random letter
> >> >> > combinations, and at least I have to really think about it, in a way
> >> >> > that the octal representation does *not* make me go "I have to think
> >> >> > about that".
> >> >> >
> >> >> > So my personal preference would be to just see that simple 0644 in
> >> >> > proc_create. Hmm?
> >> >>
> >> >> Perhaps we could also generate the most common variants as:
> >> >>
> >> >>  #define PERM__rw_r__r__              0644
> >> >>  #define PERM__r________              0400
> >> >>  #define PERM__r__r__r__              0444
> >> >>  #define PERM__r_xr_xr_x              0555
> >>
> >> I like it (also without the PERM prefix, cfr. Alexey's old patch).
> >>
> >> >> or something similar, more or less matching the output of 'ls -l'?
> >> >
> >> > Another variant of this would be to do the following macro:
> >> >
> >> >         PERM(R_X, R_X, R_X)
> >> >         PERM(R__, R__, R__)
> >> >         PERM(RW_, R__, R__)
> >>
> >> IMHO, this is again less outstanding.
> >>
> >> > With the advantage of separating the groups better and reducing the
> >> > number of constants needed.
> >>
> >> Only a limited number of combinations is in active use, right?
> >
> > Correct - and in fact that kind of limitation is also a security
> > feature: using patterns _outside_ of the typical, already defined
> > group of permission patterns would in itself be a 'is that really
> > justified?' red flag during review.
> 
> Then Joe (CCed :-) can write a checkpatch rule to flag all new users of the
> I_S[RWX}* flags..,

I'd also flag raw octal use: they are easily mixed up and only a 
relatively small group of people will read them as-is, most other 
kernel/Linux people will only recognize anomalies in the rwxrwxrwx 
notation.

So the number of reviewers who might spot bugs, either during patch 
submission or later on reading the code increases.

Thanks,

	Ingo

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-28 12:17           ` Geert Uytterhoeven
  2014-01-28 12:20             ` Ingo Molnar
@ 2014-01-28 17:34             ` Joe Perches
  1 sibling, 0 replies; 31+ messages in thread
From: Joe Perches @ 2014-01-28 17:34 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Ingo Molnar, Linus Torvalds, David Howells,
	Linux Kernel Mailing List, linux-afs, Pali Rohár,
	Alexey Dobriyan

On Tue, 2014-01-28 at 13:17 +0100, Geert Uytterhoeven wrote:
> On Tue, Jan 28, 2014 at 1:04 PM, Ingo Molnar <mingo@kernel.org> wrote:
> > * Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> >> On Sun, Jan 26, 2014 at 9:25 PM, Ingo Molnar <mingo@kernel.org> wrote:
> >> > * Ingo Molnar <mingo@kernel.org> wrote:
> >> >> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
> >> >> > On Sun, Jan 26, 2014 at 4:27 AM, David Howells <dhowells@redhat.com> wrote:
> >> >> > > -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> >> >> > > +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
> >> >> > > -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> >> >> > > +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
> >> >> >
> >> >> > So the S_IFREG isn't necessary.
> >> >> >
> >> >> > And quite frankly, I personally think S_IRUGO | S_IWUSR is _less_
> >> >> > readable than 0644. It's damn hard to parse those random letter
> >> >> > combinations, and at least I have to really think about it, in a way
> >> >> > that the octal representation does *not* make me go "I have to think
> >> >> > about that".
> >> >> >
> >> >> > So my personal preference would be to just see that simple 0644 in
> >> >> > proc_create. Hmm?

I don't have an issue with octal uses here either.

I think just as clear if not clearer than defines like

#define {whatever_}rwxrwxrwx	0777
#define {whatever_}rw_r__r__	0644
#define {whatever_}r________	0400

etc...

> >> Only a limited number of combinations is in active use, right?
> > Correct - and in fact that kind of limitation is also a security
> > feature: using patterns _outside_ of the typical, already defined
> > group of permission patterns would in itself be a 'is that really
> > justified?' red flag during review.
> 
> Then Joe (CCed :-) can write a checkpatch rule to flag all new users of the
> I_S[RWX}* flags..,

Flagging all "odd" uses of octal too?

Perhaps a checkpatch rule might look something like:
---
 scripts/checkpatch.pl | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 0ea2a1e..bf278e0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -328,6 +328,12 @@ our $typeTypedefs = qr{(?x:
 	atomic_t
 )};
 
+our $permissions = qr{(?x:
+	S_I[RWX](?:USR|GRP|OTH)|
+	S_IRWX[UGO]|
+	S_I(?:RWX|ALL|R|W|X)UGO
+)};
+
 our $logFunctions = qr{(?x:
 	printk(?:_ratelimited|_once|)|
 	(?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
@@ -4457,6 +4463,15 @@ sub process {
 			WARN("EXPORTED_WORLD_WRITABLE",
 			     "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
 		}
+
+# check for uses of permissions S_I<FOO> defines
+		if ($line =~ /\b($permissions)\b/) {
+			my $perm = $1;
+			my $msg_type = \&WARN;
+			$msg_type = \&CHK if ($file);
+			&{$msg_type}("PERMISSIONS",
+				     "Use of $perm is not preferred.\n" . $herecurr);
+		}
 	}
 
 	# If we have no input at all, then there is nothing to report on



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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-26 19:23 ` Linus Torvalds
  2014-01-26 20:19   ` Ingo Molnar
@ 2014-01-28 20:20   ` David Howells
  2014-01-28 20:27     ` Al Viro
  1 sibling, 1 reply; 31+ messages in thread
From: David Howells @ 2014-01-28 20:20 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: dhowells, Linux Kernel Mailing List, linux-afs, Pali Rohár

Linus Torvalds <torvalds@linux-foundation.org> wrote:

> > -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> > +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
> > -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> > +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
> 
> So the S_IFREG isn't necessary.

True.  Is it worth creating proc_create_special() that can create a non-regular
file and then making proc_create() only permit regular files (and complain if
the S_IFMT field is not zero)?

> And quite frankly, I personally think S_IRUGO | S_IWUSR is _less_
> readable than 0644. It's damn hard to parse those random letter
> combinations, and at least I have to really think about it, in a way
> that the octal representation does *not* make me go "I have to think
> about that".

Fine by me.

David

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-28 20:20   ` David Howells
@ 2014-01-28 20:27     ` Al Viro
  2014-01-28 20:56       ` David Howells
  0 siblings, 1 reply; 31+ messages in thread
From: Al Viro @ 2014-01-28 20:27 UTC (permalink / raw)
  To: David Howells
  Cc: Linus Torvalds, Linux Kernel Mailing List, linux-afs, Pali Roh??r

On Tue, Jan 28, 2014 at 08:20:12PM +0000, David Howells wrote:
> Linus Torvalds <torvalds@linux-foundation.org> wrote:
> 
> > > -       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> > > +       p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
> > > -       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> > > +       p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
> > 
> > So the S_IFREG isn't necessary.
> 
> True.  Is it worth creating proc_create_special() that can create a non-regular
> file and then making proc_create() only permit regular files (and complain if
> the S_IFMT field is not zero)?

We already do: in proc_create_data() we have
        struct proc_dir_entry *pde;
        if ((mode & S_IFMT) == 0)
                mode |= S_IFREG;

        if (!S_ISREG(mode)) {
                WARN_ON(1);     /* use proc_mkdir() */
                return NULL;
        }

proc_mkdir{,_data,_mode} are there for purpose.  Nobody had been insane
enough to put FIFOs or sockets in procfs and anything else would need
additional data anyway.  proc_symlink() is there, proc_mknod() isn't and
nobody has complained yet.  Let's keep it that way, plese...

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-28 20:27     ` Al Viro
@ 2014-01-28 20:56       ` David Howells
  0 siblings, 0 replies; 31+ messages in thread
From: David Howells @ 2014-01-28 20:56 UTC (permalink / raw)
  To: Al Viro
  Cc: dhowells, Linus Torvalds, Linux Kernel Mailing List, linux-afs,
	Pali Roh??r

Al Viro <viro@ZenIV.linux.org.uk> wrote:

> > ... and then making proc_create() only permit regular files (and complain
> > if the S_IFMT field is not zero)?
> 
> We already do: in proc_create_data() we have
>         struct proc_dir_entry *pde;
>         if ((mode & S_IFMT) == 0)
>                 mode |= S_IFREG;
> 
>         if (!S_ISREG(mode)) {
>                 WARN_ON(1);     /* use proc_mkdir() */
>                 return NULL;
>         }
> 
> proc_mkdir{,_data,_mode} are there for purpose.  Nobody had been insane
> enough to put FIFOs or sockets in procfs and anything else would need
> additional data anyway.  proc_symlink() is there, proc_mknod() isn't and
> nobody has complained yet.  Let's keep it that way, plese...

Should we then change the proc_create_data() to do:

	struct proc_dir_entry *pde;

	if (mode & S_IFMT) {
		WARN_ON(1);     /* use proc_mkdir() */
		return NULL;
	}
	mode |= S_IFREG;

and stop passing S_IFREG into it?

David

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-26 12:27 David Howells
  2014-01-26 19:23 ` Linus Torvalds
@ 2014-01-30 21:48 ` Eric W. Biederman
  2014-01-30 21:50   ` Linus Torvalds
  2014-01-31  0:07   ` David Howells
  1 sibling, 2 replies; 31+ messages in thread
From: Eric W. Biederman @ 2014-01-30 21:48 UTC (permalink / raw)
  To: David Howells; +Cc: torvalds, linux-kernel, linux-afs, Pali Rohár

David Howells <dhowells@redhat.com> writes:

> From: Pali Rohár <pali.rohar@gmail.com>
>
> Both proc files are writeable and used for configuring cells. But
> there is missing correct mode flag for writeable files. Without
> this patch both proc files are read only.

Dumb question.  Is this worth fixing?  Should we perhaps instead remove
the write methods?

These files have been read-only since this code was merged in 2002.
Over a decade of not being used seems like a strong indication that no
one cares about the write path.

Eric

> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
>
>  fs/afs/proc.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/afs/proc.c b/fs/afs/proc.c
> index 526e4bbbde59..276cb6ed0b93 100644
> --- a/fs/afs/proc.c
> +++ b/fs/afs/proc.c
> @@ -147,11 +147,11 @@ int afs_proc_init(void)
>  	if (!proc_afs)
>  		goto error_dir;
>  
> -	p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
> +	p = proc_create("cells", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_cells_fops);
>  	if (!p)
>  		goto error_cells;
>  
> -	p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
> +	p = proc_create("rootcell", S_IFREG | S_IRUGO | S_IWUSR, proc_afs, &afs_proc_rootcell_fops);
>  	if (!p)
>  		goto error_rootcell;
>  
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-30 21:48 ` Eric W. Biederman
@ 2014-01-30 21:50   ` Linus Torvalds
  2014-01-30 22:15     ` Pali Rohár
  2014-01-31  0:21     ` David Howells
  2014-01-31  0:07   ` David Howells
  1 sibling, 2 replies; 31+ messages in thread
From: Linus Torvalds @ 2014-01-30 21:50 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: David Howells, Linux Kernel Mailing List, linux-afs,
	Pali Rohár

On Thu, Jan 30, 2014 at 1:48 PM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
>
> These files have been read-only since this code was merged in 2002.
> Over a decade of not being used seems like a strong indication that no
> one cares about the write path.

I think this is a pretty strong argument. Counter-arguments, anybody?

                     Linus

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-30 21:50   ` Linus Torvalds
@ 2014-01-30 22:15     ` Pali Rohár
  2014-01-30 22:27       ` Linus Torvalds
  2014-01-30 22:33       ` Russ Allbery
  2014-01-31  0:21     ` David Howells
  1 sibling, 2 replies; 31+ messages in thread
From: Pali Rohár @ 2014-01-30 22:15 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Eric W. Biederman, David Howells, Linux Kernel Mailing List,
	linux-afs

2014-01-30 Linus Torvalds <torvalds@linux-foundation.org>:
> On Thu, Jan 30, 2014 at 1:48 PM, Eric W. Biederman
> <ebiederm@xmission.com> wrote:
>>
>> These files have been read-only since this code was merged in 2002.
>> Over a decade of not being used seems like a strong indication that no
>> one cares about the write path.
>
> I think this is a pretty strong argument. Counter-arguments, anybody?
>
>                      Linus

Hi!

In afs documentation is written that you need to write to these files. See:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/afs.txt#n82
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/afs.txt#n159

Without cells file, you cannot specify other cell servers and you can
use only one rootcell which was specified in kernel cmdline. So for
mounting other server, you need to reboot kernel (if you compiled afs
driver statically) and without cells file there is no other option to
mount more afs servers... (or at least it is not written in that
documentation). So I think without write access it is hard or maybe
impossible to use afs driver.

But maybe, afs maintainers or other afs developers should write more
info about it (or update documentation if is old).

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-30 22:15     ` Pali Rohár
@ 2014-01-30 22:27       ` Linus Torvalds
  2014-01-30 22:36         ` Dave Jones
  2014-01-30 22:33       ` Russ Allbery
  1 sibling, 1 reply; 31+ messages in thread
From: Linus Torvalds @ 2014-01-30 22:27 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Eric W. Biederman, David Howells, Linux Kernel Mailing List,
	linux-afs

On Thu, Jan 30, 2014 at 2:15 PM, Pali Rohár <pali.rohar@gmail.com> wrote:
>
> In afs documentation is written that you need to write to these files. See:

Well, but the afs documentation is clearly wrong, since the
"documented" procedure doesn't actually *work*.

So I don't think "it's documented" is a very strong argument.
Documentation is as useful as used toilet paper, if clearly nobody has
ever done what was "documented".

                     Linus

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-30 22:15     ` Pali Rohár
  2014-01-30 22:27       ` Linus Torvalds
@ 2014-01-30 22:33       ` Russ Allbery
  1 sibling, 0 replies; 31+ messages in thread
From: Russ Allbery @ 2014-01-30 22:33 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Linus Torvalds, David Howells, linux-afs, Eric W. Biederman,
	Linux Kernel Mailing List

Pali Rohár <pali.rohar@gmail.com> writes:
> 2014-01-30 Linus Torvalds <torvalds@linux-foundation.org>:
>> Eric W. Biederman <ebiederm@xmission.com> wrote:

>>> These files have been read-only since this code was merged in 2002.
>>> Over a decade of not being used seems like a strong indication that no
>>> one cares about the write path.

>> I think this is a pretty strong argument. Counter-arguments, anybody?

The current in-tree AFS module is still something of an experiment and is
not widely used by actual clients, essentially all of which are still
using the (old, ugly, frustratingly-difficult-to-maintain) out-of-tree
module.  This is mostly because the in-kernel module is not yet
sufficiently mature to support a variety of use cases.  I think this is a
(minor) step towards making it more mature.

> In afs documentation is written that you need to write to these files. See:

> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/afs.txt#n82
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/afs.txt#n159

> Without cells file, you cannot specify other cell servers and you can
> use only one rootcell which was specified in kernel cmdline. So for
> mounting other server, you need to reboot kernel (if you compiled afs
> driver statically) and without cells file there is no other option to
> mount more afs servers... (or at least it is not written in that
> documentation). So I think without write access it is hard or maybe
> impossible to use afs driver.

In the AFS world more generally, it is not common to change the root cell
without restarting the client.  It *is*, however, very common to add
configuration for new cells on the fly.  The most common implementation,
OpenAFS, has a command-line tool for root to do that (fs newcell).  The
equivalent for the in-tree AFS module would be writing to this file, so to
support the fs newcell command with the in-tree module, this file would
need to be writable.  This is a common action in some use cases.

By comparison, there is not a standard fs command to set the current local
cell, only to retrieve it.  However, I suspect that's primarily due to
design limitations in the OpenAFS client.  If it's not difficult to
support this operation in the in-tree kernel module, I think it would be a
good idea to do so early, since it's the kind of thing that could be
difficult to retroactively add later.

-- 
Russ Allbery (eagle@eyrie.org)              <http://www.eyrie.org/~eagle/>

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-30 22:27       ` Linus Torvalds
@ 2014-01-30 22:36         ` Dave Jones
  0 siblings, 0 replies; 31+ messages in thread
From: Dave Jones @ 2014-01-30 22:36 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Pali Rohár, Eric W. Biederman, David Howells,
	Linux Kernel Mailing List, linux-afs

On Thu, Jan 30, 2014 at 02:27:15PM -0800, Linus Torvalds wrote:
 > On Thu, Jan 30, 2014 at 2:15 PM, Pali Rohár <pali.rohar@gmail.com> wrote:
 > >
 > > In afs documentation is written that you need to write to these files. See:
 > 
 > Well, but the afs documentation is clearly wrong, since the
 > "documented" procedure doesn't actually *work*.
 > 
 > So I don't think "it's documented" is a very strong argument.
 > Documentation is as useful as used toilet paper, if clearly nobody has
 > ever done what was "documented".

Don't most (all?) of the people actually using AFS use some out-of-tree thing instead ?

	Dave


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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-30 21:48 ` Eric W. Biederman
  2014-01-30 21:50   ` Linus Torvalds
@ 2014-01-31  0:07   ` David Howells
  2014-01-31  0:20     ` David Howells
  1 sibling, 1 reply; 31+ messages in thread
From: David Howells @ 2014-01-31  0:07 UTC (permalink / raw)
  To: Eric W. Biederman, Linus Torvalds
  Cc: dhowells, linux-kernel, linux-afs, Pali Rohár

Eric W. Biederman <ebiederm@xmission.com> wrote:

> These files have been read-only since this code was merged in 2002.
> Over a decade of not being used seems like a strong indication that no
> one cares about the write path.

Actually, things aren't as simple as they seem.  Without the patch applied:

	[root@andromeda ~]# ls -l /proc/fs/afs/cells
	-r--r--r--. 1 root root 0 Jan 31 00:04 /proc/fs/afs/cells
	[root@andromeda ~]# echo add your-file-system.com 204.29.154.37 >/proc/fs/afs/cells
	[root@andromeda ~]# 

You'll observe there is no error reported on the echo command.

Further, looking in dmesg, I see:

	kAFS: Added new cell 'your-file-system.com'

So the file *is* writable, *despite* i_mode.

David

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-31  0:07   ` David Howells
@ 2014-01-31  0:20     ` David Howells
  0 siblings, 0 replies; 31+ messages in thread
From: David Howells @ 2014-01-31  0:20 UTC (permalink / raw)
  To: Eric W. Biederman, Linus Torvalds
  Cc: dhowells, linux-kernel, linux-afs, Pali Rohár


Further:

	[root@andromeda ~]# touch /tmp/foo
	[root@andromeda ~]# chmod 0444 /tmp/foo
	[root@andromeda ~]# ls -l /tmp/foo
	-r--r--r--. 1 root root 0 Jan 31 00:17 /tmp/foo
	[root@andromeda ~]# echo hello >/tmp/foo
	[root@andromeda ~]# ls -l /tmp/foo
	-r--r--r--. 1 root root 6 Jan 31 00:17 /tmp/foo
	[root@andromeda ~]# 

But:

	[root@andromeda ~]# su - dhowells
	[dhowells@andromeda ~]$ touch /tmp/bar
	[dhowells@andromeda ~]$ chmod 0444 /tmp/bar
	[dhowells@andromeda ~]$ ls -l /tmp/bar
	-r--r--r--. 1 dhowells dhowells 0 Jan 31 00:19 /tmp/bar
	[dhowells@andromeda ~]$ echo hello >/tmp/bar
	-bash: /tmp/bar: Permission denied

David

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-30 21:50   ` Linus Torvalds
  2014-01-30 22:15     ` Pali Rohár
@ 2014-01-31  0:21     ` David Howells
  2014-01-31  0:28       ` David Howells
  1 sibling, 1 reply; 31+ messages in thread
From: David Howells @ 2014-01-31  0:21 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: dhowells, Eric W. Biederman, Linux Kernel Mailing List, linux-afs,
	Pali Rohár

Linus Torvalds <torvalds@linux-foundation.org> wrote:

> I think this is a pretty strong argument. Counter-arguments, anybody?

Yes.  CAP_DAC_READ_SEARCH.

David

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-31  0:21     ` David Howells
@ 2014-01-31  0:28       ` David Howells
  2014-01-31  0:31         ` David Howells
  0 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2014-01-31  0:28 UTC (permalink / raw)
  Cc: dhowells, Linus Torvalds, Eric W. Biederman,
	Linux Kernel Mailing List, linux-afs, Pali Rohár

David Howells <dhowells@redhat.com> wrote:

> > I think this is a pretty strong argument. Counter-arguments, anybody?
> 
> Yes.  CAP_DAC_READ_SEARCH.

No, it would seem unlikely it's that, but I guess there's another capability
override because the process is owned by root.

David

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

* Re: [PATCH] afs: proc cells and rootcell are writeable
  2014-01-31  0:28       ` David Howells
@ 2014-01-31  0:31         ` David Howells
  0 siblings, 0 replies; 31+ messages in thread
From: David Howells @ 2014-01-31  0:31 UTC (permalink / raw)
  Cc: dhowells, Linus Torvalds, Eric W. Biederman,
	Linux Kernel Mailing List, linux-afs, Pali Rohár

David Howells <dhowells@redhat.com> wrote:

> > > I think this is a pretty strong argument. Counter-arguments, anybody?
> > 
> > Yes.  CAP_DAC_READ_SEARCH.
> 
> No, it would seem unlikely it's that, but I guess there's another capability
> override because the process is owned by root.

CAP_DAC_OVERRIDE, I think.

	int generic_permission(struct inode *inode, int mask)
	{
	...
		/*
		 * Read/write DACs are always overridable.
		 * Executable DACs are overridable when there is
		 * at least one exec bit set.
		 */
		if (!(mask & MAY_EXEC) || (inode->i_mode & S_IXUGO))
			if (inode_capable(inode, CAP_DAC_OVERRIDE))
				return 0;
	...
	}

David

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

end of thread, other threads:[~2014-01-31  0:31 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-20 13:30 [PATCH] afs: proc cells and rootcell are writeable Pali Rohár
2013-12-10  8:02 ` Pali Rohár
2013-12-16  7:00 ` Andrew Morton
2013-12-17 13:19   ` Pali Rohár
2013-12-17 18:31   ` David Howells
2013-12-31  9:59     ` Pali Rohár
  -- strict thread matches above, loose matches on Subject: below --
2014-01-26 12:27 David Howells
2014-01-26 19:23 ` Linus Torvalds
2014-01-26 20:19   ` Ingo Molnar
2014-01-26 20:22     ` Ingo Molnar
2014-01-26 20:25     ` Ingo Molnar
2014-01-28  8:39       ` Geert Uytterhoeven
2014-01-28 12:04         ` Ingo Molnar
2014-01-28 12:17           ` Geert Uytterhoeven
2014-01-28 12:20             ` Ingo Molnar
2014-01-28 17:34             ` Joe Perches
2014-01-28 20:20   ` David Howells
2014-01-28 20:27     ` Al Viro
2014-01-28 20:56       ` David Howells
2014-01-30 21:48 ` Eric W. Biederman
2014-01-30 21:50   ` Linus Torvalds
2014-01-30 22:15     ` Pali Rohár
2014-01-30 22:27       ` Linus Torvalds
2014-01-30 22:36         ` Dave Jones
2014-01-30 22:33       ` Russ Allbery
2014-01-31  0:21     ` David Howells
2014-01-31  0:28       ` David Howells
2014-01-31  0:31         ` David Howells
2014-01-31  0:07   ` David Howells
2014-01-31  0:20     ` David Howells
2014-01-27 12:33 Alexey Dobriyan

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