All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] fs: expose do_unlinkat for built-in callers
@ 2017-11-04 10:44 Christoph Hellwig
  2017-11-04 10:44 ` [PATCH 2/2] coredump: call do_unlinkat directly instead of sys_unlink Christoph Hellwig
  2017-11-06  3:13 ` [PATCH 1/2] fs: expose do_unlinkat for built-in callers Al Viro
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-11-04 10:44 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel

And make it take a struct filename instead of a user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/internal.h |  1 +
 fs/namei.c    | 12 +++++-------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/internal.h b/fs/internal.h
index 48cee21b4f14..df262f41a0ef 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -55,6 +55,7 @@ extern void __init chrdev_init(void);
 extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *);
 extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
 			   const char *, unsigned int, struct path *);
+long do_unlinkat(int dfd, struct filename *name);
 
 /*
  * namespace.c
diff --git a/fs/namei.c b/fs/namei.c
index c75ea03ca147..9060fd69981f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4009,10 +4009,9 @@ EXPORT_SYMBOL(vfs_unlink);
  * writeout happening, and we don't want to prevent access to the directory
  * while waiting on the I/O.
  */
-static long do_unlinkat(int dfd, const char __user *pathname)
+long do_unlinkat(int dfd, struct filename *name)
 {
 	int error;
-	struct filename *name;
 	struct dentry *dentry;
 	struct path path;
 	struct qstr last;
@@ -4021,8 +4020,7 @@ static long do_unlinkat(int dfd, const char __user *pathname)
 	struct inode *delegated_inode = NULL;
 	unsigned int lookup_flags = 0;
 retry:
-	name = filename_parentat(dfd, getname(pathname), lookup_flags,
-				&path, &last, &type);
+	name = filename_parentat(dfd, name, lookup_flags, &path, &last, &type);
 	if (IS_ERR(name))
 		return PTR_ERR(name);
 
@@ -4064,12 +4062,12 @@ static long do_unlinkat(int dfd, const char __user *pathname)
 	mnt_drop_write(path.mnt);
 exit1:
 	path_put(&path);
-	putname(name);
 	if (retry_estale(error, lookup_flags)) {
 		lookup_flags |= LOOKUP_REVAL;
 		inode = NULL;
 		goto retry;
 	}
+	putname(name);
 	return error;
 
 slashes:
@@ -4090,12 +4088,12 @@ SYSCALL_DEFINE3(unlinkat, int, dfd, const char __user *, pathname, int, flag)
 	if (flag & AT_REMOVEDIR)
 		return do_rmdir(dfd, pathname);
 
-	return do_unlinkat(dfd, pathname);
+	return do_unlinkat(dfd, getname(pathname));
 }
 
 SYSCALL_DEFINE1(unlink, const char __user *, pathname)
 {
-	return do_unlinkat(AT_FDCWD, pathname);
+	return do_unlinkat(AT_FDCWD, getname(pathname));
 }
 
 int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] coredump: call do_unlinkat directly instead of sys_unlink
  2017-11-04 10:44 [PATCH 1/2] fs: expose do_unlinkat for built-in callers Christoph Hellwig
@ 2017-11-04 10:44 ` Christoph Hellwig
  2017-11-06  3:13 ` [PATCH 1/2] fs: expose do_unlinkat for built-in callers Al Viro
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-11-04 10:44 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel

And stop messing with the address limit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/coredump.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/coredump.c b/fs/coredump.c
index 0eec03696707..cd72a4ca0cec 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -679,16 +679,11 @@ void do_coredump(const siginfo_t *siginfo)
 		 * privs and don't want to unlink another user's coredump.
 		 */
 		if (!need_suid_safe) {
-			mm_segment_t old_fs;
-
-			old_fs = get_fs();
-			set_fs(KERNEL_DS);
 			/*
 			 * If it doesn't exist, that's fine. If there's some
 			 * other problem, we'll catch it at the filp_open().
 			 */
-			(void) sys_unlink((const char __user *)cn.corename);
-			set_fs(old_fs);
+			do_unlinkat(AT_FDCWD, getname_kernel(cn.corename));
 		}
 
 		/*
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] fs: expose do_unlinkat for built-in callers
  2017-11-04 10:44 [PATCH 1/2] fs: expose do_unlinkat for built-in callers Christoph Hellwig
  2017-11-04 10:44 ` [PATCH 2/2] coredump: call do_unlinkat directly instead of sys_unlink Christoph Hellwig
@ 2017-11-06  3:13 ` Al Viro
  1 sibling, 0 replies; 4+ messages in thread
From: Al Viro @ 2017-11-06  3:13 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-fsdevel

On Sat, Nov 04, 2017 at 01:44:45PM +0300, Christoph Hellwig wrote:
> And make it take a struct filename instead of a user pointer.

Applied.  It's not pretty, but then neither was the original and
after trying to tweak it... probably better do that as a followup
someday.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] fs: expose do_unlinkat for built-in callers
@ 2017-05-15 15:59 Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-05-15 15:59 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel

And make it take a struct filename instead of a user pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/internal.h |  1 +
 fs/namei.c    | 12 +++++-------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/internal.h b/fs/internal.h
index 9676fe11c093..c127454fe4af 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -55,6 +55,7 @@ extern void __init chrdev_init(void);
 extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *);
 extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
 			   const char *, unsigned int, struct path *);
+long do_unlinkat(int dfd, struct filename *name);
 
 /*
  * namespace.c
diff --git a/fs/namei.c b/fs/namei.c
index 6571a5f5112e..75e90a083369 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4002,10 +4002,9 @@ EXPORT_SYMBOL(vfs_unlink);
  * writeout happening, and we don't want to prevent access to the directory
  * while waiting on the I/O.
  */
-static long do_unlinkat(int dfd, const char __user *pathname)
+long do_unlinkat(int dfd, struct filename *name)
 {
 	int error;
-	struct filename *name;
 	struct dentry *dentry;
 	struct path path;
 	struct qstr last;
@@ -4014,8 +4013,7 @@ static long do_unlinkat(int dfd, const char __user *pathname)
 	struct inode *delegated_inode = NULL;
 	unsigned int lookup_flags = 0;
 retry:
-	name = filename_parentat(dfd, getname(pathname), lookup_flags,
-				&path, &last, &type);
+	name = filename_parentat(dfd, name, lookup_flags, &path, &last, &type);
 	if (IS_ERR(name))
 		return PTR_ERR(name);
 
@@ -4057,12 +4055,12 @@ static long do_unlinkat(int dfd, const char __user *pathname)
 	mnt_drop_write(path.mnt);
 exit1:
 	path_put(&path);
-	putname(name);
 	if (retry_estale(error, lookup_flags)) {
 		lookup_flags |= LOOKUP_REVAL;
 		inode = NULL;
 		goto retry;
 	}
+	putname(name);
 	return error;
 
 slashes:
@@ -4083,12 +4081,12 @@ SYSCALL_DEFINE3(unlinkat, int, dfd, const char __user *, pathname, int, flag)
 	if (flag & AT_REMOVEDIR)
 		return do_rmdir(dfd, pathname);
 
-	return do_unlinkat(dfd, pathname);
+	return do_unlinkat(dfd, getname(pathname));
 }
 
 SYSCALL_DEFINE1(unlink, const char __user *, pathname)
 {
-	return do_unlinkat(AT_FDCWD, pathname);
+	return do_unlinkat(AT_FDCWD, getname(pathname));
 }
 
 int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-06  3:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-04 10:44 [PATCH 1/2] fs: expose do_unlinkat for built-in callers Christoph Hellwig
2017-11-04 10:44 ` [PATCH 2/2] coredump: call do_unlinkat directly instead of sys_unlink Christoph Hellwig
2017-11-06  3:13 ` [PATCH 1/2] fs: expose do_unlinkat for built-in callers Al Viro
  -- strict thread matches above, loose matches on Subject: below --
2017-05-15 15:59 Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.