make consistent errno value when open pident vs exit(2) race
PATCH 1/1 make consistent errno value when open pident vs exit(2) race
proc_pident_instantiate() has following call flow.
proc_pident_lookup()
proc_pident_instantiate()
proc_pid_make_inode()
And, proc_pident_lookup() has following error handling.
const struct pid_entry *p, *last; error = ERR_PTR(-ENOENT); if (!task) goto out_no_task;
Then, proc_pident_instantiate should return ENOENT too when racing against exit(2) occur.
EINAL has two bad reason.
- it implies caller is wrong. bad the race isn't caller's mistake.
- man 2 open don't explain EINVAL. user often don't handle it.
Note: Other proc_pid_make_inode() caller already use ENOENT properly.
--
fs/proc/base.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/proc/base.c +1 -1
@@ -1953,7 +1953,7 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,const struct pid_entry *p = ptr;struct inode *inode;struct proc_inode *ei; -struct dentry *error =ERR_PTR (-EINVAL ); +struct dentry *error =ERR_PTR (-ENOENT ); inode =proc_pid_make_inode (dir->i_sb, task);if (!inode)
Quoted 16 lines · KOSAKI Motohiro
proc_pident_instantiate()has following call flow.
proc_pident_lookup()
proc_pident_instantiate()
proc_pid_make_inode()And,
proc_pident_lookup()has following error handling.const struct pid_entry *p, *last; error = ERR_PTR(-ENOENT); if (!task) goto out_no_task;Then,
proc_pident_instantiateshould return ENOENT too when racing against exit(2) occur.
Quoted 6 lines
EINAL has two bad reason.
- it implies caller is wrong. bad the race isn't caller's mistake.
- man 2 open don't explain EINVAL. user often don't handle it.Note: Other
proc_pid_make_inode()caller already use ENOENT properly.
Looks reasonable to me.
Quoted 21 lines
Cc Eric W. Biederman <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexey Dobriyan <[email protected]>Signed-off-by KOSAKI Motohiro <[email protected]>--
fs/proc/base.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/proc/base.c +1
-1@@ -1953,7 +1953,7 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,const struct pid_entry *p = ptr;struct inode *inode;struct proc_inode *ei; -struct dentry *error =ERR_PTR (-EINVAL ); +struct dentry *error =ERR_PTR (-ENOENT ); inode =proc_pid_make_inode (dir->i_sb, task);if (!inode)