]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs: fix kernel_write / kernel_read arguments
authorMarcio Barbosa <mbarbosa@sinenomine.net>
Thu, 16 Nov 2017 22:24:03 +0000 (17:24 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Tue, 28 Nov 2017 04:50:56 +0000 (23:50 -0500)
The order / content of the arguments passed to kernel_write and
kernel_read are not right. As a result, the kernel will panic if one of
the functions in question is called.

[kaduk@mit.edu: include configure check for multiple kernel_read()
variants, per linux commits bdd1d2d3d251c65b74ac4493e08db18971c09240
and e13ec939e96b13e664bb6cee361cc976a0ee621a]

FIXES 134440

Reviewed-on: https://gerrit.openafs.org/12769
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 3ce55426ee6912b78460465bcaa1428333ad1fbc)

Change-Id: I28f04f7625a471c37f98515d5186f80082bf6a43
Reviewed-on: https://gerrit.openafs.org/12780
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
acinclude.m4
src/afs/LINUX/osi_compat.h
src/cf/linux-test4.m4

index 703d3ea7b5d6d6d8f3900f09d518832d4daad72e..8952776c62051fb5e91c342addefd726f14851de 100644 (file)
@@ -1195,6 +1195,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 LINUX_DOP_D_REVALIDATE_TAKES_UNSIGNED
                 LINUX_IOP_LOOKUP_TAKES_UNSIGNED
                 LINUX_D_INVALIDATE_IS_VOID
+                LINUX_KERNEL_READ_OFFSET_IS_LAST
 
                 dnl If we are guaranteed that keyrings will work - that is
                 dnl  a) The kernel has keyrings enabled
index 60cfdc1c27143e8153e0ff61f98f50ac85963f2c..62fce213dee15a5d1951bd16227aa8ebe5c9df68 100644 (file)
@@ -659,7 +659,11 @@ afs_file_read(struct file *filp, char __user *buf, size_t len, loff_t *pos)
 #if defined(HAVE_LINUX___VFS_WRITE)
     return __vfs_read(filp, buf, len, pos);
 #elif defined(HAVE_LINUX_KERNEL_WRITE)
+# if defined(LINUX_KERNEL_READ_OFFSET_IS_LAST)
     return kernel_read(filp, buf, len, pos);
+# else
+    return kernel_read(filp, *pos, buf, len);
+# endif
 #else
     return filp->f_op->read(filp, buf, len, pos);
 #endif
@@ -671,7 +675,11 @@ afs_file_write(struct file *filp, char __user *buf, size_t len, loff_t *pos)
 #if defined(HAVE_LINUX___VFS_WRITE)
     return __vfs_write(filp, buf, len, pos);
 #elif defined(HAVE_LINUX_KERNEL_WRITE)
+# if defined(LINUX_KERNEL_READ_OFFSET_IS_LAST)
     return kernel_write(filp, buf, len, pos);
+# else
+    return kernel_write(filp, buf, len, *pos);
+# endif
 #else
     return filp->f_op->write(filp, buf, len, pos);
 #endif
index ed759e1ee88c23cf0a27f68f202b89251c21145c..6746a107acf50fd1452f2f2ab93d8ea690e35e5c 100644 (file)
@@ -799,3 +799,15 @@ AC_DEFUN([LINUX_D_INVALIDATE_IS_VOID], [
                       [define if your d_invalidate returns void],
                       [])
 ])
+
+AC_DEFUN([LINUX_KERNEL_READ_OFFSET_IS_LAST], [
+  AC_CHECK_LINUX_BUILD([whether offset is the last argument to kernel_read],
+                       [ac_cv_linux_func_kernel_read_offset_is_last],
+                       [#include <linux/fs.h>],
+                       [
+                       ssize_t kernel_read(struct file *, void *, size_t, loff_t *);
+                       ],
+                       [KERNEL_READ_OFFSET_IS_LAST],
+                       [define if your kernel_read has offset as the last argument],
+                       [])
+])