diff --git a/linux-kmp.patch b/linux-kmp.patch index c6b749c..29b43ed 100644 --- a/linux-kmp.patch +++ b/linux-kmp.patch @@ -805,3 +805,367 @@ index ae406df61..c2a4278bf 100644 } static void +commit aaa7043a154d35838e65bc28473355c452339bcc +Author: Andrew Deason +Date: Thu Jan 28 16:59:47 2021 -0600 + + LINUX: Fix includes for fatal_signal_pending test + + Commit 8b6ae289 (LINUX: Avoid lookup ENOENT on fatal signals) added a + configure test for fatal_signal_pending(). However, this check fails + incorrectly ever since Linux 4.11, because fatal_signal_pending() was moved + from linux/sched.h to linux/sched/signal.h in Linux commit 2a1f062a + (sched/headers: Move signal wakeup [...]). Fix this by including + linux/sched/signal.h if we have it during the configure test. + + A false negative on this configure test doesn't break the build, but + it disables one of our safeguards preventing incorrect negative + dentries at runtime. The function fatal_signal_pending() hasn't + changed in quite some time (except for what header it lives in); it + was introduced in Linux 2.6.25 via Linux commit f776d12d (Add + fatal_signal_pending). So to try to avoid this mistake again in the + future, make it so a missing fatal_signal_pending() breaks the build + if we're on Linux 2.6.25+. + + Reviewed-on: https://gerrit.openafs.org/14508 + Reviewed-by: Benjamin Kaduk + Tested-by: BuildBot + (cherry picked from commit 0c1465e4f3310daa54f1e799f76237604222666d) + + Change-Id: I1334c060f8ab5733461ebf7c191dffa7be830021 + Reviewed-on: https://gerrit.openafs.org/14509 + Reviewed-by: Cheyenne Wills + Reviewed-by: Michael Meffie + Reviewed-by: Andrew Deason + Tested-by: BuildBot + Reviewed-by: Stephan Wiesand + +diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c +index 593086d1e..1564f8986 100644 +--- a/src/afs/LINUX/osi_vnodeops.c ++++ b/src/afs/LINUX/osi_vnodeops.c +@@ -1212,6 +1212,8 @@ filter_enoent(int code) + if (code == ENOENT && fatal_signal_pending(current)) { + return EINTR; + } ++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) ++# error fatal_signal_pending not available, but it should be + #endif + return code; + } +diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4 +index 10b7c97dd..4651b5b1a 100644 +--- a/src/cf/linux-kernel-func.m4 ++++ b/src/cf/linux-kernel-func.m4 +@@ -42,8 +42,13 @@ AC_CHECK_LINUX_FUNC([d_make_root], + AC_CHECK_LINUX_FUNC([do_sync_read], + [#include ], + [do_sync_read(NULL, NULL, 0, NULL);]) ++dnl - fatal_signal_pending introduced in 2.6.25 ++dnl - moved from linux/sched.h to linux/sched/signal.h in 4.11 + AC_CHECK_LINUX_FUNC([fatal_signal_pending], +- [#include ], ++ [#include ++ #ifdef HAVE_LINUX_SCHED_SIGNAL_H ++ # include ++ #endif], + [fatal_signal_pending(NULL);]) + AC_CHECK_LINUX_FUNC([file_dentry], + [#include ], +commit 4ad1057ab8fd206c9fa8d5e3bdde4f1a8417afdb +Author: Cheyenne Wills +Date: Fri Jan 29 11:32:36 2021 -0700 + + 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. + + Reviewed-on: https://gerrit.openafs.org/14500 + Tested-by: BuildBot + Reviewed-by: Andrew Deason + Reviewed-by: Benjamin Kaduk + (cherry picked from commit 32cc6b0796495e596262d84c428172a511f757c4) + + Change-Id: I746e5777737d49381c4a74627b79d2a61cbd4f8e + Reviewed-on: https://gerrit.openafs.org/14510 + Reviewed-by: Cheyenne Wills + Reviewed-by: Andrew Deason + Tested-by: BuildBot + Reviewed-by: Stephan Wiesand + +diff --git a/src/afs/LINUX/osi_ioctl.c b/src/afs/LINUX/osi_ioctl.c +index 9ba076a1b..7d355674d 100644 +--- a/src/afs/LINUX/osi_ioctl.c ++++ b/src/afs/LINUX/osi_ioctl.c +@@ -43,21 +43,13 @@ afs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + { + + 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; +diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h +index 784829627..9ecdaf0bf 100644 +--- a/src/afs/LINUX/osi_machdep.h ++++ b/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, char *to, int count, int *length) { + } + #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) +diff --git a/src/afs/afs_syscall.c b/src/afs/afs_syscall.c +index ce6afdf9a..9414f38b8 100644 +--- a/src/afs/afs_syscall.c ++++ b/src/afs/afs_syscall.c +@@ -114,40 +114,9 @@ copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst) + #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; +- +-#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()) ++ if (afs_in_compat_syscall()) { ++ struct afs_ioctl32 dst32; + +-#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 iparam *dst) + #endif /* AFS_SUN5_64BIT_ENV */ + + #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) +- 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()) ++ if (afs_in_compat_syscall()) { ++ struct iparam32 dst32; + +-#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); +commit ee53dd3bc087a05e22fc4111297a51ddb30013f0 +Author: Cheyenne Wills +Date: Fri Jan 22 07:57:55 2021 -0700 + + 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) + + Reviewed-on: https://gerrit.openafs.org/14499 + Reviewed-by: Andrew Deason + Reviewed-by: Benjamin Kaduk + Tested-by: BuildBot + (cherry picked from commit 78ef922612bef5f5fd6904896e84b9d2ea802404) + + Change-Id: I4eca62f19ae58fd830915feff5098cec2825f099 + Reviewed-on: https://gerrit.openafs.org/14511 + Reviewed-by: Cheyenne Wills + Tested-by: Cheyenne Wills + Reviewed-by: Stephan Wiesand + +diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h +index 9ecdaf0bf..066c1885f 100644 +--- a/src/afs/LINUX/osi_machdep.h ++++ b/src/afs/LINUX/osi_machdep.h +@@ -167,7 +167,9 @@ static inline long copyinstr(char *from, char *to, int count, int *length) { + 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; +diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4 +index 4651b5b1a..0ca3e4463 100644 +--- a/src/cf/linux-kernel-func.m4 ++++ b/src/cf/linux-kernel-func.m4 +@@ -160,6 +160,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 --git a/openafs.changes b/openafs.changes index a7191cb..d571c78 100644 --- a/openafs.changes +++ b/openafs.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Mar 4 14:57:26 UTC 2021 - Christof Hanke + +- add patches for kernel 5.11 to linux-kmp.patch + ------------------------------------------------------------------- Mon Feb 22 16:38:07 UTC 2021 - Michael Meffie