mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 20:32:04 +09:00
procfs: fix race between symlink removals and traversals
commit 7e0e953bb0 upstream.
use_pde()/unuse_pde() in ->follow_link()/->put_link() resp.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
db32c77427
commit
cf6c05a77c
@@ -19,7 +19,6 @@
|
||||
#include <linux/mount.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/namei.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/completion.h>
|
||||
@@ -163,17 +162,6 @@ void proc_free_inum(unsigned int inum)
|
||||
spin_unlock_irqrestore(&proc_inum_lock, flags);
|
||||
}
|
||||
|
||||
static void *proc_follow_link(struct dentry *dentry, struct nameidata *nd)
|
||||
{
|
||||
nd_set_link(nd, __PDE_DATA(dentry->d_inode));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const struct inode_operations proc_link_inode_operations = {
|
||||
.readlink = generic_readlink,
|
||||
.follow_link = proc_follow_link,
|
||||
};
|
||||
|
||||
/*
|
||||
* As some entries in /proc are volatile, we want to
|
||||
* get rid of unused dentries. This could be made
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/mount.h>
|
||||
#include <linux/magic.h>
|
||||
#include <linux/namei.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
@@ -373,6 +374,26 @@ static const struct file_operations proc_reg_file_ops_no_compat = {
|
||||
};
|
||||
#endif
|
||||
|
||||
static void *proc_follow_link(struct dentry *dentry, struct nameidata *nd)
|
||||
{
|
||||
struct proc_dir_entry *pde = PDE(dentry->d_inode);
|
||||
if (unlikely(!use_pde(pde)))
|
||||
return ERR_PTR(-EINVAL);
|
||||
nd_set_link(nd, pde->data);
|
||||
return pde;
|
||||
}
|
||||
|
||||
static void proc_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
|
||||
{
|
||||
unuse_pde(p);
|
||||
}
|
||||
|
||||
const struct inode_operations proc_link_inode_operations = {
|
||||
.readlink = generic_readlink,
|
||||
.follow_link = proc_follow_link,
|
||||
.put_link = proc_put_link,
|
||||
};
|
||||
|
||||
struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
|
||||
{
|
||||
struct inode *inode = new_inode_pseudo(sb);
|
||||
|
||||
@@ -202,6 +202,7 @@ struct pde_opener {
|
||||
int closing;
|
||||
struct completion *c;
|
||||
};
|
||||
extern const struct inode_operations proc_link_inode_operations;
|
||||
|
||||
extern const struct inode_operations proc_pid_link_inode_operations;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user