lkml.org 
[lkml]   [2012]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 61/73] union-mount: Make various syscalls aware (link, chmod, chown, utimes & setxattr) [ver #2]
Date
Make the link, chmod, chown, utimes and setxattr syscalls and their variants
aware of unionmounts by passing LOOKUP_COPY_UP to pathwalk.

This has the downside that the copyup will occur even if permission is later
denied to perform the operation.

Signed-off-by: David Howells <dhowells@redhat.com>
---

fs/namei.c | 2 +-
fs/open.c | 5 +++--
fs/utimes.c | 2 +-
fs/xattr.c | 10 ++++++----
4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 6ec5725..efad85e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3583,7 +3583,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
if (flags & AT_SYMLINK_FOLLOW)
how |= LOOKUP_FOLLOW;

- error = user_path_at(olddfd, oldname, how, &old_path);
+ error = user_path_at(olddfd, oldname, how | LOOKUP_COPY_UP, &old_path);
if (error)
return error;

diff --git a/fs/open.c b/fs/open.c
index d3be9e3..bce645b 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -516,7 +516,8 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, umode_t, mode
struct path path;
int error;

- error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
+ error = user_path_at(dfd, filename, LOOKUP_FOLLOW | LOOKUP_COPY_UP,
+ &path);
if (!error) {
error = chmod_common(&path, mode);
path_put(&path);
@@ -569,7 +570,7 @@ SYSCALL_DEFINE5(fchownat, int, dfd, const char __user *, filename, uid_t, user,
lookup_flags = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
if (flag & AT_EMPTY_PATH)
lookup_flags |= LOOKUP_EMPTY;
- error = user_path_at(dfd, filename, lookup_flags, &path);
+ error = user_path_at(dfd, filename, lookup_flags | LOOKUP_COPY_UP, &path);
if (error)
goto out;
error = mnt_want_write(path.mnt);
diff --git a/fs/utimes.c b/fs/utimes.c
index ba653f3..5fe9ed5 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -154,7 +154,7 @@ long do_utimes(int dfd, const char __user *filename, struct timespec *times,
fput(file);
} else {
struct path path;
- int lookup_flags = 0;
+ int lookup_flags = LOOKUP_COPY_UP;

if (!(flags & AT_SYMLINK_NOFOLLOW))
lookup_flags |= LOOKUP_FOLLOW;
diff --git a/fs/xattr.c b/fs/xattr.c
index 82f4337..b1d8b4c 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -351,7 +351,8 @@ SYSCALL_DEFINE5(setxattr, const char __user *, pathname,
struct path path;
int error;

- error = user_path(pathname, &path);
+ error = user_path_at(AT_FDCWD, pathname, LOOKUP_FOLLOW | LOOKUP_COPY_UP,
+ &path);
if (error)
return error;
error = mnt_want_write(path.mnt);
@@ -370,7 +371,7 @@ SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname,
struct path path;
int error;

- error = user_lpath(pathname, &path);
+ error = user_path_at(AT_FDCWD, pathname, LOOKUP_COPY_UP, &path);
if (error)
return error;
error = mnt_want_write(path.mnt);
@@ -580,7 +581,8 @@ SYSCALL_DEFINE2(removexattr, const char __user *, pathname,
struct path path;
int error;

- error = user_path(pathname, &path);
+ error = user_path_at(AT_FDCWD, pathname, LOOKUP_FOLLOW | LOOKUP_COPY_UP,
+ &path);
if (error)
return error;
error = mnt_want_write(path.mnt);
@@ -598,7 +600,7 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
struct path path;
int error;

- error = user_lpath(pathname, &path);
+ error = user_path_at(AT_FDCWD, pathname, LOOKUP_COPY_UP, &path);
if (error)
return error;
error = mnt_want_write(path.mnt);


\
 
 \ /
  Last update: 2012-02-21 19:21    [W:0.271 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site