Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1481913 > unrolled thread
| Started by | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| First post | 2016-09-12 21:40 +0200 |
| Last post | 2016-09-12 21:40 +0200 |
| Articles | 9 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 00/17] clean up readlinks Miklos Szeredi <mszeredi@redhat.com> - 2016-09-12 21:40 +0200
[PATCH 08/17] proc: merge proc_pid_readlink() into proc_pid_get_link() Miklos Szeredi <mszeredi@redhat.com> - 2016-09-12 21:40 +0200
[PATCH 15/17] vfs: add vfs_get_link() helper Miklos Szeredi <mszeredi@redhat.com> - 2016-09-12 21:40 +0200
[PATCH 09/17] proc: merge proc_ns_readlink() into proc_ns_get_link() Miklos Szeredi <mszeredi@redhat.com> - 2016-09-12 21:40 +0200
[PATCH 04/17] afs: use generic_readlink Miklos Szeredi <mszeredi@redhat.com> - 2016-09-12 21:40 +0200
[PATCH 12/17] vfs: remove ".readlink = generic_readlink" assignments Miklos Szeredi <mszeredi@redhat.com> - 2016-09-12 21:40 +0200
[PATCH 06/17] vfs: remove page_readlink() Miklos Szeredi <mszeredi@redhat.com> - 2016-09-12 21:40 +0200
[PATCH 03/17] proc/self: use generic_readlink Miklos Szeredi <mszeredi@redhat.com> - 2016-09-12 21:40 +0200
[PATCH 16/17] ovl: use vfs_get_link() Miklos Szeredi <mszeredi@redhat.com> - 2016-09-12 21:40 +0200
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-09-12 21:40 +0200 |
| Subject | [PATCH 00/17] clean up readlinks |
| Message-ID | <sgF5v-7Bx-3@gated-at.bofh.it> |
The first patch is actually a bug fix, but I put it into this bunch for simplicity... The rest are really cleanups as well as minor bugfixes that are byproducts of the cleanups. This series builds on the fact that i_op.readlink is already set to generic_readlink() in 43/50 of the cases. And of those 7 only 4 are doing something special. So more than 90% of readlinks are/could actually just call back into get_link. The interesting cases are: - AFS, which has readlink but not get_link - proc, that allow jumping while following symlinks The first is handled by setting IOP_NOFOLLOW on the inode by the fs. The second one is handled by introducing is_following_link() which returns a bool depending on whether current->nameidata is NULL or not. If it returns false ->get_link() should behave as ->readlink() did. Otherwise it should behave as id did previously. Builds and boots. Can even read symlinks. Git tree is here: git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git readlink Thanks, Miklos --- Miklos Szeredi (17): bad_inode: add missing i_op initializers ovl: use generic_readlink proc/self: use generic_readlink afs: use generic_readlink bad_inode: use generic_readlink vfs: remove page_readlink() vfs: add is_following_link() helper proc: merge proc_pid_readlink() into proc_pid_get_link() proc: merge proc_ns_readlink() into proc_ns_get_link() nsfs: clean up ns_get_name() interface vfs: replace calling i_op->readlink with vfs_readlink() vfs: remove ".readlink = generic_readlink" assignments vfs: remove unused i_op->readlink vfs: remove unused generic_readlink() vfs: add vfs_get_link() helper ovl: use vfs_get_link() ecryptfs: use vfs_get_link() Documentation/filesystems/Locking | 2 - Documentation/filesystems/porting | 15 +++++ Documentation/filesystems/vfs.txt | 25 ++++---- drivers/staging/lustre/lustre/llite/symlink.c | 1 - fs/9p/vfs_inode.c | 1 - fs/9p/vfs_inode_dotl.c | 1 - fs/affs/symlink.c | 1 - fs/afs/inode.c | 2 + fs/afs/mntpt.c | 2 +- fs/autofs4/symlink.c | 1 - fs/bad_inode.c | 62 ++++++++++++++++---- fs/btrfs/inode.c | 1 - fs/ceph/inode.c | 1 - fs/cifs/cifsfs.c | 1 - fs/coda/cnode.c | 1 - fs/configfs/symlink.c | 1 - fs/ecryptfs/inode.c | 30 ++++------ fs/ext2/symlink.c | 2 - fs/ext4/symlink.c | 3 - fs/f2fs/namei.c | 2 - fs/fuse/dir.c | 1 - fs/gfs2/inode.c | 1 - fs/hostfs/hostfs_kern.c | 1 - fs/jffs2/symlink.c | 1 - fs/jfs/symlink.c | 2 - fs/kernfs/symlink.c | 1 - fs/libfs.c | 1 - fs/minix/inode.c | 1 - fs/namei.c | 82 ++++++++++++++++++++------- fs/ncpfs/inode.c | 1 - fs/nfs/symlink.c | 1 - fs/nfsd/nfs4xdr.c | 8 +-- fs/nfsd/vfs.c | 4 +- fs/nilfs2/namei.c | 1 - fs/nsfs.c | 17 ++++-- fs/ocfs2/symlink.c | 1 - fs/orangefs/symlink.c | 1 - fs/overlayfs/copy_up.c | 46 ++------------- fs/overlayfs/inode.c | 25 +------- fs/proc/base.c | 66 +++++++-------------- fs/proc/inode.c | 1 - fs/proc/namespaces.c | 41 +++++--------- fs/proc/self.c | 13 ----- fs/proc/thread_self.c | 14 ----- fs/reiserfs/namei.c | 1 - fs/squashfs/symlink.c | 1 - fs/stat.c | 5 +- fs/sysv/inode.c | 1 - fs/ubifs/file.c | 1 - fs/xfs/xfs_ioctl.c | 4 +- fs/xfs/xfs_iops.c | 2 - include/linux/fs.h | 9 ++- include/linux/namei.h | 1 + include/linux/proc_ns.h | 4 +- mm/shmem.c | 2 - 55 files changed, 226 insertions(+), 291 deletions(-) -- 2.5.5
[toc] | [next] | [standalone]
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-09-12 21:40 +0200 |
| Subject | [PATCH 08/17] proc: merge proc_pid_readlink() into proc_pid_get_link() |
| Message-ID | <sgFfc-7H4-37@gated-at.bofh.it> |
| In reply to | #1481913 |
This will allow us to move the generic readlink logic into the VFS and get
rid of the readlink method.
And it's a cleanup, removing more lines than it adds, since the two
functions have a lot in common.
/proc/$$/map_files/A allowed reading the symlink with the normal proc
permission checks, but following only allowed for CAP_SYS_ADMIN capable
tasks. So in proc_map_files_get_link() check for is_following_link()
before bailing out if not CAP_SYS_ADMIN capable.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/proc/base.c | 68 ++++++++++++++++++----------------------------------------
1 file changed, 21 insertions(+), 47 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index ac0df4dde823..84769c763afe 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1578,6 +1578,7 @@ static const char *proc_pid_get_link(struct dentry *dentry,
{
struct path path;
int error = -EACCES;
+ char *res;
if (!dentry)
return ERR_PTR(-ECHILD);
@@ -1590,58 +1591,31 @@ static const char *proc_pid_get_link(struct dentry *dentry,
if (error)
goto out;
- nd_jump_link(&path);
- return NULL;
-out:
- return ERR_PTR(error);
-}
-
-static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
-{
- char *tmp = (char*)__get_free_page(GFP_TEMPORARY);
- char *pathname;
- int len;
-
- if (!tmp)
- return -ENOMEM;
-
- pathname = d_path(path, tmp, PAGE_SIZE);
- len = PTR_ERR(pathname);
- if (IS_ERR(pathname))
- goto out;
- len = tmp + PAGE_SIZE - 1 - pathname;
-
- if (len > buflen)
- len = buflen;
- if (copy_to_user(buffer, pathname, len))
- len = -EFAULT;
- out:
- free_page((unsigned long)tmp);
- return len;
-}
-
-static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int buflen)
-{
- int error = -EACCES;
- struct inode *inode = d_inode(dentry);
- struct path path;
+ if (is_following_link()) {
+ nd_jump_link(&path);
+ res = NULL;
+ } else {
+ char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- /* Are we allowed to snoop on the tasks file descriptors? */
- if (!proc_fd_access_allowed(inode))
- goto out;
+ error = -ENOMEM;
+ if (!buf)
+ goto out;
- error = PROC_I(inode)->op.proc_get_link(dentry, &path);
- if (error)
- goto out;
+ res = d_path(&path, buf, PAGE_SIZE);
+ if (IS_ERR(res))
+ kfree(buf);
+ else
+ set_delayed_call(done, kfree_link, buf);
+ }
+ return res;
- error = do_proc_readlink(&path, buffer, buflen);
- path_put(&path);
out:
- return error;
+ return ERR_PTR(error);
}
+
const struct inode_operations proc_pid_link_inode_operations = {
- .readlink = proc_pid_readlink,
+ .readlink = generic_readlink,
.get_link = proc_pid_get_link,
.setattr = proc_setattr,
};
@@ -1966,7 +1940,7 @@ proc_map_files_get_link(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
{
- if (!capable(CAP_SYS_ADMIN))
+ if (is_following_link() && !capable(CAP_SYS_ADMIN))
return ERR_PTR(-EPERM);
return proc_pid_get_link(dentry, inode, done);
@@ -1976,7 +1950,7 @@ proc_map_files_get_link(struct dentry *dentry,
* Identical to proc_pid_link_inode_operations except for get_link()
*/
static const struct inode_operations proc_map_files_link_inode_operations = {
- .readlink = proc_pid_readlink,
+ .readlink = generic_readlink,
.get_link = proc_map_files_get_link,
.setattr = proc_setattr,
};
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-09-12 21:40 +0200 |
| Subject | [PATCH 15/17] vfs: add vfs_get_link() helper |
| Message-ID | <sgFfc-7H4-31@gated-at.bofh.it> |
| In reply to | #1481913 |
This helper is for filesystems that want to read the symlink and are better
off with the get_link() interface (returning a char *) rather than the
readlink() interface (copy into a userspace buffer).
Also call the LSM hook for readlink (not get_link) since this is for
symlink reading not following.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/namei.c | 47 ++++++++++++++++++++++++++++++++++++++++++-----
include/linux/fs.h | 2 ++
2 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index 76d1f061de3c..23c3fb8cec0a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4659,6 +4659,47 @@ out:
return len;
}
+static const char *do_get_link(struct dentry *dentry, struct inode *inode,
+ struct delayed_call *done)
+{
+ const char *link = inode->i_op->get_link(dentry, inode, done);
+
+ /* "jumping" is unacceptable, warn and return error */
+ if (!IS_ERR(link) && WARN_ON_ONCE(!link))
+ link = ERR_PTR(-EIO);
+
+ return link;
+}
+
+/**
+ * vfs_get_link - get symbolic link
+ * @dentry: dentry
+ * @inode: inode on which to get symbolic link
+ * @done: caller needs to free returned data with this
+ *
+ * Calls security hook and i_op->get_link() on the supplied inode.
+ *
+ * It does not touch atime. That's up to the caller if necessary.
+ *
+ * Don't call this from RCU lookup mode (yet)
+ */
+const char *vfs_get_link(struct dentry *dentry, struct inode *inode,
+ struct delayed_call *done)
+{
+ const char *res = ERR_PTR(-EINVAL);
+
+ if (inode->i_op->get_link) {
+ int error = security_inode_readlink(dentry);
+
+ res = ERR_PTR(error);
+ if (!error)
+ res = do_get_link(dentry, inode, done);
+ }
+
+ return res;
+}
+EXPORT_SYMBOL(vfs_get_link);
+
/**
* vfs_readlink - read symlink body
* @dentry: read symlink from this dentry
@@ -4682,13 +4723,9 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen)
int res;
if (!link) {
- link = inode->i_op->get_link(dentry, inode, &done);
+ link = do_get_link(dentry, inode, &done);
if (IS_ERR(link))
return PTR_ERR(link);
-
- /* "jumping" is unacceptable, warn and return error */
- if (WARN_ON_ONCE(!link))
- return -EIO;
}
res = readlink_copy(buffer, buflen, link);
do_delayed_call(&done);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f71e70e3017b..58f42e979b12 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2916,6 +2916,8 @@ extern int vfs_fstat(unsigned int, struct kstat *);
extern int vfs_fstatat(int , const char __user *, struct kstat *, int);
extern int vfs_readlink(struct dentry *, char __user *, int);
+extern const char *vfs_get_link(struct dentry *, struct inode *,
+ struct delayed_call *);
extern int __generic_block_fiemap(struct inode *inode,
struct fiemap_extent_info *fieinfo,
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-09-12 21:40 +0200 |
| Subject | [PATCH 09/17] proc: merge proc_ns_readlink() into proc_ns_get_link() |
| Message-ID | <sgFfd-7H4-53@gated-at.bofh.it> |
| In reply to | #1481913 |
This will allow us to move the generic readlink logic into the VFS and get
rid of the readlink method.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/proc/namespaces.c | 56 +++++++++++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 27 deletions(-)
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 51b8b0a8ad91..9c9a1683791a 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -33,6 +33,8 @@ static const struct proc_ns_operations *ns_entries[] = {
#endif
};
+#define PROC_NS_LINK_MAX 50
+
static const char *proc_ns_get_link(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
@@ -40,47 +42,47 @@ static const char *proc_ns_get_link(struct dentry *dentry,
const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops;
struct task_struct *task;
struct path ns_path;
- void *error = ERR_PTR(-EACCES);
+ char *res = ERR_PTR(-EACCES);
if (!dentry)
return ERR_PTR(-ECHILD);
task = get_proc_task(inode);
if (!task)
- return error;
-
- if (ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) {
- error = ns_get_path(&ns_path, task, ns_ops);
- if (!error)
- nd_jump_link(&ns_path);
- }
- put_task_struct(task);
- return error;
-}
-
-static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int buflen)
-{
- struct inode *inode = d_inode(dentry);
- const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops;
- struct task_struct *task;
- char name[50];
- int res = -EACCES;
+ goto out;
- task = get_proc_task(inode);
- if (!task)
- return res;
+ if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS))
+ goto out_put;
- if (ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) {
- res = ns_get_name(name, sizeof(name), task, ns_ops);
- if (res >= 0)
- res = readlink_copy(buffer, buflen, name);
+ if (is_following_link()) {
+ res = ns_get_path(&ns_path, task, ns_ops);
+ if (!res)
+ nd_jump_link(&ns_path);
+ } else {
+ char *name = kmalloc(PROC_NS_LINK_MAX, GFP_KERNEL);
+ int err;
+
+ res = ERR_PTR(-ENOMEM);
+ if (!name)
+ goto out_put;
+
+ err = ns_get_name(name, PROC_NS_LINK_MAX, task, ns_ops);
+ if (err < 0) {
+ kfree(name);
+ res = ERR_PTR(err);
+ goto out_put;
+ }
+ set_delayed_call(done, kfree_link, name);
+ res = name;
}
+out_put:
put_task_struct(task);
+out:
return res;
}
static const struct inode_operations proc_ns_link_inode_operations = {
- .readlink = proc_ns_readlink,
+ .readlink = generic_readlink,
.get_link = proc_ns_get_link,
.setattr = proc_setattr,
};
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-09-12 21:40 +0200 |
| Subject | [PATCH 04/17] afs: use generic_readlink |
| Message-ID | <sgFfd-7H4-63@gated-at.bofh.it> |
| In reply to | #1481913 |
This will allow us to move the generic readlink logic into the VFS and get
rid of the readlink method.
AFS mountpoints seem to be special symlinks that can be read but not
followed. So add IOP_NOFOLLOW to i_opflags and use page_get_link +
generic_readlink instead of page_readlink.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Cc: David Howells <dhowells@redhat.com>
---
fs/afs/inode.c | 2 ++
fs/afs/mntpt.c | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 86cc7264c21c..56709b2c46e3 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -88,6 +88,8 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key)
inode->i_mode = S_IFDIR | vnode->status.mode;
inode->i_op = &afs_mntpt_inode_operations;
inode->i_fop = &afs_mntpt_file_operations;
+ /* Not a real symlink, don't follow */
+ inode->i_opflags |= IOP_NOFOLLOW;
}
}
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index 81dd075356b9..7d170de2ce1b 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -33,7 +33,8 @@ const struct file_operations afs_mntpt_file_operations = {
const struct inode_operations afs_mntpt_inode_operations = {
.lookup = afs_mntpt_lookup,
- .readlink = page_readlink,
+ .get_link = page_get_link,
+ .readlink = generic_readlink,
.getattr = afs_getattr,
};
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-09-12 21:40 +0200 |
| Subject | [PATCH 12/17] vfs: remove ".readlink = generic_readlink" assignments |
| Message-ID | <sgFfd-7H4-55@gated-at.bofh.it> |
| In reply to | #1481913 |
i_op->readlink is never called now, we can get rid of it. This is the
first part, getting rid of the assignments.
Generated by:
to_del="\.readlink.*=.*generic_readlink"
for i in `git grep -l $to_del`; do sed -i "/$to_del"/d $i; done
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
drivers/staging/lustre/lustre/llite/symlink.c | 1 -
fs/9p/vfs_inode.c | 1 -
fs/9p/vfs_inode_dotl.c | 1 -
fs/affs/symlink.c | 1 -
fs/afs/mntpt.c | 1 -
fs/autofs4/symlink.c | 1 -
fs/bad_inode.c | 1 -
fs/btrfs/inode.c | 1 -
fs/ceph/inode.c | 1 -
fs/cifs/cifsfs.c | 1 -
fs/coda/cnode.c | 1 -
fs/configfs/symlink.c | 1 -
fs/ecryptfs/inode.c | 1 -
fs/ext2/symlink.c | 2 --
fs/ext4/symlink.c | 3 ---
fs/f2fs/namei.c | 2 --
fs/fuse/dir.c | 1 -
fs/gfs2/inode.c | 1 -
fs/hostfs/hostfs_kern.c | 1 -
fs/jffs2/symlink.c | 1 -
fs/jfs/symlink.c | 2 --
fs/kernfs/symlink.c | 1 -
fs/libfs.c | 1 -
fs/minix/inode.c | 1 -
fs/namei.c | 1 -
fs/ncpfs/inode.c | 1 -
fs/nfs/symlink.c | 1 -
fs/nilfs2/namei.c | 1 -
fs/ocfs2/symlink.c | 1 -
fs/orangefs/symlink.c | 1 -
fs/overlayfs/inode.c | 1 -
fs/proc/base.c | 2 --
fs/proc/inode.c | 1 -
fs/proc/namespaces.c | 1 -
fs/proc/self.c | 1 -
fs/proc/thread_self.c | 1 -
fs/reiserfs/namei.c | 1 -
fs/squashfs/symlink.c | 1 -
fs/sysv/inode.c | 1 -
fs/ubifs/file.c | 1 -
fs/xfs/xfs_iops.c | 2 --
mm/shmem.c | 2 --
42 files changed, 50 deletions(-)
diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c
index 8c8bdfe1ad71..48d37dce3229 100644
--- a/drivers/staging/lustre/lustre/llite/symlink.c
+++ b/drivers/staging/lustre/lustre/llite/symlink.c
@@ -150,7 +150,6 @@ static const char *ll_get_link(struct dentry *dentry,
}
const struct inode_operations ll_fast_symlink_inode_operations = {
- .readlink = generic_readlink,
.setattr = ll_setattr,
.get_link = ll_get_link,
.getattr = ll_getattr,
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 8b1999b528e9..a76d61bc809a 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1460,7 +1460,6 @@ static const struct inode_operations v9fs_file_inode_operations = {
};
static const struct inode_operations v9fs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = v9fs_vfs_get_link,
.getattr = v9fs_vfs_getattr,
.setattr = v9fs_vfs_setattr,
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index eeabcb0bad12..cee0e43f350b 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -985,7 +985,6 @@ const struct inode_operations v9fs_file_inode_operations_dotl = {
};
const struct inode_operations v9fs_symlink_inode_operations_dotl = {
- .readlink = generic_readlink,
.get_link = v9fs_vfs_get_link_dotl,
.getattr = v9fs_vfs_getattr_dotl,
.setattr = v9fs_vfs_setattr_dotl,
diff --git a/fs/affs/symlink.c b/fs/affs/symlink.c
index 69b03dbb792f..ae622cdce142 100644
--- a/fs/affs/symlink.c
+++ b/fs/affs/symlink.c
@@ -70,7 +70,6 @@ const struct address_space_operations affs_symlink_aops = {
};
const struct inode_operations affs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.setattr = affs_notify_change,
};
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index 7d170de2ce1b..8211b5ecae94 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -34,7 +34,6 @@ const struct file_operations afs_mntpt_file_operations = {
const struct inode_operations afs_mntpt_inode_operations = {
.lookup = afs_mntpt_lookup,
.get_link = page_get_link,
- .readlink = generic_readlink,
.getattr = afs_getattr,
};
diff --git a/fs/autofs4/symlink.c b/fs/autofs4/symlink.c
index 99aab00dc217..ab0b4285a202 100644
--- a/fs/autofs4/symlink.c
+++ b/fs/autofs4/symlink.c
@@ -25,6 +25,5 @@ static const char *autofs4_get_link(struct dentry *dentry,
}
const struct inode_operations autofs4_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = autofs4_get_link
};
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 7cf1f445fe04..9475e9b4a85c 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -172,7 +172,6 @@ static const struct inode_operations bad_inode_ops =
.rmdir = bad_inode_rmdir,
.mknod = bad_inode_mknod,
.rename2 = bad_inode_rename2,
- .readlink = generic_readlink,
.permission = bad_inode_permission,
.getattr = bad_inode_getattr,
.setattr = bad_inode_setattr,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e6811c42e41e..fe1f416a4cad 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -10670,7 +10670,6 @@ static const struct inode_operations btrfs_special_inode_operations = {
.update_time = btrfs_update_time,
};
static const struct inode_operations btrfs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.getattr = btrfs_getattr,
.setattr = btrfs_setattr,
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index dd3a6dbf71eb..76482fa1a500 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1881,7 +1881,6 @@ retry:
* symlinks
*/
static const struct inode_operations ceph_symlink_iops = {
- .readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = ceph_setattr,
.getattr = ceph_getattr,
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 6bbec5e784cd..cb164ef84335 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -923,7 +923,6 @@ const struct inode_operations cifs_file_inode_ops = {
};
const struct inode_operations cifs_symlink_inode_ops = {
- .readlink = generic_readlink,
.get_link = cifs_get_link,
.permission = cifs_permission,
.setxattr = generic_setxattr,
diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c
index 1bfb7ba4e85e..f13e09057c6b 100644
--- a/fs/coda/cnode.c
+++ b/fs/coda/cnode.c
@@ -17,7 +17,6 @@ static inline int coda_fideq(struct CodaFid *fid1, struct CodaFid *fid2)
}
static const struct inode_operations coda_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.setattr = coda_setattr,
};
diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c
index db6d69289608..a6ab012a2c6a 100644
--- a/fs/configfs/symlink.c
+++ b/fs/configfs/symlink.c
@@ -305,7 +305,6 @@ static const char *configfs_get_link(struct dentry *dentry,
const struct inode_operations configfs_symlink_inode_operations = {
.get_link = configfs_get_link,
- .readlink = generic_readlink,
.setattr = configfs_setattr,
};
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 9885a8f88260..fb2d831b7030 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1082,7 +1082,6 @@ out:
}
const struct inode_operations ecryptfs_symlink_iops = {
- .readlink = generic_readlink,
.get_link = ecryptfs_get_link,
.permission = ecryptfs_permission,
.setattr = ecryptfs_setattr,
diff --git a/fs/ext2/symlink.c b/fs/ext2/symlink.c
index 3495d8ae4b33..b77bb8198bb9 100644
--- a/fs/ext2/symlink.c
+++ b/fs/ext2/symlink.c
@@ -21,7 +21,6 @@
#include "xattr.h"
const struct inode_operations ext2_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.setattr = ext2_setattr,
#ifdef CONFIG_EXT2_FS_XATTR
@@ -33,7 +32,6 @@ const struct inode_operations ext2_symlink_inode_operations = {
};
const struct inode_operations ext2_fast_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = ext2_setattr,
#ifdef CONFIG_EXT2_FS_XATTR
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
index 4d83d9e05f2e..96ab1e69e8ad 100644
--- a/fs/ext4/symlink.c
+++ b/fs/ext4/symlink.c
@@ -87,7 +87,6 @@ errout:
}
const struct inode_operations ext4_encrypted_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = ext4_encrypted_get_link,
.setattr = ext4_setattr,
.setxattr = generic_setxattr,
@@ -97,7 +96,6 @@ const struct inode_operations ext4_encrypted_symlink_inode_operations = {
};
const struct inode_operations ext4_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.setattr = ext4_setattr,
.setxattr = generic_setxattr,
@@ -107,7 +105,6 @@ const struct inode_operations ext4_symlink_inode_operations = {
};
const struct inode_operations ext4_fast_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = ext4_setattr,
.setxattr = generic_setxattr,
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 73fa356f8fbb..c19de60dee5d 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -1072,7 +1072,6 @@ errout:
}
const struct inode_operations f2fs_encrypted_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = f2fs_encrypted_get_link,
.getattr = f2fs_getattr,
.setattr = f2fs_setattr,
@@ -1108,7 +1107,6 @@ const struct inode_operations f2fs_dir_inode_operations = {
};
const struct inode_operations f2fs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = f2fs_get_link,
.getattr = f2fs_getattr,
.setattr = f2fs_setattr,
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index c47b7780ce37..5e18012fd662 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1914,7 +1914,6 @@ static const struct inode_operations fuse_common_inode_operations = {
static const struct inode_operations fuse_symlink_inode_operations = {
.setattr = fuse_setattr,
.get_link = fuse_get_link,
- .readlink = generic_readlink,
.getattr = fuse_getattr,
.setxattr = fuse_setxattr,
.getxattr = fuse_getxattr,
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index e4da0ecd3285..ff48245848e7 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -2069,7 +2069,6 @@ const struct inode_operations gfs2_dir_iops = {
};
const struct inode_operations gfs2_symlink_iops = {
- .readlink = generic_readlink,
.get_link = gfs2_get_link,
.permission = gfs2_permission,
.setattr = gfs2_setattr,
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 90e46cd752fe..10a512450575 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -920,7 +920,6 @@ static const char *hostfs_get_link(struct dentry *dentry,
}
static const struct inode_operations hostfs_link_iops = {
- .readlink = generic_readlink,
.get_link = hostfs_get_link,
};
diff --git a/fs/jffs2/symlink.c b/fs/jffs2/symlink.c
index 2cabd649d4fb..18da3700e848 100644
--- a/fs/jffs2/symlink.c
+++ b/fs/jffs2/symlink.c
@@ -13,7 +13,6 @@
const struct inode_operations jffs2_symlink_inode_operations =
{
- .readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = jffs2_setattr,
.setxattr = jffs2_setxattr,
diff --git a/fs/jfs/symlink.c b/fs/jfs/symlink.c
index c94c7e4a1323..a9e3c856cc0c 100644
--- a/fs/jfs/symlink.c
+++ b/fs/jfs/symlink.c
@@ -22,7 +22,6 @@
#include "jfs_xattr.h"
const struct inode_operations jfs_fast_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = jfs_setattr,
.setxattr = generic_setxattr,
@@ -32,7 +31,6 @@ const struct inode_operations jfs_fast_symlink_inode_operations = {
};
const struct inode_operations jfs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.setattr = jfs_setattr,
.setxattr = generic_setxattr,
diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c
index 117b8b3416f9..e4a4aee2d74f 100644
--- a/fs/kernfs/symlink.c
+++ b/fs/kernfs/symlink.c
@@ -138,7 +138,6 @@ const struct inode_operations kernfs_symlink_iops = {
.removexattr = kernfs_iop_removexattr,
.getxattr = kernfs_iop_getxattr,
.listxattr = kernfs_iop_listxattr,
- .readlink = generic_readlink,
.get_link = kernfs_iop_get_link,
.setattr = kernfs_iop_setattr,
.getattr = kernfs_iop_getattr,
diff --git a/fs/libfs.c b/fs/libfs.c
index 74dc8b9e7f53..7a0844e01e3f 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1124,7 +1124,6 @@ EXPORT_SYMBOL(simple_get_link);
const struct inode_operations simple_symlink_inode_operations = {
.get_link = simple_get_link,
- .readlink = generic_readlink
};
EXPORT_SYMBOL(simple_symlink_inode_operations);
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index f975d667c539..e7d9bf86d975 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -434,7 +434,6 @@ static const struct address_space_operations minix_aops = {
};
static const struct inode_operations minix_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.getattr = minix_getattr,
};
diff --git a/fs/namei.c b/fs/namei.c
index f72c405d1a27..a93424178634 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4765,7 +4765,6 @@ int page_symlink(struct inode *inode, const char *symname, int len)
EXPORT_SYMBOL(page_symlink);
const struct inode_operations page_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
};
EXPORT_SYMBOL(page_symlink_inode_operations);
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 1af15fcbe57b..86717e51cf1d 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -243,7 +243,6 @@ static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo)
#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
static const struct inode_operations ncp_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.setattr = ncp_notify_change,
};
diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c
index 4fe3eead3868..5a1d0ded8979 100644
--- a/fs/nfs/symlink.c
+++ b/fs/nfs/symlink.c
@@ -77,7 +77,6 @@ static const char *nfs_get_link(struct dentry *dentry,
* symlinks can't do much...
*/
const struct inode_operations nfs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = nfs_get_link,
.getattr = nfs_getattr,
.setattr = nfs_setattr,
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index dbcf1dc93a51..c7eb03be9723 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -564,7 +564,6 @@ const struct inode_operations nilfs_special_inode_operations = {
};
const struct inode_operations nilfs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.permission = nilfs_permission,
};
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
index 6c2a3e3c521c..1a2ba465e291 100644
--- a/fs/ocfs2/symlink.c
+++ b/fs/ocfs2/symlink.c
@@ -87,7 +87,6 @@ const struct address_space_operations ocfs2_fast_symlink_aops = {
};
const struct inode_operations ocfs2_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.getattr = ocfs2_getattr,
.setattr = ocfs2_setattr,
diff --git a/fs/orangefs/symlink.c b/fs/orangefs/symlink.c
index 8fecf823f5ba..20c8b4193cf3 100644
--- a/fs/orangefs/symlink.c
+++ b/fs/orangefs/symlink.c
@@ -9,7 +9,6 @@
#include "orangefs-bufmap.h"
const struct inode_operations orangefs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = orangefs_setattr,
.getattr = orangefs_getattr,
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 3b636e3acda4..db8975f59021 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -359,7 +359,6 @@ static const struct inode_operations ovl_file_inode_operations = {
static const struct inode_operations ovl_symlink_inode_operations = {
.setattr = ovl_setattr,
.get_link = ovl_get_link,
- .readlink = generic_readlink,
.getattr = ovl_getattr,
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 84769c763afe..efd87ce587e6 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1615,7 +1615,6 @@ out:
const struct inode_operations proc_pid_link_inode_operations = {
- .readlink = generic_readlink,
.get_link = proc_pid_get_link,
.setattr = proc_setattr,
};
@@ -1950,7 +1949,6 @@ proc_map_files_get_link(struct dentry *dentry,
* Identical to proc_pid_link_inode_operations except for get_link()
*/
static const struct inode_operations proc_map_files_link_inode_operations = {
- .readlink = generic_readlink,
.get_link = proc_map_files_get_link,
.setattr = proc_setattr,
};
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index c1b72388e571..43b228b8cb21 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -411,7 +411,6 @@ static const char *proc_get_link(struct dentry *dentry,
}
const struct inode_operations proc_link_inode_operations = {
- .readlink = generic_readlink,
.get_link = proc_get_link,
};
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 9c7209734b05..ea5f1fac3987 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -68,7 +68,6 @@ out:
}
static const struct inode_operations proc_ns_link_inode_operations = {
- .readlink = generic_readlink,
.get_link = proc_ns_get_link,
.setattr = proc_setattr,
};
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 80bc52fd7846..3ce34845a174 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -26,7 +26,6 @@ static const char *proc_self_get_link(struct dentry *dentry,
}
static const struct inode_operations proc_self_inode_operations = {
- .readlink = generic_readlink,
.get_link = proc_self_get_link,
};
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index 55053d5280ff..75bbdd7f7c69 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -27,7 +27,6 @@ static const char *proc_thread_self_get_link(struct dentry *dentry,
}
static const struct inode_operations proc_thread_self_inode_operations = {
- .readlink = generic_readlink,
.get_link = proc_thread_self_get_link,
};
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 8a36696d6df9..adbf154ef4a2 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -1664,7 +1664,6 @@ const struct inode_operations reiserfs_dir_inode_operations = {
* stuff added
*/
const struct inode_operations reiserfs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.setattr = reiserfs_setattr,
.setxattr = generic_setxattr,
diff --git a/fs/squashfs/symlink.c b/fs/squashfs/symlink.c
index d688ef42a6a1..853b8516ba44 100644
--- a/fs/squashfs/symlink.c
+++ b/fs/squashfs/symlink.c
@@ -118,7 +118,6 @@ const struct address_space_operations squashfs_symlink_aops = {
};
const struct inode_operations squashfs_symlink_inode_ops = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.getxattr = generic_getxattr,
.listxattr = squashfs_listxattr
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index d62c423a5a2d..858fb72f9e0f 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -145,7 +145,6 @@ static inline void write3byte(struct sysv_sb_info *sbi,
}
static const struct inode_operations sysv_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = page_get_link,
.getattr = sysv_getattr,
};
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 7bbf420d1289..62f69c392e17 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1631,7 +1631,6 @@ const struct inode_operations ubifs_file_inode_operations = {
};
const struct inode_operations ubifs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = simple_get_link,
.setattr = ubifs_setattr,
.getattr = ubifs_getattr,
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index b24c3102fa93..b679efa7ae09 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1101,7 +1101,6 @@ static const struct inode_operations xfs_dir_ci_inode_operations = {
};
static const struct inode_operations xfs_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = xfs_vn_get_link,
.getattr = xfs_vn_getattr,
.setattr = xfs_vn_setattr,
@@ -1113,7 +1112,6 @@ static const struct inode_operations xfs_symlink_inode_operations = {
};
static const struct inode_operations xfs_inline_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = xfs_vn_get_link_inline,
.getattr = xfs_vn_getattr,
.setattr = xfs_vn_setattr,
diff --git a/mm/shmem.c b/mm/shmem.c
index fd8b2b5741b1..68162abd85e6 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3284,7 +3284,6 @@ static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size)
#endif /* CONFIG_TMPFS_XATTR */
static const struct inode_operations shmem_short_symlink_operations = {
- .readlink = generic_readlink,
.get_link = simple_get_link,
#ifdef CONFIG_TMPFS_XATTR
.setxattr = generic_setxattr,
@@ -3295,7 +3294,6 @@ static const struct inode_operations shmem_short_symlink_operations = {
};
static const struct inode_operations shmem_symlink_inode_operations = {
- .readlink = generic_readlink,
.get_link = shmem_get_link,
#ifdef CONFIG_TMPFS_XATTR
.setxattr = generic_setxattr,
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-09-12 21:40 +0200 |
| Subject | [PATCH 06/17] vfs: remove page_readlink() |
| Message-ID | <sgFfd-7H4-59@gated-at.bofh.it> |
| In reply to | #1481913 |
Remove this unused helper (sole previous user was AFS).
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/namei.c | 11 -----------
include/linux/fs.h | 1 -
2 files changed, 12 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index adb04146df09..c06a68b82088 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4713,17 +4713,6 @@ void page_put_link(void *arg)
}
EXPORT_SYMBOL(page_put_link);
-int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
-{
- DEFINE_DELAYED_CALL(done);
- int res = readlink_copy(buffer, buflen,
- page_get_link(dentry, d_inode(dentry),
- &done));
- do_delayed_call(&done);
- return res;
-}
-EXPORT_SYMBOL(page_readlink);
-
/*
* The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS
*/
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 901e25d495cc..5448a9b88c41 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2890,7 +2890,6 @@ extern const struct file_operations generic_ro_fops;
#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
extern int readlink_copy(char __user *, int, const char *);
-extern int page_readlink(struct dentry *, char __user *, int);
extern const char *page_get_link(struct dentry *, struct inode *,
struct delayed_call *);
extern void page_put_link(void *);
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-09-12 21:40 +0200 |
| Subject | [PATCH 03/17] proc/self: use generic_readlink |
| Message-ID | <sgFfd-7H4-69@gated-at.bofh.it> |
| In reply to | #1481913 |
This will also allow us to move the generic readlink logic into the VFS and
get rid of the readlink method.
The /proc/self and /proc/self-thread symlinks have separate but identical
functionality for reading and following. This cleanup utilizes
generic_readlink to remove the duplication.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/proc/self.c | 14 +-------------
fs/proc/thread_self.c | 15 +--------------
2 files changed, 2 insertions(+), 27 deletions(-)
diff --git a/fs/proc/self.c b/fs/proc/self.c
index b6a8d3529fea..80bc52fd7846 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -6,18 +6,6 @@
/*
* /proc/self:
*/
-static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
- int buflen)
-{
- struct pid_namespace *ns = dentry->d_sb->s_fs_info;
- pid_t tgid = task_tgid_nr_ns(current, ns);
- char tmp[PROC_NUMBUF];
- if (!tgid)
- return -ENOENT;
- sprintf(tmp, "%d", tgid);
- return readlink_copy(buffer, buflen, tmp);
-}
-
static const char *proc_self_get_link(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
@@ -38,7 +26,7 @@ static const char *proc_self_get_link(struct dentry *dentry,
}
static const struct inode_operations proc_self_inode_operations = {
- .readlink = proc_self_readlink,
+ .readlink = generic_readlink,
.get_link = proc_self_get_link,
};
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index e58a31e8fb2a..55053d5280ff 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -6,19 +6,6 @@
/*
* /proc/thread_self:
*/
-static int proc_thread_self_readlink(struct dentry *dentry, char __user *buffer,
- int buflen)
-{
- struct pid_namespace *ns = dentry->d_sb->s_fs_info;
- pid_t tgid = task_tgid_nr_ns(current, ns);
- pid_t pid = task_pid_nr_ns(current, ns);
- char tmp[PROC_NUMBUF + 6 + PROC_NUMBUF];
- if (!pid)
- return -ENOENT;
- sprintf(tmp, "%d/task/%d", tgid, pid);
- return readlink_copy(buffer, buflen, tmp);
-}
-
static const char *proc_thread_self_get_link(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
@@ -40,7 +27,7 @@ static const char *proc_thread_self_get_link(struct dentry *dentry,
}
static const struct inode_operations proc_thread_self_inode_operations = {
- .readlink = proc_thread_self_readlink,
+ .readlink = generic_readlink,
.get_link = proc_thread_self_get_link,
};
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | Miklos Szeredi <mszeredi@redhat.com> |
|---|---|
| Date | 2016-09-12 21:40 +0200 |
| Subject | [PATCH 16/17] ovl: use vfs_get_link() |
| Message-ID | <sgFfd-7H4-73@gated-at.bofh.it> |
| In reply to | #1481913 |
Resulting in a complete removal of a function basically implementing the
inverse of vfs_readlink().
As a bonus, now the proper security hook is also called.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/overlayfs/copy_up.c | 45 ++++++---------------------------------------
fs/overlayfs/inode.c | 5 +----
2 files changed, 7 insertions(+), 43 deletions(-)
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index a2d4c10dd74d..c3371d62d931 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -167,39 +167,6 @@ out_fput:
return error;
}
-static char *ovl_read_symlink(struct dentry *realdentry)
-{
- int res;
- char *buf;
- struct inode *inode = realdentry->d_inode;
- mm_segment_t old_fs;
-
- res = -EINVAL;
- if (!inode->i_op->get_link)
- goto err;
-
- res = -ENOMEM;
- buf = (char *) __get_free_page(GFP_KERNEL);
- if (!buf)
- goto err;
-
- old_fs = get_fs();
- set_fs(get_ds());
- /* The cast to a user pointer is valid due to the set_fs() */
- res = vfs_readlink(realdentry, (char __user *)buf, PAGE_SIZE - 1);
- set_fs(old_fs);
- if (res < 0) {
- free_page((unsigned long) buf);
- goto err;
- }
- buf[res] = '\0';
-
- return buf;
-
-err:
- return ERR_PTR(res);
-}
-
static int ovl_set_timestamps(struct dentry *upperdentry, struct kstat *stat)
{
struct iattr attr = {
@@ -331,19 +298,21 @@ out_cleanup:
int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
struct path *lowerpath, struct kstat *stat)
{
+ DEFINE_DELAYED_CALL(done);
struct dentry *workdir = ovl_workdir(dentry);
int err;
struct kstat pstat;
struct path parentpath;
+ struct dentry *lowerdentry = lowerpath->dentry;
struct dentry *upperdir;
struct dentry *upperdentry;
const struct cred *old_cred;
- char *link = NULL;
+ const char *link = NULL;
if (WARN_ON(!workdir))
return -EROFS;
- ovl_do_check_copy_up(lowerpath->dentry);
+ ovl_do_check_copy_up(lowerdentry);
ovl_path_upper(parent, &parentpath);
upperdir = parentpath.dentry;
@@ -353,7 +322,7 @@ int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
return err;
if (S_ISLNK(stat->mode)) {
- link = ovl_read_symlink(lowerpath->dentry);
+ link = vfs_get_link(lowerdentry, d_inode(lowerdentry), &done);
if (IS_ERR(link))
return PTR_ERR(link);
}
@@ -381,9 +350,7 @@ int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
out_unlock:
unlock_rename(workdir, upperdir);
revert_creds(old_cred);
-
- if (link)
- free_page((unsigned long) link);
+ do_delayed_call(&done);
return err;
}
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index db8975f59021..6be9bb470fd9 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -164,11 +164,8 @@ static const char *ovl_get_link(struct dentry *dentry,
realdentry = ovl_dentry_real(dentry);
realinode = realdentry->d_inode;
- if (WARN_ON(!realinode->i_op->get_link))
- return ERR_PTR(-EPERM);
-
old_cred = ovl_override_creds(dentry->d_sb);
- p = realinode->i_op->get_link(realdentry, realinode, done);
+ p = vfs_get_link(realdentry, realinode, done);
revert_creds(old_cred);
return p;
}
--
2.5.5
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web