Skip to contentSkip to conversation

afs: proc cells and rootcell are writeable

PATCH In review David Howells 10 participants 24 messages Jan 26, 2014 – Jan 31, 2014

Subsystems (2)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/1 afs: proc cells and rootcell are writeable

From: Pali Rohár <[email protected]>

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.

---

 fs/afs/proc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/afs/proc.c +2 -2
index 526e4bbbde59..276cb6ed0b93 100644
@@ -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;
 
#1 lore raw

fs/afs/proc.c int afs_proc_init(void) · line 154

Quoted 5 lines · David Howells
fs/afs/proc.c +2 -2
-       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

#2 lore raw
Quoted 9 lines · Linus Torvalds

fs/afs/proc.c int afs_proc_init(void) · line 154

Quoted 5 lines · David Howells
fs/afs/proc.c +2 -2
-       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.

Quoted 8 lines

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

#3 lore raw
Quoted 7 lines · Ingo Molnar

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

Quoted 8 lines

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

#4 lore raw
In reply to Ingo Molnar
Quoted 23 lines · Ingo Molnar
Quoted 9 lines · Linus Torvalds

fs/afs/proc.c int afs_proc_init(void) · line 154

Quoted 5 lines · David Howells
fs/afs/proc.c +2 -2
-       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.

Quoted 8 lines

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:

Quoted 8 lines

#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

#5 lore raw
Quoted 19 lines · Ingo Molnar
Quoted 18 lines · Ingo Molnar
Quoted 16 lines · Linus Torvalds

fs/afs/proc.c int afs_proc_init(void) · line 154

Quoted 4 lines · David Howells
fs/afs/proc.c +2 -2
-       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?

Quoted 6 lines
Quoted 6 lines

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

Quoted 7 lines
Quoted 1 line

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.

Quoted 2 lines

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 -- [email protected]

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

#6 lore raw
Quoted 37 lines · Geert Uytterhoeven
Quoted 19 lines · Ingo Molnar
Quoted 18 lines · Ingo Molnar
Quoted 16 lines · Linus Torvalds

fs/afs/proc.c int afs_proc_init(void) · line 154

Quoted 4 lines · David Howells
fs/afs/proc.c +2 -2
-       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?

Quoted 6 lines
Quoted 6 lines

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

Quoted 7 lines
Quoted 1 line

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__)
Quoted 6 lines

IMHO, this is again less outstanding.

Quoted 2 lines

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

#7 lore raw
Quoted 43 lines · Ingo Molnar
Quoted 42 lines · Geert Uytterhoeven
Quoted 19 lines · Ingo Molnar
Quoted 18 lines · Ingo Molnar
Quoted 16 lines · Linus Torvalds

fs/afs/proc.c int afs_proc_init(void) · line 154

Quoted 4 lines · David Howells
fs/afs/proc.c +2 -2
-       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?

Quoted 6 lines
Quoted 6 lines

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

Quoted 7 lines
Quoted 1 line

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.

Quoted 2 lines

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

Quoted 6 lines
Quoted 1 line

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

Quoted 4 lines

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 -- [email protected]

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

#8 lore raw
Quoted 46 lines · Geert Uytterhoeven
Quoted 45 lines · Ingo Molnar
Quoted 43 lines · Geert Uytterhoeven
Quoted 19 lines · Ingo Molnar
Quoted 18 lines · Ingo Molnar
Quoted 16 lines · Linus Torvalds

Review

Quoted 4 lines · David Howells
(quoted diff) +2 -2
-       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?

Quoted 6 lines
Quoted 6 lines

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

Quoted 7 lines
Quoted 1 line

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.

Quoted 2 lines

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?

Quoted 7 lines
Quoted 4 lines

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

maintainer
#9 lore raw
In reply to Geert Uytterhoeven
Quoted 13 lines · Geert Uytterhoeven
Quoted 12 lines · Ingo Molnar
Quoted 11 lines · Geert Uytterhoeven
Quoted 10 lines · Ingo Molnar
Quoted 9 lines · Ingo Molnar
Quoted 8 lines · Linus Torvalds

Review

Quoted 4 lines · David Howells
(quoted diff) +2 -2
-       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.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

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(+)
scripts/checkpatch.pl +15 -0
index 0ea2a1e..bf278e0 100755
@@ -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
author maintainer
#10 lore raw
In reply to Linus Torvalds
Quoted 6 lines · Linus Torvalds

fs/afs/proc.c int afs_proc_init(void) · line 154

Quoted 4 lines
fs/afs/proc.c +2 -2
-       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)?

Quoted 5 lines

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

#11 lore raw
Quoted 7 lines · David Howells
Quoted 5 lines · Linus Torvalds
Quoted 4 lines
fs/afs/proc.c +2 -2
-       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);
Quoted 5 lines
Quoted 1 line

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

author maintainer
#12 lore raw
Quoted 13 lines · Al Viro
Quoted 2 lines

... 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;
        }
Quoted 4 lines

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

#13 lore raw
In reply to David Howells
Quoted 5 lines · David Howells

From: Pali Rohár <[email protected]>

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

Quoted 31 lines

---

 fs/afs/proc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/afs/proc.c +2 -3
index 526e4bbbde59..276cb6ed0b93 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#14 lore raw
Quoted 4 lines · Eric W. Biederman

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

#15 lore raw

2014-01-30 Linus Torvalds <[email protected]>:

Quoted 10 lines
Quoted 4 lines · Eric W. Biederman

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

Signature · 2 lines
Pali Rohár
[email protected]
#16 lore raw
Quoted 2 lines · Pali Rohár

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

#17 lore raw
Quoted 10 lines · Linus Torvalds
Quoted 2 lines · Pali Rohár

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

#18 lore raw
In reply to Pali Rohár
Quoted 8 lines · Pali Rohár

2014-01-30 Linus Torvalds <[email protected]>:

Quoted 7 lines
Quoted 3 lines · Eric W. Biederman

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.

Quoted 5 lines

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

Quoted 7 lines

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.

Signature · 1 line
Russ Allbery ([email protected])              <http://www.eyrie.org/~eagle/>
author maintainer
#20 lore raw
Quoted 3 lines · David Howells
Quoted 1 line

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

author maintainer
#21 lore raw
Quoted 6 lines · David Howells
Quoted 3 lines
Quoted 1 line

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

author maintainer
#22 lore raw
In reply to Eric W. Biederman
Quoted 3 lines · Eric W. Biederman

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

author maintainer
#23 lore raw

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