kdbus: porting to to 5.4 11/251411/4
authorŁukasz Stelmach <l.stelmach@samsung.com>
Mon, 21 Dec 2020 15:34:08 +0000 (16:34 +0100)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 15 Jan 2021 10:11:22 +0000 (10:11 +0000)
The following changes were made to adapt kdbus driver to 5.4 kernel

- use KERNEL_DS instead of get_ds()
- remove ITER_KVEC flag
- remove 'type' argument from access_ok()
- use memfd_fcntl() instead of shmem_get_seals()
- use uapi/linux/mount.h

Fixes: 736706bee329 ("get rid of legacy 'get_ds()' function")
Fixes: aa563d7bca6e ("iov_iter: Separate type from direction and use accessor functions")
Fixes: 96d4f267e40f ("Remove 'type' argument from access_ok() function")
Fixes: 5aadc431a593 ("shmem: rename functions that are memfd-related")
Fixes: 5d752600a8c3 ("mm: restructure memfd code")
Fixes: e262e32d6bde ("vfs: Suppress MS_* flag defs within the kernel unless explicitly enabled")
Change-Id: I8d2b3db1c83bb21114554ba9eb38e5e439f5c141
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
ipc/kdbus/fs.c
ipc/kdbus/message.c
ipc/kdbus/pool.c

index e368b73..3e74111 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/ipc_namespace.h>
 #include <linux/magic.h>
 #include <linux/module.h>
-#include <linux/mount.h>
+#include <uapi/linux/mount.h>
 #include <linux/mutex.h>
 #include <linux/namei.h>
 #include <linux/pagemap.h>
index 8aef83d..63626c8 100644 (file)
 #include <linux/cred.h>
 #include <linux/file.h>
 #include <linux/init.h>
+#include <linux/memfd.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/sched.h>
-#include <linux/shmem_fs.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
@@ -263,7 +263,7 @@ static struct file *kdbus_get_memfd(const struct kdbus_memfd *memfd)
        if (!f)
                return ERR_PTR(-EBADF);
 
-       s = shmem_get_seals(f);
+       s = memfd_fcntl(f, F_GET_SEALS, 0);
        if (s < 0)
                ret = ERR_PTR(-EMEDIUMTYPE);
        else if ((s & m) != m)
@@ -346,7 +346,7 @@ static int kdbus_msg_examine(struct kdbus_msg *msg, struct kdbus_bus *bus,
                                return -EMSGSIZE;
                        if (vec_size + size > KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE)
                                return -EMSGSIZE;
-                       if (ptr && unlikely(!access_ok(VERIFY_READ, ptr, size)))
+                       if (ptr && unlikely(!access_ok(ptr, size)))
                                return -EFAULT;
 
                        if (ptr || size % 8) /* data or padding */
index fb1a88a..b128963 100644 (file)
@@ -616,10 +616,10 @@ ssize_t kdbus_pool_slice_copy_kvec(const struct kdbus_pool_slice *slice,
                return -EFAULT;
 
        off += slice->off;
-       iov_iter_kvec(&iter, WRITE | ITER_KVEC, kvec, kvec_len, total_len);
+       iov_iter_kvec(&iter, WRITE, kvec, kvec_len, total_len);
 
        old_fs = get_fs();
-       set_fs(get_ds());
+       set_fs(KERNEL_DS);
        len = vfs_iter_write(slice->pool->f, &iter, &off, 0);
        set_fs(old_fs);
 
@@ -653,7 +653,7 @@ int kdbus_pool_slice_copy(const struct kdbus_pool_slice *slice_dst,
 
        inode_lock(i_dst);
        old_fs = get_fs();
-       set_fs(get_ds());
+       set_fs(KERNEL_DS);
        while (len > 0) {
                unsigned long page_off;
                unsigned long copy_len;