proc: set attributes of pde by accessor functions
Subsystems (2)
PATCH 1/2 proc: set attributes of pde by accessor functions
Clean up.
Signed-off-by Rui Xiang <[email protected]>
--- fs/proc/generic.c | 3 +-- fs/proc/proc_devtree.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
fs/proc/generic.c +1 -2
@@ -49,8 +49,7 @@ static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)setattr_copy (inode, iattr);mark_inode_dirty (inode); - de->uid = inode->i_uid; - de->gid = inode->i_gid; +proc_set_user (de, inode->i_uid, inode->i_gid); de->mode = inode->i_mode;return 0 ; }
fs/proc/proc_devtree.c +2 -2
@@ -77,9 +77,9 @@ __proc_device_tree_add_prop(struct proc_dir_entry *de, struct property *pp,return NULL ;if (!strncmp (name,"security-" ,9 )) - ent->size =0 ;/* don't leak number of password chars */ +proc_set_size (ent,0 );/* don't leak number of password chars */ else - ent->size = pp->length; +proc_set_size (ent, pp->length);return ent; }
Signature · 1 line
1.8.2.2
PATCH 2/2 proc: change return values while get_proc_task err
While getting proc task fails, it shoule return -ESRCH.
Signed-off-by Rui Xiang <[email protected]>
--- fs/proc/base.c | 25 +++++++++++++++---------- fs/proc/fd.c | 8 +++++--- fs/proc/namespaces.c | 12 ++++++++---- fs/proc_namespace.c | 2 +- 4 files changed, 29 insertions(+), 18 deletions(-)
fs/proc/base.c +15 -10
@@ -174,9 +174,10 @@ static int get_task_root(struct task_struct *task, struct path *root)static int proc_cwd_link (struct dentry *dentry,struct path *path) {struct task_struct *task =get_proc_task (dentry->d_inode); -int result = -ENOENT ; +int result = -ESRCH ;if (task) { + result = -ENOENT ;task_lock (task);if (task->fs) {get_fs_pwd (task->fs, path);
@@ -191,7 +192,7 @@ static int proc_cwd_link(struct dentry *dentry, struct path *path)static int proc_root_link (struct dentry *dentry,struct path *path) {struct task_struct *task =get_proc_task (dentry->d_inode); -int result = -ENOENT ; +int result = -ESRCH ;if (task) { result =get_task_root (task, path);
@@ -1438,11 +1439,11 @@ static int proc_exe_link(struct dentry *dentry, struct path *exe_path) task =get_proc_task (dentry->d_inode);if (!task) -return -ENOENT ; +return -ECHILD ; mm =get_task_mm (task);put_task_struct (task);if (!mm) -return -ENOENT ; +return -EINVAL ; exe_file =get_mm_exe_file (mm);mmput (mm);if (exe_file) {
@@ -1799,11 +1800,12 @@ static int proc_map_files_get_link(struct dentry *dentry, struct path *path)struct mm_struct *mm;int rc; - rc = -ENOENT ; + rc = -ESRCH ; task =get_proc_task (dentry->d_inode);if (!task) goto out; + rc = -EINVAL ; mm =get_task_mm (task);put_task_struct (task);if (!mm)
@@ -1934,7 +1936,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)if (!capable (CAP_SYS_ADMIN )) goto out; - ret = -ENOENT ; + ret = -ESRCH ; task =get_proc_task (file_inode (file));if (!task) goto out;
@@ -2161,11 +2163,12 @@ static struct dentry *proc_pident_lookup(struct inode *dir,struct task_struct *task =get_proc_task (dir);const struct pid_entry *p, *last; - error = -ENOENT ; + error = -ESRCH ;if (!task) goto out_no_task; + error = -ENOENT ;/* * Yes, it does not scale. And it should not. Don't add * new entries into /proc/<tgid>/ without very good reasons.
@@ -2194,7 +2197,7 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,const struct pid_entry *p;if (!task) -return -ENOENT ; +return -ESRCH ;if (!dir_emit_dots (file, ctx)) goto out;
@@ -3047,8 +3050,10 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentryunsigned tid;struct pid_namespace *ns; -if (!leader) +if (!leader) { + result = -ESRCH ; goto out_no_task; + } tid =name_to_int (dentry);if (tid == ~0U )
@@ -3152,7 +3157,7 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx)int tid;if (!task) -return -ENOENT ; +return -ESRCH ;rcu_read_lock ();if (pid_alive (task)) { leader = task->group_leader;
fs/proc/fd.c +5 -3
@@ -23,7 +23,7 @@ static int seq_show(struct seq_file *m, void *v) task =get_proc_task (m->private);if (!task) -return -ENOENT ; +return -ESRCH ; files =get_files_struct (task);put_task_struct (task);
@@ -206,8 +206,10 @@ static struct dentry *proc_lookupfd_common(struct inode *dir,int result = -ENOENT ;unsigned fd =name_to_int (dentry); -if (!task) +if (!task) { + result = -ESRCH ; goto out_no_task; + }if (fd == ~0U ) goto out;
@@ -226,7 +228,7 @@ static int proc_readfd_common(struct file *file, struct dir_context *ctx,unsigned int fd;if (!p) -return -ENOENT ; +return -ESRCH ;if (!dir_emit_dots (file, ctx)) goto out;
fs/proc/namespaces.c +8 -4
@@ -119,12 +119,13 @@ static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd)struct proc_inode *ei =PROC_I (inode);struct task_struct *task;struct path ns_path; -void *error =ERR_PTR (-EACCES ); +void *error =ERR_PTR (-ESRCH ); task =get_proc_task (inode);if (!task) goto out; + error =ERR_PTR (-EACCES );if (!ptrace_may_access (task,PTRACE_MODE_READ )) goto out_put_task;
@@ -152,12 +153,13 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int buflstruct task_struct *task;void *ns;char name[50 ]; -int len = -EACCES ; +int len = -ESRCH ; task =get_proc_task (inode);if (!task) goto out; + len = -EACCES ;if (!ptrace_may_access (task,PTRACE_MODE_READ )) goto out_put_task;
@@ -218,7 +220,7 @@ static int proc_ns_dir_readdir(struct file *file, struct dir_context *ctx)const struct proc_ns_operations **entry, **last;if (!task) -return -ENOENT ; +return -ESRCH ;if (!dir_emit_dots (file, ctx)) goto out;
@@ -254,8 +256,10 @@ static struct dentry *proc_ns_dir_lookup(struct inode *dir, error = -ENOENT ; -if (!task) +if (!task) { + error = -ESRCH ; goto out_no_task; + } last = &ns_entries[ARRAY_SIZE (ns_entries)];for (entry = ns_entries; entry < last; entry++) {
fs/proc_namespace.c +1 -1
@@ -230,7 +230,7 @@ static int mounts_open_common(struct inode *inode, struct file *file,int ret = -EINVAL ;if (!task) - goto err; +return -ESRCH ;rcu_read_lock (); nsp =task_nsproxy (task);
Signature · 1 line
1.8.2.2