proc_fill_cache(): just make instantiate_t return int
all instances always return ERR_PTR(-E...) or NULL, anyway Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
db96316487
commit
c52a47ace7
|
@ -1700,7 +1700,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,
|
||||||
struct dentry *new;
|
struct dentry *new;
|
||||||
new = d_alloc(dir, &qname);
|
new = d_alloc(dir, &qname);
|
||||||
if (new) {
|
if (new) {
|
||||||
child = instantiate(dir->d_inode, new, task, ptr);
|
child = ERR_PTR(instantiate(dir->d_inode, new, task, ptr));
|
||||||
if (child)
|
if (child)
|
||||||
dput(new);
|
dput(new);
|
||||||
else
|
else
|
||||||
|
@ -1844,7 +1844,7 @@ struct map_files_info {
|
||||||
unsigned char name[4*sizeof(long)+2]; /* max: %lx-%lx\0 */
|
unsigned char name[4*sizeof(long)+2]; /* max: %lx-%lx\0 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct dentry *
|
static int
|
||||||
proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
|
proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
|
||||||
struct task_struct *task, const void *ptr)
|
struct task_struct *task, const void *ptr)
|
||||||
{
|
{
|
||||||
|
@ -1854,7 +1854,7 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
|
||||||
|
|
||||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||||
if (!inode)
|
if (!inode)
|
||||||
return ERR_PTR(-ENOENT);
|
return -ENOENT;
|
||||||
|
|
||||||
ei = PROC_I(inode);
|
ei = PROC_I(inode);
|
||||||
ei->op.proc_get_link = proc_map_files_get_link;
|
ei->op.proc_get_link = proc_map_files_get_link;
|
||||||
|
@ -1871,7 +1871,7 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
|
||||||
d_set_d_op(dentry, &tid_map_files_dentry_operations);
|
d_set_d_op(dentry, &tid_map_files_dentry_operations);
|
||||||
d_add(dentry, inode);
|
d_add(dentry, inode);
|
||||||
|
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dentry *proc_map_files_lookup(struct inode *dir,
|
static struct dentry *proc_map_files_lookup(struct inode *dir,
|
||||||
|
@ -1880,23 +1880,23 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
|
||||||
unsigned long vm_start, vm_end;
|
unsigned long vm_start, vm_end;
|
||||||
struct vm_area_struct *vma;
|
struct vm_area_struct *vma;
|
||||||
struct task_struct *task;
|
struct task_struct *task;
|
||||||
struct dentry *result;
|
int result;
|
||||||
struct mm_struct *mm;
|
struct mm_struct *mm;
|
||||||
|
|
||||||
result = ERR_PTR(-EPERM);
|
result = -EPERM;
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
result = ERR_PTR(-ENOENT);
|
result = -ENOENT;
|
||||||
task = get_proc_task(dir);
|
task = get_proc_task(dir);
|
||||||
if (!task)
|
if (!task)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
result = ERR_PTR(-EACCES);
|
result = -EACCES;
|
||||||
if (!ptrace_may_access(task, PTRACE_MODE_READ))
|
if (!ptrace_may_access(task, PTRACE_MODE_READ))
|
||||||
goto out_put_task;
|
goto out_put_task;
|
||||||
|
|
||||||
result = ERR_PTR(-ENOENT);
|
result = -ENOENT;
|
||||||
if (dname_to_vma_addr(dentry, &vm_start, &vm_end))
|
if (dname_to_vma_addr(dentry, &vm_start, &vm_end))
|
||||||
goto out_put_task;
|
goto out_put_task;
|
||||||
|
|
||||||
|
@ -1919,7 +1919,7 @@ out_no_vma:
|
||||||
out_put_task:
|
out_put_task:
|
||||||
put_task_struct(task);
|
put_task_struct(task);
|
||||||
out:
|
out:
|
||||||
return result;
|
return ERR_PTR(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct inode_operations proc_map_files_inode_operations = {
|
static const struct inode_operations proc_map_files_inode_operations = {
|
||||||
|
@ -2133,13 +2133,12 @@ static const struct file_operations proc_timers_operations = {
|
||||||
};
|
};
|
||||||
#endif /* CONFIG_CHECKPOINT_RESTORE */
|
#endif /* CONFIG_CHECKPOINT_RESTORE */
|
||||||
|
|
||||||
static struct dentry *proc_pident_instantiate(struct inode *dir,
|
static int proc_pident_instantiate(struct inode *dir,
|
||||||
struct dentry *dentry, struct task_struct *task, const void *ptr)
|
struct dentry *dentry, struct task_struct *task, const void *ptr)
|
||||||
{
|
{
|
||||||
const struct pid_entry *p = ptr;
|
const struct pid_entry *p = ptr;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct proc_inode *ei;
|
struct proc_inode *ei;
|
||||||
struct dentry *error = ERR_PTR(-ENOENT);
|
|
||||||
|
|
||||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||||
if (!inode)
|
if (!inode)
|
||||||
|
@ -2158,9 +2157,9 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,
|
||||||
d_add(dentry, inode);
|
d_add(dentry, inode);
|
||||||
/* Close the race of the process dying before we return the dentry */
|
/* Close the race of the process dying before we return the dentry */
|
||||||
if (pid_revalidate(dentry, 0))
|
if (pid_revalidate(dentry, 0))
|
||||||
error = NULL;
|
return 0;
|
||||||
out:
|
out:
|
||||||
return error;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dentry *proc_pident_lookup(struct inode *dir,
|
static struct dentry *proc_pident_lookup(struct inode *dir,
|
||||||
|
@ -2168,11 +2167,11 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
|
||||||
const struct pid_entry *ents,
|
const struct pid_entry *ents,
|
||||||
unsigned int nents)
|
unsigned int nents)
|
||||||
{
|
{
|
||||||
struct dentry *error;
|
int error;
|
||||||
struct task_struct *task = get_proc_task(dir);
|
struct task_struct *task = get_proc_task(dir);
|
||||||
const struct pid_entry *p, *last;
|
const struct pid_entry *p, *last;
|
||||||
|
|
||||||
error = ERR_PTR(-ENOENT);
|
error = -ENOENT;
|
||||||
|
|
||||||
if (!task)
|
if (!task)
|
||||||
goto out_no_task;
|
goto out_no_task;
|
||||||
|
@ -2195,7 +2194,7 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
|
||||||
out:
|
out:
|
||||||
put_task_struct(task);
|
put_task_struct(task);
|
||||||
out_no_task:
|
out_no_task:
|
||||||
return error;
|
return ERR_PTR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
|
static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
|
||||||
|
@ -2778,11 +2777,10 @@ void proc_flush_task(struct task_struct *task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dentry *proc_pid_instantiate(struct inode *dir,
|
static int proc_pid_instantiate(struct inode *dir,
|
||||||
struct dentry * dentry,
|
struct dentry * dentry,
|
||||||
struct task_struct *task, const void *ptr)
|
struct task_struct *task, const void *ptr)
|
||||||
{
|
{
|
||||||
struct dentry *error = ERR_PTR(-ENOENT);
|
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
|
|
||||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||||
|
@ -2802,14 +2800,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
|
||||||
d_add(dentry, inode);
|
d_add(dentry, inode);
|
||||||
/* Close the race of the process dying before we return the dentry */
|
/* Close the race of the process dying before we return the dentry */
|
||||||
if (pid_revalidate(dentry, 0))
|
if (pid_revalidate(dentry, 0))
|
||||||
error = NULL;
|
return 0;
|
||||||
out:
|
out:
|
||||||
return error;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
|
struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct dentry *result = NULL;
|
int result = 0;
|
||||||
struct task_struct *task;
|
struct task_struct *task;
|
||||||
unsigned tgid;
|
unsigned tgid;
|
||||||
struct pid_namespace *ns;
|
struct pid_namespace *ns;
|
||||||
|
@ -2830,7 +2828,7 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
|
||||||
result = proc_pid_instantiate(dir, dentry, task, NULL);
|
result = proc_pid_instantiate(dir, dentry, task, NULL);
|
||||||
put_task_struct(task);
|
put_task_struct(task);
|
||||||
out:
|
out:
|
||||||
return result;
|
return ERR_PTR(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3025,10 +3023,9 @@ static const struct inode_operations proc_tid_base_inode_operations = {
|
||||||
.setattr = proc_setattr,
|
.setattr = proc_setattr,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct dentry *proc_task_instantiate(struct inode *dir,
|
static int proc_task_instantiate(struct inode *dir,
|
||||||
struct dentry *dentry, struct task_struct *task, const void *ptr)
|
struct dentry *dentry, struct task_struct *task, const void *ptr)
|
||||||
{
|
{
|
||||||
struct dentry *error = ERR_PTR(-ENOENT);
|
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||||
|
|
||||||
|
@ -3047,14 +3044,14 @@ static struct dentry *proc_task_instantiate(struct inode *dir,
|
||||||
d_add(dentry, inode);
|
d_add(dentry, inode);
|
||||||
/* Close the race of the process dying before we return the dentry */
|
/* Close the race of the process dying before we return the dentry */
|
||||||
if (pid_revalidate(dentry, 0))
|
if (pid_revalidate(dentry, 0))
|
||||||
error = NULL;
|
return 0;
|
||||||
out:
|
out:
|
||||||
return error;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
|
static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct dentry *result = ERR_PTR(-ENOENT);
|
int result = -ENOENT;
|
||||||
struct task_struct *task;
|
struct task_struct *task;
|
||||||
struct task_struct *leader = get_proc_task(dir);
|
struct task_struct *leader = get_proc_task(dir);
|
||||||
unsigned tid;
|
unsigned tid;
|
||||||
|
@ -3084,7 +3081,7 @@ out_drop_task:
|
||||||
out:
|
out:
|
||||||
put_task_struct(leader);
|
put_task_struct(leader);
|
||||||
out_no_task:
|
out_no_task:
|
||||||
return result;
|
return ERR_PTR(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
18
fs/proc/fd.c
18
fs/proc/fd.c
|
@ -167,11 +167,10 @@ static int proc_fd_link(struct dentry *dentry, struct path *path)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dentry *
|
static int
|
||||||
proc_fd_instantiate(struct inode *dir, struct dentry *dentry,
|
proc_fd_instantiate(struct inode *dir, struct dentry *dentry,
|
||||||
struct task_struct *task, const void *ptr)
|
struct task_struct *task, const void *ptr)
|
||||||
{
|
{
|
||||||
struct dentry *error = ERR_PTR(-ENOENT);
|
|
||||||
unsigned fd = (unsigned long)ptr;
|
unsigned fd = (unsigned long)ptr;
|
||||||
struct proc_inode *ei;
|
struct proc_inode *ei;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
|
@ -194,9 +193,9 @@ proc_fd_instantiate(struct inode *dir, struct dentry *dentry,
|
||||||
|
|
||||||
/* Close the race of the process dying before we return the dentry */
|
/* Close the race of the process dying before we return the dentry */
|
||||||
if (tid_fd_revalidate(dentry, 0))
|
if (tid_fd_revalidate(dentry, 0))
|
||||||
error = NULL;
|
return 0;
|
||||||
out:
|
out:
|
||||||
return error;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dentry *proc_lookupfd_common(struct inode *dir,
|
static struct dentry *proc_lookupfd_common(struct inode *dir,
|
||||||
|
@ -204,7 +203,7 @@ static struct dentry *proc_lookupfd_common(struct inode *dir,
|
||||||
instantiate_t instantiate)
|
instantiate_t instantiate)
|
||||||
{
|
{
|
||||||
struct task_struct *task = get_proc_task(dir);
|
struct task_struct *task = get_proc_task(dir);
|
||||||
struct dentry *result = ERR_PTR(-ENOENT);
|
int result = -ENOENT;
|
||||||
unsigned fd = name_to_int(dentry);
|
unsigned fd = name_to_int(dentry);
|
||||||
|
|
||||||
if (!task)
|
if (!task)
|
||||||
|
@ -216,7 +215,7 @@ static struct dentry *proc_lookupfd_common(struct inode *dir,
|
||||||
out:
|
out:
|
||||||
put_task_struct(task);
|
put_task_struct(task);
|
||||||
out_no_task:
|
out_no_task:
|
||||||
return result;
|
return ERR_PTR(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int proc_readfd_common(struct file *file, struct dir_context *ctx,
|
static int proc_readfd_common(struct file *file, struct dir_context *ctx,
|
||||||
|
@ -300,11 +299,10 @@ const struct inode_operations proc_fd_inode_operations = {
|
||||||
.setattr = proc_setattr,
|
.setattr = proc_setattr,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct dentry *
|
static int
|
||||||
proc_fdinfo_instantiate(struct inode *dir, struct dentry *dentry,
|
proc_fdinfo_instantiate(struct inode *dir, struct dentry *dentry,
|
||||||
struct task_struct *task, const void *ptr)
|
struct task_struct *task, const void *ptr)
|
||||||
{
|
{
|
||||||
struct dentry *error = ERR_PTR(-ENOENT);
|
|
||||||
unsigned fd = (unsigned long)ptr;
|
unsigned fd = (unsigned long)ptr;
|
||||||
struct proc_inode *ei;
|
struct proc_inode *ei;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
|
@ -324,9 +322,9 @@ proc_fdinfo_instantiate(struct inode *dir, struct dentry *dentry,
|
||||||
|
|
||||||
/* Close the race of the process dying before we return the dentry */
|
/* Close the race of the process dying before we return the dentry */
|
||||||
if (tid_fd_revalidate(dentry, 0))
|
if (tid_fd_revalidate(dentry, 0))
|
||||||
error = NULL;
|
return 0;
|
||||||
out:
|
out:
|
||||||
return error;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dentry *
|
static struct dentry *
|
||||||
|
|
|
@ -170,7 +170,7 @@ extern struct dentry *proc_pid_lookup(struct inode *, struct dentry *, unsigned
|
||||||
extern loff_t mem_lseek(struct file *, loff_t, int);
|
extern loff_t mem_lseek(struct file *, loff_t, int);
|
||||||
|
|
||||||
/* Lookups */
|
/* Lookups */
|
||||||
typedef struct dentry *instantiate_t(struct inode *, struct dentry *,
|
typedef int instantiate_t(struct inode *, struct dentry *,
|
||||||
struct task_struct *, const void *);
|
struct task_struct *, const void *);
|
||||||
extern bool proc_fill_cache(struct file *, struct dir_context *, const char *, int,
|
extern bool proc_fill_cache(struct file *, struct dir_context *, const char *, int,
|
||||||
instantiate_t, struct task_struct *, const void *);
|
instantiate_t, struct task_struct *, const void *);
|
||||||
|
|
|
@ -187,13 +187,12 @@ static const struct inode_operations proc_ns_link_inode_operations = {
|
||||||
.setattr = proc_setattr,
|
.setattr = proc_setattr,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct dentry *proc_ns_instantiate(struct inode *dir,
|
static int proc_ns_instantiate(struct inode *dir,
|
||||||
struct dentry *dentry, struct task_struct *task, const void *ptr)
|
struct dentry *dentry, struct task_struct *task, const void *ptr)
|
||||||
{
|
{
|
||||||
const struct proc_ns_operations *ns_ops = ptr;
|
const struct proc_ns_operations *ns_ops = ptr;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct proc_inode *ei;
|
struct proc_inode *ei;
|
||||||
struct dentry *error = ERR_PTR(-ENOENT);
|
|
||||||
|
|
||||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||||
if (!inode)
|
if (!inode)
|
||||||
|
@ -208,9 +207,9 @@ static struct dentry *proc_ns_instantiate(struct inode *dir,
|
||||||
d_add(dentry, inode);
|
d_add(dentry, inode);
|
||||||
/* Close the race of the process dying before we return the dentry */
|
/* Close the race of the process dying before we return the dentry */
|
||||||
if (pid_revalidate(dentry, 0))
|
if (pid_revalidate(dentry, 0))
|
||||||
error = NULL;
|
return 0;
|
||||||
out:
|
out:
|
||||||
return error;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int proc_ns_dir_readdir(struct file *file, struct dir_context *ctx)
|
static int proc_ns_dir_readdir(struct file *file, struct dir_context *ctx)
|
||||||
|
@ -248,12 +247,12 @@ const struct file_operations proc_ns_dir_operations = {
|
||||||
static struct dentry *proc_ns_dir_lookup(struct inode *dir,
|
static struct dentry *proc_ns_dir_lookup(struct inode *dir,
|
||||||
struct dentry *dentry, unsigned int flags)
|
struct dentry *dentry, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct dentry *error;
|
int error;
|
||||||
struct task_struct *task = get_proc_task(dir);
|
struct task_struct *task = get_proc_task(dir);
|
||||||
const struct proc_ns_operations **entry, **last;
|
const struct proc_ns_operations **entry, **last;
|
||||||
unsigned int len = dentry->d_name.len;
|
unsigned int len = dentry->d_name.len;
|
||||||
|
|
||||||
error = ERR_PTR(-ENOENT);
|
error = -ENOENT;
|
||||||
|
|
||||||
if (!task)
|
if (!task)
|
||||||
goto out_no_task;
|
goto out_no_task;
|
||||||
|
@ -272,7 +271,7 @@ static struct dentry *proc_ns_dir_lookup(struct inode *dir,
|
||||||
out:
|
out:
|
||||||
put_task_struct(task);
|
put_task_struct(task);
|
||||||
out_no_task:
|
out_no_task:
|
||||||
return error;
|
return ERR_PTR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct inode_operations proc_ns_dir_inode_operations = {
|
const struct inode_operations proc_ns_dir_inode_operations = {
|
||||||
|
|
Loading…
Reference in New Issue