[commits] [openwrt-feed-devel] master: batman-adv-devel: Add uaccess compat code for 2 and 3 args uaccess function (167c089)

postmaster at open-mesh.org postmaster at open-mesh.org
Sat Mar 9 13:02:42 CET 2019


Repository : ssh://git@open-mesh.org/openwrt-feed-devel

On branch  : master

>---------------------------------------------------------------

commit 167c089703edec5b4e7ed5e49e093a6b080e11be
Author: Sven Eckelmann <sven at narfation.org>
Date:   Sun Jan 27 16:28:23 2019 +0100

    batman-adv-devel: Add uaccess compat code for 2 and 3 args uaccess function
    
    The kernels 3.16-3.18 use the 3-arguments access_ok macro in header
    files. When we remove this version, the build will fail on these kernels.
    with:
    
      include/net/sock.h:1818:22: error: macro "access_ok" passed 3 arguments, but takes just 2
      In file included from net/batman-adv/bridge_loop_avoidance.c:52:0:
      include/net/sock.h: In function ‘skb_do_copy_data_nocache’:
      include/net/sock.h:1818:41: error: macro "access_ok" passed 3 arguments, but takes just 2
         if (!access_ok(VERIFY_READ, from, copy) ||
                                               ^
      include/net/sock.h:1818:8: error: ‘access_ok’ undeclared (first use in this function)
         if (!access_ok(VERIFY_READ, from, copy) ||
              ^~~~~~~~~
    
    Signed-off-by: Sven Eckelmann <sven at narfation.org>


>---------------------------------------------------------------

167c089703edec5b4e7ed5e49e093a6b080e11be
 batman-adv-devel/src/compat-hacks.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/batman-adv-devel/src/compat-hacks.h b/batman-adv-devel/src/compat-hacks.h
index 4511184..718a15c 100644
--- a/batman-adv-devel/src/compat-hacks.h
+++ b/batman-adv-devel/src/compat-hacks.h
@@ -348,6 +348,27 @@ typedef unsigned __poll_t;
 
 #endif /* < KERNEL_VERSION(4, 16, 0) */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
+
+static inline int batadv_access_ok(int type, const void __user *p,
+				   unsigned long size)
+{
+	return access_ok(type, p, size);
+}
+
+#ifdef access_ok
+#undef access_ok
+#endif
+
+#define access_ok_get(_1, _2, _3 , access_ok_name, ...) access_ok_name
+#define access_ok(...) \
+	access_ok_get(__VA_ARGS__, access_ok3, access_ok2)(__VA_ARGS__)
+
+#define access_ok2(addr, size)	batadv_access_ok(VERIFY_WRITE, (addr), (size))
+#define access_ok3(type, addr, size)	batadv_access_ok((type), (addr), (size))
+
+#endif /* < KERNEL_VERSION(5, 0, 0) */
+
 /* <DECLARE_EWMA> */
 
 #include <linux/version.h>



More information about the commits mailing list