# git rev-parse -q --verify 0be0ee71816b2b6725e2b4f32ad6726c9d729777^{commit} 0be0ee71816b2b6725e2b4f32ad6726c9d729777 already have revision, skipping fetch # git checkout -q -f -B kisskb 0be0ee71816b2b6725e2b4f32ad6726c9d729777 # git clean -qxdf # < git log -1 # commit 0be0ee71816b2b6725e2b4f32ad6726c9d729777 # Author: Linus Torvalds # Date: Mon Nov 11 15:51:03 2019 -0800 # # vfs: properly and reliably lock f_pos in fdget_pos() # # fdget_pos() is used by file operations that will read and update f_pos: # things like "read()", "write()" and "lseek()" (but not, for example, # "pread()/pwrite" that get their file positions elsewhere). # # However, it had two separate escape clauses for this, because not # everybody wants or needs serialization of the file position. # # The first and most obvious case is the "file descriptor doesn't have a # position at all", ie a stream-like file. Except we didn't actually use # FMODE_STREAM, but instead used FMODE_ATOMIC_POS. The reason for that # was that FMODE_STREAM didn't exist back in the days, but also that we # didn't want to mark all the special cases, so we only marked the ones # that _required_ position atomicity according to POSIX - regular files # and directories. # # The case one was intentionally lazy, but now that we _do_ have # FMODE_STREAM we could and should just use it. With the change to use # FMODE_STREAM, there are no remaining uses for FMODE_ATOMIC_POS, and all # the code to set it is deleted. # # Any cases where we don't want the serialization because the driver (or # subsystem) doesn't use the file position should just be updated to do # "stream_open()". We've done that for all the obvious and common # situations, we may need a few more. Quoting Kirill Smelkov in the # original FMODE_STREAM thread (see link below for full email): # # "And I appreciate if people could help at least somehow with "getting # rid of mixed case entirely" (i.e. always lock f_pos_lock on # !FMODE_STREAM), because this transition starts to diverge from my # particular use-case too far. To me it makes sense to do that # transition as follows: # # - convert nonseekable_open -> stream_open via stream_open.cocci; # - audit other nonseekable_open calls and convert left users that # truly don't depend on position to stream_open; # - extend stream_open.cocci to analyze alloc_file_pseudo as well (this # will cover pipes and sockets), or maybe convert pipes and sockets # to FMODE_STREAM manually; # - extend stream_open.cocci to analyze file_operations that use # no_llseek or noop_llseek, but do not use nonseekable_open or # alloc_file_pseudo. This might find files that have stream semantic # but are opened differently; # - extend stream_open.cocci to analyze file_operations whose # .read/.write do not use ppos at all (independently of how file was # opened); # - ... # - after that remove FMODE_ATOMIC_POS and always take f_pos_lock if # !FMODE_STREAM; # - gather bug reports for deadlocked read/write and convert missed # cases to FMODE_STREAM, probably extending stream_open.cocci along # the road to catch similar cases # # i.e. always take f_pos_lock unless a file is explicitly marked as # being stream, and try to find and cover all files that are streams" # # We have not done the "extend stream_open.cocci to analyze # alloc_file_pseudo" as well, but the previous commit did manually handle # the case of pipes and sockets. # # The other case where we can avoid locking f_pos is the "this file # descriptor only has a single user and it is us, and thus there is no # need to lock it". # # The second test was correct, although a bit subtle and worth just # re-iterating here. There are two kinds of other sources of references # to the same file descriptor: file descriptors that have been explicitly # shared across fork() or with dup(), and file tables having elevated # reference counts due to threading (or explicit file sharing with # clone()). # # The first case would have incremented the file count explicitly, and in # the second case the previous __fdget() would have incremented it for us # and set the FDPUT_FPUT flag. # # But in both cases the file count would be greater than one, so the # "file_count(file) > 1" test catches both situations. Also note that if # file_count is 1, that also means that no other thread can have access to # the file table, so there also cannot be races with concurrent calls to # dup()/fork()/clone() that would increment the file count any other way. # # Link: https://lore.kernel.org/linux-fsdevel/20190413184404.GA13490@deco.navytux.spb.ru # Cc: Kirill Smelkov # Cc: Eic Dumazet # Cc: Al Viro # Cc: Alan Stern # Cc: Marco Elver # Cc: Andrea Parri # Cc: Paul McKenney # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/br-xtensa-full-2016.08-613-ge98b4dd/bin/xtensa-linux-gcc --version # < /opt/cross/kisskb/br-xtensa-full-2016.08-613-ge98b4dd/bin/xtensa-linux-ld --version # < git log --format=%s --max-count=1 0be0ee71816b2b6725e2b4f32ad6726c9d729777 # < make -s -j 80 ARCH=xtensa O=/kisskb/build/linus_xtensa-allmodconfig_xtensa CROSS_COMPILE=/opt/cross/kisskb/br-xtensa-full-2016.08-613-ge98b4dd/bin/xtensa-linux- allmodconfig # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # Added to kconfig CONFIG_SAMPLES=n # yes \n | make -s -j 80 ARCH=xtensa O=/kisskb/build/linus_xtensa-allmodconfig_xtensa CROSS_COMPILE=/opt/cross/kisskb/br-xtensa-full-2016.08-613-ge98b4dd/bin/xtensa-linux- oldconfig yes: standard output: Broken pipe # make -s -j 80 ARCH=xtensa O=/kisskb/build/linus_xtensa-allmodconfig_xtensa CROSS_COMPILE=/opt/cross/kisskb/br-xtensa-full-2016.08-613-ge98b4dd/bin/xtensa-linux- usr/include/asm/setup.h:17: userspace cannot reference function or variable defined in the kernel /kisskb/src/drivers/char/tpm/tpm2-cmd.c: In function 'tpm2_unseal_trusted': /kisskb/src/drivers/char/tpm/tpm2-cmd.c:669:2: warning: 'blob_handle' may be used uninitialized in this function [-Wmaybe-uninitialized] tpm2_flush_context(chip, blob_handle); ^ /kisskb/src/drivers/input/joystick/analog.c:160:2: warning: #warning Precise timer not defined for this architecture. [-Wcpp] #warning Precise timer not defined for this architecture. ^ /kisskb/src/drivers/i2c/busses/i2c-sh_mobile.c: In function 'sh_mobile_i2c_isr': /kisskb/src/drivers/i2c/busses/i2c-sh_mobile.c:399:26: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized] pd->msg->buf[real_pos] = data; ^ /kisskb/src/drivers/i2c/busses/i2c-sh_mobile.c:372:16: note: 'data' was declared here unsigned char data; ^ In file included from /kisskb/src/include/linux/wait.h:9:0, from /kisskb/src/include/linux/net.h:19, from /kisskb/src/drivers/infiniband/sw/siw/siw_qp_rx.c:8: /kisskb/src/drivers/infiniband/sw/siw/siw_qp_rx.c: In function 'siw_proc_send': /kisskb/src/include/linux/spinlock.h:288:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized] _raw_spin_unlock_irqrestore(lock, flags); \ ^ /kisskb/src/drivers/infiniband/sw/siw/siw_qp_rx.c:335:16: note: 'flags' was declared here unsigned long flags; ^ In file included from /kisskb/src/arch/xtensa/include/asm/atomic.h:19:0, from /kisskb/src/include/linux/atomic.h:7, from /kisskb/src/include/asm-generic/bitops/atomic.h:5, from /kisskb/src/arch/xtensa/include/asm/bitops.h:339, from /kisskb/src/include/linux/bitops.h:26, from /kisskb/src/include/linux/kernel.h:12, from /kisskb/src/include/linux/list.h:9, from /kisskb/src/include/linux/wait.h:7, 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/xtensa/include/asm/cmpxchg.h:172:3: warning: value computed is not used [-Wunused-value] ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) ^ /kisskb/src/fs/ocfs2/file.c:2421:3: note: in expansion of macro 'xchg' xchg(&iocb->ki_complete, saved_ki_complete); ^ In file included from /kisskb/src/drivers/net/phy/mdio-cavium.c:11:0: /kisskb/src/drivers/net/phy/mdio-cavium.c: In function 'cavium_mdiobus_set_mode': /kisskb/src/drivers/net/phy/mdio-cavium.h:114:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_readq(addr) readq((void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:21:16: note: in expansion of macro 'oct_mdio_readq' smi_clk.u64 = oct_mdio_readq(p->register_base + SMI_CLK); ^ /kisskb/src/drivers/net/phy/mdio-cavium.h:113:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:24:2: note: in expansion of macro 'oct_mdio_writeq' oct_mdio_writeq(smi_clk.u64, p->register_base + SMI_CLK); ^ /kisskb/src/drivers/net/phy/mdio-cavium.c: In function 'cavium_mdiobus_c45_addr': /kisskb/src/drivers/net/phy/mdio-cavium.h:113:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:39:2: note: in expansion of macro 'oct_mdio_writeq' oct_mdio_writeq(smi_wr.u64, p->register_base + SMI_WR_DAT); ^ /kisskb/src/drivers/net/phy/mdio-cavium.h:113:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:47:2: note: in expansion of macro 'oct_mdio_writeq' oct_mdio_writeq(smi_cmd.u64, p->register_base + SMI_CMD); ^ /kisskb/src/drivers/net/phy/mdio-cavium.h:114:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_readq(addr) readq((void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:54:16: note: in expansion of macro 'oct_mdio_readq' smi_wr.u64 = oct_mdio_readq(p->register_base + SMI_WR_DAT); ^ /kisskb/src/drivers/net/phy/mdio-cavium.c: In function 'cavium_mdiobus_read': /kisskb/src/drivers/net/phy/mdio-cavium.h:113:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:86:2: note: in expansion of macro 'oct_mdio_writeq' oct_mdio_writeq(smi_cmd.u64, p->register_base + SMI_CMD); ^ /kisskb/src/drivers/net/phy/mdio-cavium.h:114:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_readq(addr) readq((void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:93:16: note: in expansion of macro 'oct_mdio_readq' smi_rd.u64 = oct_mdio_readq(p->register_base + SMI_RD_DAT); ^ /kisskb/src/drivers/net/phy/mdio-cavium.c: In function 'cavium_mdiobus_write': /kisskb/src/drivers/net/phy/mdio-cavium.h:113:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:125:2: note: in expansion of macro 'oct_mdio_writeq' oct_mdio_writeq(smi_wr.u64, p->register_base + SMI_WR_DAT); ^ /kisskb/src/drivers/net/phy/mdio-cavium.h:113:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:131:2: note: in expansion of macro 'oct_mdio_writeq' oct_mdio_writeq(smi_cmd.u64, p->register_base + SMI_CMD); ^ /kisskb/src/drivers/net/phy/mdio-cavium.h:114:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_readq(addr) readq((void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-cavium.c:138:16: note: in expansion of macro 'oct_mdio_readq' smi_wr.u64 = oct_mdio_readq(p->register_base + SMI_WR_DAT); ^ /kisskb/src/drivers/net/phy/mdio-octeon.c: In function 'octeon_mdiobus_probe': /kisskb/src/drivers/net/phy/mdio-octeon.c:48:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] (u64)devm_ioremap(&pdev->dev, mdio_phys, regsize); ^ In file included from /kisskb/src/drivers/net/phy/mdio-octeon.c:14:0: /kisskb/src/drivers/net/phy/mdio-cavium.h:113:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-octeon.c:56:2: note: in expansion of macro 'oct_mdio_writeq' oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); ^ /kisskb/src/drivers/net/phy/mdio-cavium.h:113:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-octeon.c:77:2: note: in expansion of macro 'oct_mdio_writeq' oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); ^ /kisskb/src/drivers/net/phy/mdio-octeon.c: In function 'octeon_mdiobus_remove': /kisskb/src/drivers/net/phy/mdio-cavium.h:113:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr) ^ /kisskb/src/drivers/net/phy/mdio-octeon.c:91:2: note: in expansion of macro 'oct_mdio_writeq' oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); ^ In file included from /kisskb/src/include/linux/rwsem.h:16:0, from /kisskb/src/include/linux/notifier.h:15, from /kisskb/src/include/linux/clk.h:14, from /kisskb/src/drivers/tty/serial/sh-sci.c:24: /kisskb/src/drivers/tty/serial/sh-sci.c: In function 'sci_dma_rx_submit': /kisskb/src/include/linux/spinlock.h:288:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized] _raw_spin_unlock_irqrestore(lock, flags); \ ^ /kisskb/src/drivers/tty/serial/sh-sci.c:1351:16: note: 'flags' was declared here unsigned long flags; ^ In file included from /kisskb/src/arch/xtensa/include/asm/atomic.h:19:0, from /kisskb/src/include/linux/atomic.h:7, from /kisskb/src/include/asm-generic/bitops/atomic.h:5, from /kisskb/src/arch/xtensa/include/asm/bitops.h:339, from /kisskb/src/include/linux/bitops.h:26, from /kisskb/src/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:11: /kisskb/src/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c: In function 'ixgbevf_xdp_setup': /kisskb/src/arch/xtensa/include/asm/cmpxchg.h:172:3: warning: value computed is not used [-Wunused-value] ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) ^ /kisskb/src/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:4482:4: note: in expansion of macro 'xchg' xchg(&adapter->rx_ring[i]->xdp_prog, adapter->xdp_prog); ^ /kisskb/src/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c: In function 'mlx5e_grp_sw_update_stats': /kisskb/src/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c:302:1: warning: the frame size of 1232 bytes is larger than 1024 bytes [-Wframe-larger-than=] } ^ Completed OK # rm -rf /kisskb/build/linus_xtensa-allmodconfig_xtensa # Build took: 0:12:55.977970