proc: warn if registering world writeable files
PATCH 1/1 proc: warn if registering world writeable files
---
fs/proc/generic.c | 1 + 1 file changed, 1 insertion(+)
fs/proc/generic.c +1 -0
@@ -623,6 +623,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,memcpy (((char *) ent) +sizeof (struct proc_dir_entry ), fn, len +1 ); ent->name = ((char *) ent) +sizeof (*ent); ent->namelen = len; +WARN_ON (S_ISREG (mode) && (mode &S_IWOTH )); ent->mode = mode; ent->nlink = nlink;atomic_set (&ent->count,1 );
Quoted 9 lines · Alexey Dobriyan
Signed-off-by Alexey Dobriyan <[email protected]>---
fs/proc/generic.c | 1 + 1 file changed, 1 insertion(+)
fs/proc/generic.c static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, · line 629
Quoted 7 lines
fs/proc/generic.c +1
-0@@ -623,6 +623,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,memcpy (((char *) ent) +sizeof (struct proc_dir_entry ), fn, len +1 ); ent->name = ((char *) ent) +sizeof (*ent); ent->namelen = len; +WARN_ON (S_ISREG (mode) && (mode &S_IWOTH )); ent->mode = mode; ent->nlink = nlink;atomic_set (&ent->count,1 );
Not sure about this. For the reason I mentioned in the checkpatch diff that this is "usually" a problem. There may be some use cases where it may actually be ok.
(I'm having a hard time thinking up a justification though tbh)
Dave
Quoted 11 lines · Dave Jones
fs/proc/generic.c static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, · line 629
Quoted 4 lines · Alexey Dobriyan
fs/proc/generic.c +1
-0+WARN_ON (S_ISREG (mode) && (mode &S_IWOTH )); ent->mode = mode; ent->nlink = nlink;atomic_set (&ent->count,1 );Not sure about this. For the reason I mentioned in the checkpatch diff that this is "usually" a problem. There may be some use cases where it may actually be ok.
(I'm having a hard time thinking up a justification though tbh)
Me too.
If it's for quick debugging, one can reassign ->mode after registering and escape the warning.