Skip to content

Instantly share code, notes, and snippets.

@mokomull
Created July 24, 2016 20:21
Show Gist options
  • Save mokomull/a6dbb46e44bd0d55092ee565321ae40f to your computer and use it in GitHub Desktop.
Save mokomull/a6dbb46e44bd0d55092ee565321ae40f to your computer and use it in GitHub Desktop.
From 74f62401644a54685a988e29a61763e3daeea9eb Mon Sep 17 00:00:00 2001
From: Matt Mullins <mmullins@mmlx.us>
Date: Sun, 24 Jul 2016 01:20:12 -0700
Subject: [PATCH] Revert "UBUNTU: SAUCE: fuse: Add support for pid namespaces"
This reverts commit 9b869708bde3dd34f0e1c59c7c2abe1e433e5b35.
---
fs/fuse/dev.c | 11 +----------
fs/fuse/file.c | 22 +++++-----------------
fs/fuse/fuse_i.h | 4 ----
fs/fuse/inode.c | 3 ---
4 files changed, 6 insertions(+), 34 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 11b4cb0..8f81a3f 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -19,7 +19,6 @@
#include <linux/pipe_fs_i.h>
#include <linux/swap.h>
#include <linux/splice.h>
-#include <linux/sched.h>
MODULE_ALIAS_MISCDEV(FUSE_MINOR);
MODULE_ALIAS("devname:fuse");
@@ -129,7 +128,7 @@ static void fuse_req_init_context(struct fuse_conn *fc, struct fuse_req *req)
{
req->in.h.uid = from_kuid(fc->user_ns, current_fsuid());
req->in.h.gid = from_kgid(fc->user_ns, current_fsgid());
- req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns);
+ req->in.h.pid = current->pid;
}
void fuse_set_initialized(struct fuse_conn *fc)
@@ -1249,10 +1248,6 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
struct fuse_in *in;
unsigned reqsize;
- if (task_active_pid_ns(current) != fc->pid_ns ||
- current_user_ns() != fc->user_ns)
- return -EIO;
-
restart:
spin_lock(&fiq->waitq.lock);
err = -EAGAIN;
@@ -1882,10 +1877,6 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
struct fuse_req *req;
struct fuse_out_header oh;
- if (task_active_pid_ns(current) != fc->pid_ns ||
- current_user_ns() != fc->user_ns)
- return -EIO;
-
if (nbytes < sizeof(struct fuse_out_header))
return -EINVAL;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 119f35ff..570ca40 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2061,8 +2061,7 @@ static int fuse_direct_mmap(struct file *file, struct vm_area_struct *vma)
return generic_file_mmap(file, vma);
}
-static int convert_fuse_file_lock(struct fuse_conn *fc,
- const struct fuse_file_lock *ffl,
+static int convert_fuse_file_lock(const struct fuse_file_lock *ffl,
struct file_lock *fl)
{
switch (ffl->type) {
@@ -2077,14 +2076,7 @@ static int convert_fuse_file_lock(struct fuse_conn *fc,
fl->fl_start = ffl->start;
fl->fl_end = ffl->end;
-
- /*
- * Convert pid into the caller's pid namespace. If the pid
- * does not map into the namespace fl_pid will get set to 0.
- */
- rcu_read_lock();
- fl->fl_pid = pid_vnr(find_pid_ns(ffl->pid, fc->pid_ns));
- rcu_read_unlock();
+ fl->fl_pid = ffl->pid;
break;
default:
@@ -2133,7 +2125,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl)
args.out.args[0].value = &outarg;
err = fuse_simple_request(fc, &args);
if (!err)
- err = convert_fuse_file_lock(fc, &outarg.lk, fl);
+ err = convert_fuse_file_lock(&outarg.lk, fl);
return err;
}
@@ -2145,8 +2137,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock)
FUSE_ARGS(args);
struct fuse_lk_in inarg;
int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK;
- struct pid *pid = fl->fl_type != F_UNLCK ? task_tgid(current) : NULL;
- pid_t pid_nr = pid_nr_ns(pid, fc->pid_ns);
+ pid_t pid = fl->fl_type != F_UNLCK ? current->tgid : 0;
int err;
if (fl->fl_lmops && fl->fl_lmops->lm_grant) {
@@ -2158,10 +2149,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock)
if (fl->fl_flags & FL_CLOSE)
return 0;
- if (pid && pid_nr == 0)
- return -EOVERFLOW;
-
- fuse_lk_fill(&args, file, fl, opcode, pid_nr, flock, &inarg);
+ fuse_lk_fill(&args, file, fl, opcode, pid, flock, &inarg);
err = fuse_simple_request(fc, &args);
/* locking is restartable */
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 5897805..fe9ecd8 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -22,7 +22,6 @@
#include <linux/rbtree.h>
#include <linux/poll.h>
#include <linux/workqueue.h>
-#include <linux/pid_namespace.h>
#include <linux/user_namespace.h>
/** Max number of pages that can be used in a single read request */
@@ -458,9 +457,6 @@ struct fuse_conn {
/** The group id for this mount */
kgid_t group_id;
- /** The pid namespace for this mount */
- struct pid_namespace *pid_ns;
-
/** The user namespace for this mount */
struct user_namespace *user_ns;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 4ce60b2..621a03b 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -20,7 +20,6 @@
#include <linux/random.h>
#include <linux/sched.h>
#include <linux/exportfs.h>
-#include <linux/pid_namespace.h>
MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
MODULE_DESCRIPTION("Filesystem in Userspace");
@@ -619,7 +618,6 @@ void fuse_conn_init(struct fuse_conn *fc, struct user_namespace *user_ns)
fc->connected = 1;
fc->attr_version = 1;
get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key));
- fc->pid_ns = get_pid_ns(task_active_pid_ns(current));
fc->user_ns = get_user_ns(user_ns);
}
EXPORT_SYMBOL_GPL(fuse_conn_init);
@@ -629,7 +627,6 @@ void fuse_conn_put(struct fuse_conn *fc)
if (atomic_dec_and_test(&fc->count)) {
if (fc->destroy_req)
fuse_request_free(fc->destroy_req);
- put_pid_ns(fc->pid_ns);
put_user_ns(fc->user_ns);
fc->release(fc);
}
--
2.7.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment