diff -Nru openafs-1.8.6/debian/changelog openafs-1.8.6/debian/changelog --- openafs-1.8.6/debian/changelog 2021-01-14 19:48:18.000000000 +0000 +++ openafs-1.8.6/debian/changelog 2021-02-16 17:12:48.000000000 +0000 @@ -1,3 +1,11 @@ +openafs (1.8.6-5ubuntu1) hirsute; urgency=medium + + * Support linux 5.11 (LP: #123): + - debian/patches/0020-Linux-Refactor-test-for-32bit-compat.patch + - debian/patches/0021-Linux-5.11-Test-32bit-compat-with-in_compat_syscall.patch + + -- Andrea Righi Tue, 16 Feb 2021 17:12:48 +0000 + openafs (1.8.6-5) unstable; urgency=emergency * Pull in upstream patches to fix outgoing connections after diff -Nru openafs-1.8.6/debian/patches/0020-Linux-Refactor-test-for-32bit-compat.patch openafs-1.8.6/debian/patches/0020-Linux-Refactor-test-for-32bit-compat.patch --- openafs-1.8.6/debian/patches/0020-Linux-Refactor-test-for-32bit-compat.patch 1970-01-01 00:00:00.000000000 +0000 +++ openafs-1.8.6/debian/patches/0020-Linux-Refactor-test-for-32bit-compat.patch 2021-02-16 16:54:20.000000000 +0000 @@ -0,0 +1,202 @@ +From 32cc6b0796495e596262d84c428172a511f757c4 Mon Sep 17 00:00:00 2001 +From: Cheyenne Wills +Date: Fri, 29 Jan 2021 11:32:36 -0700 +Subject: [PATCH] Linux: Refactor test for 32bit compat + +Refactor the preprocessor checks for determining the method to test for +32bit compatibility (64bit kernel performing work for a 32bit task) into +a common inline function, 'afs_in_compat_syscall' that is defined in +LINUX/osi_machdep.h. Update osi_ioctl.c and afs_syscall.c to use +afs_in_compat_syscall. + +Add include afs/sysincludes into osi_machdep.h to ensure linux/compat.h +is pulled for the functions called in afs_in_compat_syscall. + +Change-Id: I6610cc19fedd909de8e8941ded05ed1608e52403 +Reviewed-on: https://gerrit.openafs.org/14500 +Tested-by: BuildBot +Reviewed-by: Andrew Deason +Reviewed-by: Benjamin Kaduk +--- + src/afs/LINUX/osi_ioctl.c | 14 ++------ + src/afs/LINUX/osi_machdep.h | 40 +++++++++++++++++++++ + src/afs/afs_syscall.c | 70 +++---------------------------------- + 3 files changed, 47 insertions(+), 77 deletions(-) + +Index: openafs-1.8.6/src/afs/LINUX/osi_ioctl.c +=================================================================== +--- openafs-1.8.6.orig/src/afs/LINUX/osi_ioctl.c ++++ openafs-1.8.6/src/afs/LINUX/osi_ioctl.c +@@ -43,21 +43,13 @@ afs_ioctl(struct inode *inode, struct fi + { + + struct afsprocdata sysargs; +-#ifdef NEED_IOCTL32 +- struct afsprocdata32 sysargs32; +-#endif + + if (cmd != VIOC_SYSCALL && cmd != VIOC_SYSCALL32) return -EINVAL; + + #ifdef NEED_IOCTL32 +-# if defined(AFS_S390X_LINUX26_ENV) +- if (test_thread_flag(TIF_31BIT)) +-# elif defined(AFS_AMD64_LINUX20_ENV) +- if (test_thread_flag(TIF_IA32)) +-# else +- if (test_thread_flag(TIF_32BIT)) +-# endif /* AFS_S390X_LINUX26_ENV */ +- { ++ if (afs_in_compat_syscall()) { ++ struct afsprocdata32 sysargs32; ++ + if (copy_from_user(&sysargs32, (void *)arg, + sizeof(struct afsprocdata32))) + return -EFAULT; +Index: openafs-1.8.6/src/afs/LINUX/osi_machdep.h +=================================================================== +--- openafs-1.8.6.orig/src/afs/LINUX/osi_machdep.h ++++ openafs-1.8.6/src/afs/LINUX/osi_machdep.h +@@ -76,6 +76,8 @@ + #include "h/cred.h" + #endif + ++#include "afs/sysincludes.h" ++ + #if !defined(HAVE_LINUX_TIME_T) + typedef time64_t time_t; + #endif +@@ -157,6 +159,44 @@ static inline long copyinstr(char *from, + } + #define copyout(F, T, C) (copy_to_user ((char*)(T), (char*)(F), (C)) > 0 ? EFAULT : 0) + ++/* ++ * Test to see for 64/32bit compatibility mode ++ * Return non-zero if in a 64bit kernel and handing a 32bit syscall ++ */ ++#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) ++static inline int ++afs_in_compat_syscall(void) ++{ ++# if defined(AFS_SPARC64_LINUX26_ENV) ++ return test_thread_flag(TIF_32BIT); ++# elif defined(AFS_SPARC64_LINUX24_ENV) ++ return (current->thread.flags & SPARC_FLAG_32BIT) != 0; ++# elif defined(AFS_SPARC64_LINUX20_ENV) ++ return (current->tss.flags & SPARC_FLAG_32BIT) != 0; ++# elif defined(AFS_AMD64_LINUX26_ENV) ++ return test_thread_flag(TIF_IA32); ++# elif defined(AFS_AMD64_LINUX20_ENV) ++ return (current->thread.flags & THREAD_IA32) != 0; ++# elif defined(AFS_PPC64_LINUX26_ENV) ++# if defined(STRUCT_TASK_STRUCT_HAS_THREAD_INFO) ++ return (current->thread_info->flags & _TIF_32BIT) != 0; ++# else ++ return (task_thread_info(current)->flags & _TIF_32BIT) != 0; ++# endif ++# elif defined(AFS_PPC64_LINUX20_ENV) ++ return (current->thread.flags & PPC_FLAG_32BIT) != 0; ++# elif defined(AFS_S390X_LINUX26_ENV) ++ return test_thread_flag(TIF_31BIT); ++# elif defined(AFS_S390X_LINUX20_ENV) ++ return (current->thread.flags & S390_FLAG_31BIT) != 0; ++# elif defined(AFS_ARM64_LINUX26_ENV) ++ return is_compat_task(); ++# else ++# error afs_in_compat_syscall not done for this linux ++# endif ++} ++#endif /* AFS_LINUX_64BIT_KERNEL */ ++ + /* kernel print statements */ + #define printf(args...) printk(args) + #define uprintf(args...) printk(args) +Index: openafs-1.8.6/src/afs/afs_syscall.c +=================================================================== +--- openafs-1.8.6.orig/src/afs/afs_syscall.c ++++ openafs-1.8.6/src/afs/afs_syscall.c +@@ -114,40 +114,9 @@ copyin_afs_ioctl(caddr_t cmarg, struct a + #endif /* defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64) */ + + #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) +- struct afs_ioctl32 dst32; ++ if (afs_in_compat_syscall()) { ++ struct afs_ioctl32 dst32; + +-#ifdef AFS_SPARC64_LINUX26_ENV +- if (test_thread_flag(TIF_32BIT)) +-#elif defined(AFS_SPARC64_LINUX24_ENV) +- if (current->thread.flags & SPARC_FLAG_32BIT) +-#elif defined(AFS_SPARC64_LINUX20_ENV) +- if (current->tss.flags & SPARC_FLAG_32BIT) +- +-#elif defined(AFS_AMD64_LINUX26_ENV) +- if (test_thread_flag(TIF_IA32)) +-#elif defined(AFS_AMD64_LINUX20_ENV) +- if (current->thread.flags & THREAD_IA32) +- +-#elif defined(AFS_PPC64_LINUX26_ENV) +-#if defined(STRUCT_TASK_STRUCT_HAS_THREAD_INFO) +- if (current->thread_info->flags & _TIF_32BIT) +-#else +- if (task_thread_info(current)->flags & _TIF_32BIT) +-#endif +-#elif defined(AFS_PPC64_LINUX20_ENV) +- if (current->thread.flags & PPC_FLAG_32BIT) +- +-#elif defined(AFS_S390X_LINUX26_ENV) +- if (test_thread_flag(TIF_31BIT)) +-#elif defined(AFS_S390X_LINUX20_ENV) +- if (current->thread.flags & S390_FLAG_31BIT) +-#elif defined(AFS_ARM64_LINUX26_ENV) +- if (is_compat_task()) +- +-#else +-#error pioctl32 not done for this linux +-#endif +- { + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + afs_ioctl32_to_afs_ioctl(&dst32, dst); +@@ -391,40 +360,9 @@ copyin_iparam(caddr_t cmarg, struct ipar + #endif /* AFS_SUN5_64BIT_ENV */ + + #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) +- struct iparam32 dst32; ++ if (afs_in_compat_syscall()) { ++ struct iparam32 dst32; + +-#ifdef AFS_SPARC64_LINUX26_ENV +- if (test_thread_flag(TIF_32BIT)) +-#elif defined(AFS_SPARC64_LINUX24_ENV) +- if (current->thread.flags & SPARC_FLAG_32BIT) +-#elif defined(AFS_SPARC64_LINUX20_ENV) +- if (current->tss.flags & SPARC_FLAG_32BIT) +- +-#elif defined(AFS_AMD64_LINUX26_ENV) +- if (test_thread_flag(TIF_IA32)) +-#elif defined(AFS_AMD64_LINUX20_ENV) +- if (current->thread.flags & THREAD_IA32) +- +-#elif defined(AFS_PPC64_LINUX26_ENV) +-#if defined(STRUCT_TASK_STRUCT_HAS_THREAD_INFO) +- if (current->thread_info->flags & _TIF_32BIT) +-#else +- if (task_thread_info(current)->flags & _TIF_32BIT) +-#endif +-#elif defined(AFS_PPC64_LINUX20_ENV) +- if (current->thread.flags & PPC_FLAG_32BIT) +- +-#elif defined(AFS_S390X_LINUX26_ENV) +- if (test_thread_flag(TIF_31BIT)) +-#elif defined(AFS_S390X_LINUX20_ENV) +- if (current->thread.flags & S390_FLAG_31BIT) +-#elif defined(AFS_ARM64_LINUX26_ENV) +- if (is_compat_task()) +- +-#else +-#error iparam32 not done for this linux platform +-#endif +- { + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + iparam32_to_iparam(&dst32, dst); diff -Nru openafs-1.8.6/debian/patches/0021-Linux-5.11-Test-32bit-compat-with-in_compat_syscall.patch openafs-1.8.6/debian/patches/0021-Linux-5.11-Test-32bit-compat-with-in_compat_syscall.patch --- openafs-1.8.6/debian/patches/0021-Linux-5.11-Test-32bit-compat-with-in_compat_syscall.patch 1970-01-01 00:00:00.000000000 +0000 +++ openafs-1.8.6/debian/patches/0021-Linux-5.11-Test-32bit-compat-with-in_compat_syscall.patch 2021-02-16 16:54:22.000000000 +0000 @@ -0,0 +1,89 @@ +From 78ef922612bef5f5fd6904896e84b9d2ea802404 Mon Sep 17 00:00:00 2001 +From: Cheyenne Wills +Date: Fri, 22 Jan 2021 07:57:55 -0700 +Subject: [PATCH] Linux 5.11: Test 32bit compat with in_compat_syscall + +Linux 5.11 removed the TIF_IA32 thread flag with commit: + x86: Reclaim TIF_IA32 and TIF_X32 (8d71d2bf6efec) + +The flag TIF_IA32 was being used by openafs to determine if the task was +handling a syscall request from a 32 bit process. Building against a +Linux 5.11 kernel results in a build failure as TIF_IA32 is undefined. + +The function 'in_compat_syscall' was introduced in Linux 4.6 as +the preferred method to determine if a syscall needed to handle a +compatible call (e.g. 32bit application). + +To resolve the build problem, use 'in_compat_syscall' if present (Linux +4.6 and later) to determine if the syscall needs to handle a +compatibility mode call. + +Add autoconf check for in_compat_syscall. + +Notes about in_compat_syscall: + +In Linux 4.6 'in_compat_syscall' was defined for all architectures with +a generic return of 'is_compat_task', but allows architecture specific +overriding implementations (x86 and sparc). + +At 4.6 (and later), the function 'is_compat_task' is defined only for +the following architectures to return: + +Arch Returns +======= ============================== +arm64 test_thread_flag(TIF_32BIT); +mips test_thread_flag(TIF_32BIT_ADDR) +parisc test_ti_thread_flag(task_thread_info(t), TIF_32BIT) +powerpc is_32bit_task() +s390 test_thread_flag(TIF_31BIT) +sparc test_thread_flag(TIF_32BIT) + +If the Linux kernel is not built with compat mode, is_compat_task and +in_compat_syscall is set to always return 0 + +Linux commit that introduced in_compat_syscall: + compat: add in_compat_syscall to ask whether we're in a compat syscall + (5180e3e24fd3e8e7) + +Change-Id: I59deebfe5d8cddaf845b15ef69e65a684a961280 +Reviewed-on: https://gerrit.openafs.org/14499 +Reviewed-by: Andrew Deason +Reviewed-by: Benjamin Kaduk +Tested-by: BuildBot +--- + src/afs/LINUX/osi_machdep.h | 4 +++- + src/cf/linux-kernel-func.m4 | 6 ++++++ + 2 files changed, 9 insertions(+), 1 deletion(-) + +Index: openafs-1.8.6/src/afs/LINUX/osi_machdep.h +=================================================================== +--- openafs-1.8.6.orig/src/afs/LINUX/osi_machdep.h ++++ openafs-1.8.6/src/afs/LINUX/osi_machdep.h +@@ -167,7 +167,9 @@ static inline long copyinstr(char *from, + static inline int + afs_in_compat_syscall(void) + { +-# if defined(AFS_SPARC64_LINUX26_ENV) ++# if defined(HAVE_LINUX_IN_COMPAT_SYSCALL) ++ return in_compat_syscall(); ++# elif defined(AFS_SPARC64_LINUX26_ENV) + return test_thread_flag(TIF_32BIT); + # elif defined(AFS_SPARC64_LINUX24_ENV) + return (current->thread.flags & SPARC_FLAG_32BIT) != 0; +Index: openafs-1.8.6/src/cf/linux-kernel-func.m4 +=================================================================== +--- openafs-1.8.6.orig/src/cf/linux-kernel-func.m4 ++++ openafs-1.8.6/src/cf/linux-kernel-func.m4 +@@ -152,6 +152,12 @@ AC_CHECK_LINUX_FUNC([lru_cache_add_file] + [#include ], + [lru_cache_add_file(NULL);]) + ++dnl Linux 4.6 introduced in_compat_syscall as replacement for is_compat_task ++dnl for certain platforms. ++AC_CHECK_LINUX_FUNC([in_compat_syscall], ++ [#include ], ++ [in_compat_syscall();]) ++ + dnl lru_cache_add exported in Linux 5.8 + dnl replaces lru_cache_add_file + AC_CHECK_LINUX_FUNC([lru_cache_add], diff -Nru openafs-1.8.6/debian/patches/series openafs-1.8.6/debian/patches/series --- openafs-1.8.6/debian/patches/series 2021-01-14 18:49:35.000000000 +0000 +++ openafs-1.8.6/debian/patches/series 2021-02-16 16:54:16.000000000 +0000 @@ -12,3 +12,5 @@ 0012-rx-rx_InitHost-do-not-overwrite-RAND_bytes-rx_nextCi.patch 0013-rx-update_nextCid-overflow-handling-is-broken.patch 0014-Remove-overflow-check-from-update_nextCid.patch +0020-Linux-Refactor-test-for-32bit-compat.patch +0021-Linux-5.11-Test-32bit-compat-with-in_compat_syscall.patch