# git rev-parse -q --verify 03275585cabd0240944f19f33d7584a1b099a3a8^{commit} 03275585cabd0240944f19f33d7584a1b099a3a8 already have revision, skipping fetch # git checkout -q -f -B kisskb 03275585cabd0240944f19f33d7584a1b099a3a8 # git clean -qxdf # < git log -1 # commit 03275585cabd0240944f19f33d7584a1b099a3a8 # Author: David Howells # Date: Tue Jul 4 20:22:15 2023 +0100 # # afs: Fix accidental truncation when storing data # # When an AFS FS.StoreData RPC call is made, amongst other things it is # given the resultant file size to be. On the server, this is processed # by truncating the file to new size and then writing the data. # # Now, kafs has a lock (vnode->io_lock) that serves to serialise # operations against a specific vnode (ie. inode), but the parameters for # the op are set before the lock is taken. This allows two writebacks # (say sync and kswapd) to race - and if writes are ongoing the writeback # for a later write could occur before the writeback for an earlier one if # the latter gets interrupted. # # Note that afs_writepages() cannot take i_mutex and only takes a shared # lock on vnode->validate_lock. # # Also note that the server does the truncation and the write inside a # lock, so there's no problem at that end. # # Fix this by moving the calculation for the proposed new i_size inside # the vnode->io_lock. Also reset the iterator (which we might have read # from) and update the mtime setting there. # # Fixes: bd80d8a80e12 ("afs: Use ITER_XARRAY for writing") # Reported-by: Marc Dionne # Signed-off-by: David Howells # Reviewed-by: Jeffrey Altman # Reviewed-by: Marc Dionne # cc: linux-afs@lists.infradead.org # cc: linux-fsdevel@vger.kernel.org # Link: https://lore.kernel.org/r/3526895.1687960024@warthog.procyon.org.uk/ # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/korg/gcc-8.5.0-nolibc/m68k-linux/bin/m68k-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-8.5.0-nolibc/m68k-linux/bin/m68k-linux-ld --version # < git log --format=%s --max-count=1 03275585cabd0240944f19f33d7584a1b099a3a8 # make -s -j 40 ARCH=m68k O=/kisskb/build/linus_sun3_defconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.5.0-nolibc/m68k-linux/bin/m68k-linux- sun3_defconfig # < make -s -j 40 ARCH=m68k O=/kisskb/build/linus_sun3_defconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.5.0-nolibc/m68k-linux/bin/m68k-linux- help # make -s -j 40 ARCH=m68k O=/kisskb/build/linus_sun3_defconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.5.0-nolibc/m68k-linux/bin/m68k-linux- olddefconfig # make -s -j 40 ARCH=m68k O=/kisskb/build/linus_sun3_defconfig_m68k-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.5.0-nolibc/m68k-linux/bin/m68k-linux- In file included from /kisskb/src/include/linux/swab.h:5, from /kisskb/src/include/uapi/linux/byteorder/big_endian.h:14, from /kisskb/src/include/linux/byteorder/big_endian.h:5, from /kisskb/src/arch/m68k/include/uapi/asm/byteorder.h:5, from /kisskb/src/include/asm-generic/bitops/le.h:6, from /kisskb/src/arch/m68k/include/asm/bitops.h:545, from /kisskb/src/include/linux/bitops.h:68, from /kisskb/src/include/linux/kernel.h:22, from /kisskb/src/drivers/net/ethernet/i825xx/sun3_82586.c:32: /kisskb/src/drivers/net/ethernet/i825xx/sun3_82586.c: In function 'sun3_82586_timeout': /kisskb/src/drivers/net/ethernet/i825xx/sun3_82586.c:990:108: warning: array subscript 1 is above array bounds of 'volatile struct transmit_cmd_struct *[1]' [-Warray-bounds] printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status)); ~~~~~~~~~~~~^~~ /kisskb/src/include/uapi/linux/swab.h:107:12: note: in definition of macro '__swab16' __fswab16(x)) ^ /kisskb/src/include/linux/printk.h:455:26: note: in expansion of macro 'printk_index_wrap' #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__) ^~~~~~~~~~~~~~~~~ /kisskb/src/drivers/net/ethernet/i825xx/sun3_82586.c:990:3: note: in expansion of macro 'printk' printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status)); ^~~~~~ Completed OK # rm -rf /kisskb/build/linus_sun3_defconfig_m68k-gcc8 # Build took: 0:00:55.518766