# git rev-parse -q --verify 8c1684bb81f173543599f1848c29a2a3b1ee5907^{commit} 8c1684bb81f173543599f1848c29a2a3b1ee5907 already have revision, skipping fetch # git checkout -q -f -B kisskb 8c1684bb81f173543599f1848c29a2a3b1ee5907 # git clean -qxdf # < git log -1 # commit 8c1684bb81f173543599f1848c29a2a3b1ee5907 # Merge: f44d5c489051 3f2c788a1314 # Author: Linus Torvalds # Date: Thu May 14 11:52:28 2020 -0700 # # Merge tag 'for-linus-2020-05-13' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux # # Pull thread fix from Christian Brauner: # "This contains a single fix for all exported legacy fork helpers to # block accidental access to clone3() features in the upper 32 bits of # their respective flags arguments. # # I got Cced on a glibc issue where someone reported consistent failures # for the legacy clone() syscall on ppc64le when sign extension was # performed (since the clone() syscall in glibc exposes the flags # argument as an int whereas the kernel uses unsigned long). # # The legacy clone() syscall is odd in a bunch of ways and here two # things interact: # # - First, legacy clone's flag argument is word-size dependent, i.e. # it's an unsigned long whereas most system calls with flag arguments # use int or unsigned int. # # - Second, legacy clone() ignores unknown and deprecated flags. # # The two of them taken together means that users on 64bit systems can # pass garbage for the upper 32bit of the clone() syscall since forever # and things would just work fine. # # The following program compiled on a 64bit kernel prior to v5.7-rc1 # will succeed and will fail post v5.7-rc1 with EBADF: # # int main(int argc, char *argv[]) # { # pid_t pid; # # /* Note that legacy clone() has different argument ordering on # * different architectures so this won't work everywhere. # * # * Only set the upper 32 bits. # */ # pid = syscall(__NR_clone, 0xffffffff00000000 | SIGCHLD, # NULL, NULL, NULL, NULL); # if (pid < 0) # exit(EXIT_FAILURE); # if (pid == 0) # exit(EXIT_SUCCESS); # if (wait(NULL) != pid) # exit(EXIT_FAILURE); # # exit(EXIT_SUCCESS); # } # # Since legacy clone() couldn't be extended this was not a problem so # far and nobody really noticed or cared since nothing in the kernel # ever bothered to look at the upper 32 bits. # # But once we introduced clone3() and expanded the flag argument in # struct clone_args to 64 bit we opened this can of worms. With the # first flag-based extension to clone3() making use of the upper 32 bits # of the flag argument we've effectively made it possible for the legacy # clone() syscall to reach clone3() only flags on accident. The sign # extension scenario is just the odd corner-case that we needed to # figure this out. # # The reason we just realized this now and not already when we # introduced CLONE_CLEAR_SIGHAND was that CLONE_INTO_CGROUP assumes that # a valid cgroup file descriptor has been given - whereas # CLONE_CLEAR_SIGHAND doesn't need to verify anything. It just silently # resets the signal handlers to SIG_DFL. # # So the sign extension (or the user accidently passing garbage for the # upper 32 bits) caused the CLONE_INTO_CGROUP bit to be raised and the # kernel to error out when it didn't find a valid cgroup file # descriptor. # # Note, I'm also capping kernel_thread()'s flag argument mainly because # none of the new features make sense for kernel_thread() and we # shouldn't risk them being accidently activated however unlikely. If we # wanted to, we could even make kernel_thread() yell when an unknown # flag has been set which it doesn't do right now. But it's not worth # risking this in a bugfix imho" # # * tag 'for-linus-2020-05-13' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux: # fork: prevent accidental access to clone3 features # < /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux-ld --version # < git log --format=%s --max-count=1 8c1684bb81f173543599f1848c29a2a3b1ee5907 # < make -s -j 48 ARCH=m68k O=/kisskb/build/linus_sun3_defconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux- sun3_defconfig WARNING: unmet direct dependencies detected for NEED_MULTIPLE_NODES Depends on [n]: DISCONTIGMEM [=n] || NUMA Selected by [y]: - SINGLE_MEMORY_CHUNK [=y] && MMU [=y] WARNING: unmet direct dependencies detected for NEED_MULTIPLE_NODES Depends on [n]: DISCONTIGMEM [=n] || NUMA Selected by [y]: - SINGLE_MEMORY_CHUNK [=y] && MMU [=y] # < make -s -j 48 ARCH=m68k O=/kisskb/build/linus_sun3_defconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux- help # make -s -j 48 ARCH=m68k O=/kisskb/build/linus_sun3_defconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux- olddefconfig WARNING: unmet direct dependencies detected for NEED_MULTIPLE_NODES Depends on [n]: DISCONTIGMEM [=n] || NUMA Selected by [y]: - SINGLE_MEMORY_CHUNK [=y] && MMU [=y] WARNING: unmet direct dependencies detected for NEED_MULTIPLE_NODES Depends on [n]: DISCONTIGMEM [=n] || NUMA Selected by [y]: - SINGLE_MEMORY_CHUNK [=y] && MMU [=y] # make -s -j 48 ARCH=m68k O=/kisskb/build/linus_sun3_defconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux- In file included from /kisskb/src/arch/m68k/include/asm/atomic.h:7, from /kisskb/src/include/linux/atomic.h:7, from /kisskb/src/include/linux/spinlock.h:460, from /kisskb/src/include/linux/seqlock.h:36, from /kisskb/src/include/linux/time.h:6, from /kisskb/src/include/linux/stat.h:19, from /kisskb/src/include/linux/module.h:13, from /kisskb/src/net/core/filter.c:20: /kisskb/src/net/core/filter.c: In function 'bpf_clear_redirect_map': /kisskb/src/arch/m68k/include/asm/cmpxchg.h:137:3: warning: value computed is not used [-Wunused-value] ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (unsigned long)(n), sizeof(*(ptr)))) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /kisskb/src/include/asm-generic/cmpxchg.h:106:28: note: in expansion of macro 'cmpxchg_local' #define cmpxchg(ptr, o, n) cmpxchg_local((ptr), (o), (n)) ^~~~~~~~~~~~~ /kisskb/src/net/core/filter.c:3529:4: note: in expansion of macro 'cmpxchg' cmpxchg(&ri->map, map, NULL); ^~~~~~~ In file included from /kisskb/src/arch/m68k/include/asm/atomic.h:7, from /kisskb/src/include/linux/atomic.h:7, from /kisskb/src/include/linux/spinlock.h:460, from /kisskb/src/include/linux/mmzone.h:8, from /kisskb/src/include/linux/gfp.h:6, from /kisskb/src/include/linux/mm.h:10, from /kisskb/src/kernel/acct.c:47: /kisskb/src/kernel/acct.c: In function 'acct_pin_kill': /kisskb/src/arch/m68k/include/asm/cmpxchg.h:137:3: warning: value computed is not used [-Wunused-value] ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (unsigned long)(n), sizeof(*(ptr)))) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /kisskb/src/include/asm-generic/cmpxchg.h:106:28: note: in expansion of macro 'cmpxchg_local' #define cmpxchg(ptr, o, n) cmpxchg_local((ptr), (o), (n)) ^~~~~~~~~~~~~ /kisskb/src/kernel/acct.c:177:2: note: in expansion of macro 'cmpxchg' cmpxchg(&acct->ns->bacct, pin, NULL); ^~~~~~~ In file included from /kisskb/src/arch/m68k/include/asm/atomic.h:7, from /kisskb/src/include/linux/atomic.h:7, from /kisskb/src/include/linux/spinlock.h:460, from /kisskb/src/include/linux/wait.h:9, from /kisskb/src/include/linux/wait_bit.h:8, from /kisskb/src/include/linux/fs.h:6, from /kisskb/src/fs/ocfs2/file.c:13: /kisskb/src/fs/ocfs2/file.c: In function 'ocfs2_file_write_iter': /kisskb/src/arch/m68k/include/asm/cmpxchg.h:79:22: warning: value computed is not used [-Wunused-value] #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /kisskb/src/fs/ocfs2/file.c:2419:3: note: in expansion of macro 'xchg' xchg(&iocb->ki_complete, saved_ki_complete); ^~~~ In file included from /kisskb/src/arch/m68k/include/asm/atomic.h:7, from /kisskb/src/include/linux/atomic.h:7, from /kisskb/src/include/linux/spinlock.h:460, from /kisskb/src/include/linux/mmzone.h:8, from /kisskb/src/include/linux/gfp.h:6, from /kisskb/src/include/linux/slab.h:15, from /kisskb/src/fs/posix_acl.c:15: /kisskb/src/fs/posix_acl.c: In function 'get_acl': /kisskb/src/arch/m68k/include/asm/cmpxchg.h:137:3: warning: value computed is not used [-Wunused-value] ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (unsigned long)(n), sizeof(*(ptr)))) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /kisskb/src/include/asm-generic/cmpxchg.h:106:28: note: in expansion of macro 'cmpxchg_local' #define cmpxchg(ptr, o, n) cmpxchg_local((ptr), (o), (n)) ^~~~~~~~~~~~~ /kisskb/src/fs/posix_acl.c:148:3: note: in expansion of macro 'cmpxchg' cmpxchg(p, sentinel, ACL_NOT_CACHED); ^~~~~~~ Completed OK # rm -rf /kisskb/build/linus_sun3_defconfig_m68k-gcc8 # Build took: 0:01:57.113562