Revert "Revert "Revert "kdbus: add CMD_UPDATE_METADATA ioctl (reinitialize connection... 21/119821/2
authorHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 20 Mar 2017 07:58:48 +0000 (00:58 -0700)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 21 Mar 2017 00:43:42 +0000 (17:43 -0700)
This reverts commit 3cd1cf51706d2df8256cf8014d01b3d23d553f44.

Change-Id: Iea89918ca8ff2992fe967ce47887ad15d881053c

include/uapi/linux/kdbus.h
ipc/kdbus/connection.c
ipc/kdbus/connection.h
ipc/kdbus/handle.c
ipc/kdbus/metadata.c
ipc/kdbus/metadata.h

index 778bccb..4fc44cb 100644 (file)
@@ -979,9 +979,6 @@ enum kdbus_ioctl_type {
                                             struct kdbus_cmd_match),
        KDBUS_CMD_MATCH_REMOVE =        _IOW(KDBUS_IOCTL_MAGIC, 0xb1,
                                             struct kdbus_cmd_match),
-
-       /* Tizen */
-       KDBUS_CMD_UPDATE_METADATA = _IO(KDBUS_IOCTL_MAGIC, 0xd0),
 };
 
 #endif /* _UAPI_KDBUS_H_ */
index 2f850bd..02deba3 100644 (file)
@@ -57,8 +57,6 @@
  */
 #define DISABLE_KDBUS_POLICY
 
-static int kdbus_conn_meta_update(struct kdbus_conn *conn, bool first_time);
-
 static struct kdbus_conn *kdbus_conn_new(struct kdbus_ep *ep,
                                         struct file *file,
                                         struct kdbus_cmd_hello *hello,
@@ -197,7 +195,25 @@ static struct kdbus_conn *kdbus_conn_new(struct kdbus_ep *ep,
                if (ret < 0)
                        goto exit_unref;
        } else {
-               ret = kdbus_conn_meta_update(conn, 1);
+               conn->meta_proc = kdbus_meta_proc_new();
+               if (IS_ERR(conn->meta_proc)) {
+                       ret = PTR_ERR(conn->meta_proc);
+                       conn->meta_proc = NULL;
+                       goto exit_unref;
+               }
+
+               ret = kdbus_meta_proc_collect(conn->meta_proc,
+                                             KDBUS_ATTACH_CREDS |
+                                             KDBUS_ATTACH_PIDS |
+                                             KDBUS_ATTACH_AUXGROUPS |
+                                             KDBUS_ATTACH_TID_COMM |
+                                             KDBUS_ATTACH_PID_COMM |
+                                             KDBUS_ATTACH_EXE |
+                                             KDBUS_ATTACH_CMDLINE |
+                                             KDBUS_ATTACH_CGROUP |
+                                             KDBUS_ATTACH_CAPS |
+                                             KDBUS_ATTACH_SECLABEL |
+                                             KDBUS_ATTACH_AUDIT);
                if (ret < 0)
                        goto exit_unref;
        }
@@ -1718,7 +1734,6 @@ int kdbus_cmd_conn_info(struct kdbus_conn *conn, void __user *argp)
        struct kdbus_name_owner *owner = NULL;
        struct kdbus_conn *owner_conn = NULL;
        struct kdbus_item *meta_items = NULL;
-       struct kdbus_meta_proc *meta_proc = NULL;
        struct kdbus_info info = {};
        struct kdbus_cmd_info *cmd;
        struct kdbus_bus *bus = conn->ep->bus;
@@ -1790,13 +1805,7 @@ int kdbus_cmd_conn_info(struct kdbus_conn *conn, void __user *argp)
        if (ret < 0)
                goto exit;
 
-       if (!owner_conn->meta_fake) {
-               rcu_read_lock();
-               meta_proc = rcu_dereference(owner_conn->meta_proc);
-               kdbus_meta_proc_ref(meta_proc);
-               rcu_read_unlock();
-       }
-       ret = kdbus_meta_emit(meta_proc, owner_conn->meta_fake,
+       ret = kdbus_meta_emit(owner_conn->meta_proc, owner_conn->meta_fake,
                              conn_meta, conn, attach_flags,
                              &meta_items, &meta_size);
        if (ret < 0)
@@ -1840,7 +1849,6 @@ exit:
        kdbus_pool_slice_release(slice);
        kfree(meta_items);
        kdbus_meta_conn_unref(conn_meta);
-       kdbus_meta_proc_unref(meta_proc);
        kdbus_conn_unref(owner_conn);
        return kdbus_args_clear(&args, ret);
 }
@@ -2235,56 +2243,3 @@ int kdbus_cmd_free(struct kdbus_conn *conn, void __user *argp)
 
        return kdbus_args_clear(&args, ret);
 }
-
-static int kdbus_conn_meta_update(struct kdbus_conn *conn, bool first_time)
-{
-       int ret;
-       struct kdbus_meta_proc *mp = kdbus_meta_proc_new();
-
-       if (IS_ERR(mp))
-               return PTR_ERR(mp);
-
-       ret = kdbus_meta_proc_collect(mp,
-                                         KDBUS_ATTACH_CREDS |
-                                         KDBUS_ATTACH_PIDS |
-                                         KDBUS_ATTACH_AUXGROUPS |
-                                         KDBUS_ATTACH_TID_COMM |
-                                         KDBUS_ATTACH_PID_COMM |
-                                         KDBUS_ATTACH_EXE |
-                                         KDBUS_ATTACH_CMDLINE |
-                                         KDBUS_ATTACH_CGROUP |
-                                         KDBUS_ATTACH_CAPS |
-                                         KDBUS_ATTACH_SECLABEL |
-                                         KDBUS_ATTACH_AUDIT);
-       if (ret < 0) {
-               kdbus_meta_proc_free(&mp->kref);
-               return ret;
-       }
-
-       if (first_time)
-               conn->meta_proc = mp;
-       else {
-               struct kdbus_meta_proc *old_meta;
-               mutex_lock(&conn->lock);
-               old_meta = conn->meta_proc;
-               rcu_assign_pointer(conn->meta_proc, mp);
-               synchronize_rcu();
-               mutex_unlock(&conn->lock);
-               kdbus_meta_proc_unref(old_meta);
-       }
-
-       return 0;
-}
-
-/**
- * kdbus_cmd_update_metadata() - handle KDBUS_CMD_UPDATE_METADATA
- * @conn:              connection to operate on
- *
- * Return: >=0 on success, negative error code on failure.
- */
-int kdbus_cmd_update_metadata(struct kdbus_conn *conn)
-{
-       if (conn->meta_fake)
-               return -EOPNOTSUPP;
-       return kdbus_conn_meta_update(conn, 0);
-}
index bd96a1c..1ad0820 100644 (file)
@@ -158,7 +158,6 @@ struct kdbus_conn *kdbus_cmd_hello(struct kdbus_ep *ep, struct file *file,
 int kdbus_cmd_byebye_unlocked(struct kdbus_conn *conn, void __user *argp);
 int kdbus_cmd_conn_info(struct kdbus_conn *conn, void __user *argp);
 int kdbus_cmd_update(struct kdbus_conn *conn, void __user *argp);
-int kdbus_cmd_update_metadata(struct kdbus_conn *conn);
 int kdbus_cmd_send(struct kdbus_conn *conn, struct file *f, void __user *argp);
 int kdbus_cmd_recv(struct kdbus_conn *conn, void __user *argp);
 int kdbus_cmd_free(struct kdbus_conn *conn, void __user *argp);
index c5ce6cf..fc60932 100644 (file)
@@ -498,9 +498,6 @@ static long kdbus_handle_ioctl_connected(struct file *file,
        case KDBUS_CMD_UPDATE:
                ret = kdbus_cmd_update(conn, buf);
                break;
-       case KDBUS_CMD_UPDATE_METADATA:
-               ret = kdbus_cmd_update_metadata(conn);
-               break;
        case KDBUS_CMD_MATCH_ADD:
                ret = kdbus_cmd_match_add(conn, buf);
                break;
@@ -579,7 +576,6 @@ static long kdbus_handle_ioctl(struct file *file, unsigned int cmd,
        case KDBUS_CMD_NAME_ACQUIRE:
        case KDBUS_CMD_NAME_RELEASE:
        case KDBUS_CMD_LIST:
-       case KDBUS_CMD_UPDATE_METADATA:
        case KDBUS_CMD_CONN_INFO:
        case KDBUS_CMD_BUS_CREATOR_INFO:
        case KDBUS_CMD_UPDATE:
index e5dd313..106ec26 100644 (file)
@@ -19,7 +19,9 @@
 #include <linux/file.h>
 #include <linux/fs_struct.h>
 #include <linux/init.h>
+#include <linux/kref.h>
 #include <linux/mutex.h>
+#include <linux/sched.h>
 #include <linux/security.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
 #include "names.h"
 
 /**
+ * struct kdbus_meta_proc - Process metadata
+ * @kref:              Reference counting
+ * @lock:              Object lock
+ * @collected:         Bitmask of collected items
+ * @valid:             Bitmask of collected and valid items
+ * @cred:              Credentials
+ * @pid:               PID of process
+ * @tgid:              TGID of process
+ * @ppid:              PPID of process
+ * @tid_comm:          TID comm line
+ * @pid_comm:          PID comm line
+ * @exe_path:          Executable path
+ * @root_path:         Root-FS path
+ * @cmdline:           Command-line
+ * @cgroup:            Full cgroup path
+ * @seclabel:          Seclabel
+ * @audit_loginuid:    Audit login-UID
+ * @audit_sessionid:   Audit session-ID
+ */
+struct kdbus_meta_proc {
+       struct kref kref;
+       struct mutex lock;
+       u64 collected;
+       u64 valid;
+
+       /* KDBUS_ITEM_CREDS */
+       /* KDBUS_ITEM_AUXGROUPS */
+       /* KDBUS_ITEM_CAPS */
+       const struct cred *cred;
+
+       /* KDBUS_ITEM_PIDS */
+       struct pid *pid;
+       struct pid *tgid;
+       struct pid *ppid;
+
+       /* KDBUS_ITEM_TID_COMM */
+       char tid_comm[TASK_COMM_LEN];
+       /* KDBUS_ITEM_PID_COMM */
+       char pid_comm[TASK_COMM_LEN];
+
+       /* KDBUS_ITEM_EXE */
+       struct path exe_path;
+       struct path root_path;
+
+       /* KDBUS_ITEM_CMDLINE */
+       char *cmdline;
+
+       /* KDBUS_ITEM_CGROUP */
+       char *cgroup;
+
+       /* KDBUS_ITEM_SECLABEL */
+       char *seclabel;
+
+       /* KDBUS_ITEM_AUDIT */
+       kuid_t audit_loginuid;
+       unsigned int audit_sessionid;
+};
+
+/**
  * struct kdbus_meta_conn
  * @kref:              Reference counting
  * @lock:              Object lock
@@ -91,7 +152,7 @@ struct kdbus_meta_proc *kdbus_meta_proc_new(void)
        return mp;
 }
 
-void kdbus_meta_proc_free(struct kref *kref)
+static void kdbus_meta_proc_free(struct kref *kref)
 {
        struct kdbus_meta_proc *mp = container_of(kref, struct kdbus_meta_proc,
                                                  kref);
index e8d8433..dba7cc7 100644 (file)
 #define __KDBUS_METADATA_H
 
 #include <linux/kernel.h>
-#include <linux/kref.h>
-#include <linux/path.h>
-#include <linux/sched.h>
 
 struct kdbus_conn;
 struct kdbus_pool_slice;
 
+struct kdbus_meta_proc;
 struct kdbus_meta_conn;
 
 /**
- * struct kdbus_meta_proc - Process metadata
- * @kref:              Reference counting
- * @lock:              Object lock
- * @collected:         Bitmask of collected items
- * @valid:             Bitmask of collected and valid items
- * @cred:              Credentials
- * @pid:               PID of process
- * @tgid:              TGID of process
- * @ppid:              PPID of process
- * @tid_comm:          TID comm line
- * @pid_comm:          PID comm line
- * @exe_path:          Executable path
- * @root_path:         Root-FS path
- * @cmdline:           Command-line
- * @cgroup:            Full cgroup path
- * @seclabel:          Seclabel
- * @audit_loginuid:    Audit login-UID
- * @audit_sessionid:   Audit session-ID
- */
-struct kdbus_meta_proc {
-       struct kref kref;
-       struct mutex lock;
-       u64 collected;
-       u64 valid;
-
-       /* KDBUS_ITEM_CREDS */
-       /* KDBUS_ITEM_AUXGROUPS */
-       /* KDBUS_ITEM_CAPS */
-       const struct cred *cred;
-
-       /* KDBUS_ITEM_PIDS */
-       struct pid *pid;
-       struct pid *tgid;
-       struct pid *ppid;
-
-       /* KDBUS_ITEM_TID_COMM */
-       char tid_comm[TASK_COMM_LEN];
-       /* KDBUS_ITEM_PID_COMM */
-       char pid_comm[TASK_COMM_LEN];
-
-       /* KDBUS_ITEM_EXE */
-       struct path exe_path;
-       struct path root_path;
-
-       /* KDBUS_ITEM_CMDLINE */
-       char *cmdline;
-
-       /* KDBUS_ITEM_CGROUP */
-       char *cgroup;
-
-       /* KDBUS_ITEM_SECLABEL */
-       char *seclabel;
-
-       /* KDBUS_ITEM_AUDIT */
-       kuid_t audit_loginuid;
-       unsigned int audit_sessionid;
-};
-
-
-/**
  * struct kdbus_meta_fake - Fake metadata
  * @valid:             Bitmask of collected and valid items
  * @uid:               UID of process
@@ -118,7 +56,6 @@ struct kdbus_meta_fake {
 struct kdbus_meta_proc *kdbus_meta_proc_new(void);
 struct kdbus_meta_proc *kdbus_meta_proc_ref(struct kdbus_meta_proc *mp);
 struct kdbus_meta_proc *kdbus_meta_proc_unref(struct kdbus_meta_proc *mp);
-void kdbus_meta_proc_free(struct kref *mpkref);
 int kdbus_meta_proc_collect(struct kdbus_meta_proc *mp, u64 what);
 
 struct kdbus_meta_fake *kdbus_meta_fake_new(void);