Skip to content

Commit 74d016e

Browse files
author
Al Viro
committed
new helper: user_path_locked_at()
Equivalent of kern_path_locked() taking dfd/userland name. User introduced in the next commit. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent b85ea95 commit 74d016e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

fs/namei.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,13 +2573,13 @@ static int filename_parentat(int dfd, struct filename *name,
25732573
}
25742574

25752575
/* does lookup, returns the object with parent locked */
2576-
static struct dentry *__kern_path_locked(struct filename *name, struct path *path)
2576+
static struct dentry *__kern_path_locked(int dfd, struct filename *name, struct path *path)
25772577
{
25782578
struct dentry *d;
25792579
struct qstr last;
25802580
int type, error;
25812581

2582-
error = filename_parentat(AT_FDCWD, name, 0, path, &last, &type);
2582+
error = filename_parentat(dfd, name, 0, path, &last, &type);
25832583
if (error)
25842584
return ERR_PTR(error);
25852585
if (unlikely(type != LAST_NORM)) {
@@ -2598,12 +2598,22 @@ static struct dentry *__kern_path_locked(struct filename *name, struct path *pat
25982598
struct dentry *kern_path_locked(const char *name, struct path *path)
25992599
{
26002600
struct filename *filename = getname_kernel(name);
2601-
struct dentry *res = __kern_path_locked(filename, path);
2601+
struct dentry *res = __kern_path_locked(AT_FDCWD, filename, path);
26022602

26032603
putname(filename);
26042604
return res;
26052605
}
26062606

2607+
struct dentry *user_path_locked_at(int dfd, const char __user *name, struct path *path)
2608+
{
2609+
struct filename *filename = getname(name);
2610+
struct dentry *res = __kern_path_locked(dfd, filename, path);
2611+
2612+
putname(filename);
2613+
return res;
2614+
}
2615+
EXPORT_SYMBOL(user_path_locked_at);
2616+
26072617
int kern_path(const char *name, unsigned int flags, struct path *path)
26082618
{
26092619
struct filename *filename = getname_kernel(name);

include/linux/namei.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ extern struct dentry *kern_path_create(int, const char *, struct path *, unsigne
6666
extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int);
6767
extern void done_path_create(struct path *, struct dentry *);
6868
extern struct dentry *kern_path_locked(const char *, struct path *);
69+
extern struct dentry *user_path_locked_at(int , const char __user *, struct path *);
6970
int vfs_path_parent_lookup(struct filename *filename, unsigned int flags,
7071
struct path *parent, struct qstr *last, int *type,
7172
const struct path *root);

0 commit comments

Comments
 (0)