Commit 18a22227 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by James Toy

The patch

  "vfs: fix d_path() for unreachable paths"

generally changed d_path() to report unreachable paths with a special
prefix.  This has an effect on /proc/${PID}/maps as well for memory maps
set up with shmem_file_setup() or hugetlb_file_setup().  These functions
set up unlinked files under a kernel-private vfsmount.  Since this
vfsmount is unreachable from userspace, these maps will be reported with
the "(unreachable)" prefix.

This is undesirable, because it changes the kernel ABI and might break
applications for no good reason.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Acked-by: default avatarHugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Andreas Gruenbacher <agruen@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 6dc1faec
......@@ -906,6 +906,21 @@ static struct file_system_type hugetlbfs_fs_type = {
static struct vfsmount *hugetlbfs_vfsmount;
/*
* Do a special d_dname function so that these are not prefixed by
* "(unreachable)".
*/
static char *hugetlb_unlinked_d_dname(struct dentry *dentry, char *buf,
int buflen)
{
return dynamic_dname(dentry, buf, buflen, "/%s (deleted)",
dentry->d_name.name);
}
static struct dentry_operations hugetlb_unlinked_dentry_operations = {
.d_dname = hugetlb_unlinked_d_dname,
};
static int can_do_hugetlb_shm(void)
{
return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group);
......@@ -943,6 +958,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
if (!dentry)
goto out_shm_unlock;
dentry->d_op = &hugetlb_unlinked_dentry_operations;
error = -ENOSPC;
inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(),
current_fsgid(), S_IFREG | S_IRWXUGO, 0);
......
......@@ -2604,6 +2604,21 @@ int shmem_unuse(swp_entry_t entry, struct page *page)
/* common code */
/*
* Do a special d_dname function so that these are not prefixed by
* "(unreachable)".
*/
static char *shmem_unlinked_d_dname(struct dentry *dentry, char *buf,
int buflen)
{
return dynamic_dname(dentry, buf, buflen, "/%s (deleted)",
dentry->d_name.name);
}
static struct dentry_operations shmem_unlinked_dentry_operations = {
.d_dname = shmem_unlinked_d_dname,
};
/**
* shmem_file_setup - get an unlinked file living in tmpfs
* @name: name for dentry (to be seen in /proc/<pid>/maps
......@@ -2636,6 +2651,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
if (!dentry)
goto put_memory;
dentry->d_op = &shmem_unlinked_dentry_operations;
error = -ENFILE;
file = get_empty_filp();
if (!file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment