# git rev-parse -q --verify 1c24a186398f59c80adb9a967486b65c1423a59d^{commit} 1c24a186398f59c80adb9a967486b65c1423a59d already have revision, skipping fetch # git checkout -q -f -B kisskb 1c24a186398f59c80adb9a967486b65c1423a59d # git clean -qxdf # < git log -1 # commit 1c24a186398f59c80adb9a967486b65c1423a59d # Author: Linus Torvalds # Date: Tue Mar 29 15:06:39 2022 -0700 # # fs: fd tables have to be multiples of BITS_PER_LONG # # This has always been the rule: fdtables have several bitmaps in them, # and as a result they have to be sized properly for bitmaps. We walk # those bitmaps in chunks of 'unsigned long' in serveral cases, but even # when we don't, we use the regular kernel bitops that are defined to work # on arrays of 'unsigned long', not on some byte array. # # Now, the distinction between arrays of bytes and 'unsigned long' # normally only really ends up being noticeable on big-endian systems, but # Fedor Pchelkin and Alexey Khoroshilov reported that copy_fd_bitmaps() # could be called with an argument that wasn't even a multiple of # BITS_PER_BYTE. And then it fails to do the proper copy even on # little-endian machines. # # The bug wasn't in copy_fd_bitmap(), but in sane_fdtable_size(), which # didn't actually sanitize the fdtable size sufficiently, and never made # sure it had the proper BITS_PER_LONG alignment. # # That's partly because the alignment historically came not from having to # explicitly align things, but simply from previous fdtable sizes, and # from count_open_files(), which counts the file descriptors by walking # them one 'unsigned long' word at a time and thus naturally ends up doing # sizing in the proper 'chunks of unsigned long'. # # But with the introduction of close_range(), we now have an external # source of "this is how many files we want to have", and so # sane_fdtable_size() needs to do a better job. # # This also adds that explicit alignment to alloc_fdtable(), although # there it is mainly just for documentation at a source code level. The # arithmetic we do there to pick a reasonable fdtable size already aligns # the result sufficiently. # # In fact,clang notices that the added ALIGN() in that function doesn't # actually do anything, and does not generate any extra code for it. # # It turns out that gcc ends up confusing itself by combining a previous # constant-sized shift operation with the variable-sized shift operations # in roundup_pow_of_two(). And probably due to that doesn't notice that # the ALIGN() is a no-op. But that's a (tiny) gcc misfeature that doesn't # matter. Having the explicit alignment makes sense, and would actually # matter on a 128-bit architecture if we ever go there. # # This also adds big comments above both functions about how fdtable sizes # have to have that BITS_PER_LONG alignment. # # Fixes: 60997c3d45d9 ("close_range: add CLOSE_RANGE_UNSHARE") # Reported-by: Fedor Pchelkin # Reported-by: Alexey Khoroshilov # Link: https://lore.kernel.org/all/20220326114009.1690-1-aissur0002@gmail.com/ # Tested-and-acked-by: Christian Brauner # Signed-off-by: Linus Torvalds # < /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 1c24a186398f59c80adb9a967486b65c1423a59d # < make -s -j 10 ARCH=m68k O=/kisskb/build/linus_m68k-allmodconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux- allmodconfig # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # Added to kconfig CONFIG_SAMPLES=n # < make -s -j 10 ARCH=m68k O=/kisskb/build/linus_m68k-allmodconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux- help # make -s -j 10 ARCH=m68k O=/kisskb/build/linus_m68k-allmodconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux- olddefconfig # make -s -j 10 ARCH=m68k O=/kisskb/build/linus_m68k-allmodconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux- In file included from /kisskb/src/include/linux/bitops.h:33, from /kisskb/src/include/linux/thread_info.h:27, from /kisskb/src/include/asm-generic/preempt.h:5, from ./arch/m68k/include/generated/asm/preempt.h:1, from /kisskb/src/include/linux/preempt.h:78, from /kisskb/src/arch/m68k/include/asm/irqflags.h:6, from /kisskb/src/include/linux/irqflags.h:16, from /kisskb/src/arch/m68k/include/asm/atomic.h:6, from /kisskb/src/include/linux/atomic.h:7, from /kisskb/src/include/linux/rcupdate.h:25, from /kisskb/src/include/linux/rculist.h:11, from /kisskb/src/include/linux/pid.h:5, from /kisskb/src/include/linux/sched.h:14, from /kisskb/src/include/linux/ratelimit.h:6, from /kisskb/src/include/linux/dev_printk.h:16, from /kisskb/src/include/linux/device.h:15, from /kisskb/src/include/linux/dma-mapping.h:7, from /kisskb/src/drivers/net/ipa/ipa_mem.c:10: /kisskb/src/drivers/net/ipa/ipa_mem.c: In function 'ipa_mem_init': /kisskb/src/arch/m68k/include/asm/bitops.h:329:20: error: array subscript 2 is above array bounds of 'long unsigned int[1]' [-Werror=array-bounds] while (!(num = ~*p++)) { ~^~ cc1: all warnings being treated as errors make[4]: *** [/kisskb/src/scripts/Makefile.build:289: drivers/net/ipa/ipa_mem.o] Error 1 make[3]: *** [/kisskb/src/scripts/Makefile.build:551: drivers/net/ipa] Error 2 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [/kisskb/src/scripts/Makefile.build:551: drivers/net] Error 2 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [/kisskb/src/Makefile:1830: drivers] Error 2 make: *** [Makefile:219: __sub-make] Error 2 Command 'make -s -j 10 ARCH=m68k O=/kisskb/build/linus_m68k-allmodconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/m68k-linux/bin/m68k-linux- ' returned non-zero exit status 2 # rm -rf /kisskb/build/linus_m68k-allmodconfig_m68k-gcc8 # Build took: 0:13:24.599725