android_kernel_motorola_sm6375/Documentation
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Al Viro 0785e29899 rename(): fix the locking of subdirectories
commit 22e111ed6c83dcde3037fc81176012721bc34c0b upstream.

	We should never lock two subdirectories without having taken
->s_vfs_rename_mutex; inode pointer order or not, the "order" proposed
in 28eceeda130f "fs: Lock moved directories" is not transitive, with
the usual consequences.

	The rationale for locking renamed subdirectory in all cases was
the possibility of race between rename modifying .. in a subdirectory to
reflect the new parent and another thread modifying the same subdirectory.
For a lot of filesystems that's not a problem, but for some it can lead
to trouble (e.g. the case when short directory contents is kept in the
inode, but creating a file in it might push it across the size limit
and copy its contents into separate data block(s)).

	However, we need that only in case when the parent does change -
otherwise ->rename() doesn't need to do anything with .. entry in the
first place.  Some instances are lazy and do a tautological update anyway,
but it's really not hard to avoid.

Amended locking rules for rename():
	find the parent(s) of source and target
	if source and target have the same parent
		lock the common parent
	else
		lock ->s_vfs_rename_mutex
		lock both parents, in ancestor-first order; if neither
		is an ancestor of another, lock the parent of source
		first.
	find the source and target.
	if source and target have the same parent
		if operation is an overwriting rename of a subdirectory
			lock the target subdirectory
	else
		if source is a subdirectory
			lock the source
		if target is a subdirectory
			lock the target
	lock non-directories involved, in inode pointer order if both
	source and target are such.

That way we are guaranteed that parents are locked (for obvious reasons),
that any renamed non-directory is locked (nfsd relies upon that),
that any victim is locked (emptiness check needs that, among other things)
and subdirectory that changes parent is locked (needed to protect the update
of .. entries).  We are also guaranteed that any operation locking more
than one directory either takes ->s_vfs_rename_mutex or locks a parent
followed by its child.

Cc: stable@vger.kernel.org
Fixes: 28eceeda130f "fs: Lock moved directories"
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-23 08:24:49 +01:00
..
ABI x86/speculation: Add Gather Data Sampling mitigation 2023-08-08 19:56:35 +02:00
accounting psi: Fix uaf issue when psi trigger is destroyed while being polled 2022-02-05 12:35:36 +01:00
admin-guide Documentation: sysctl: align cells in second content column 2023-10-25 11:53:20 +02:00
arm
arm64 perf/smmuv3: Enable HiSilicon Erratum 162001900 quirk for HIP08/09 2023-09-23 11:00:03 +02:00
block
bpf
cdrom
core-api XArray: add xas_split 2021-06-10 13:37:14 +02:00
cpu-freq
crypto
dev-tools docs/scripts/gdb: add necessary make scripts_gdb step 2023-03-11 16:43:57 +01:00
devicetree firmware: ti_sci: Replace HTTP links with HTTPS ones 2023-11-20 10:30:12 +01:00
doc-guide
driver-api spi: Update reference to struct spi_controller 2023-01-18 11:41:01 +01:00
EDID
fault-injection debugfs: fix error when writing negative value to atomic_t debugfs file 2023-01-18 11:40:56 +01:00
fb
features
filesystems rename(): fix the locking of subdirectories 2024-02-23 08:24:49 +01:00
firmware-guide Documentation: ACPI: EINJ: Fix obsolete example 2022-08-25 11:18:21 +02:00
firmware_class
fpga
gpu
hid
hwmon Revert "hwmon: Make chip parameter for with_info API mandatory" 2022-06-25 12:44:36 +02:00
i2c
ia64
ide
iio
infiniband
input Input: iforce - add support for Boeder Force Feedback Wheel 2022-09-20 12:27:59 +02:00
ioctl Remove DECnet support from kernel 2023-06-21 15:44:10 +02:00
isdn
kbuild
kernel-hacking
leds
livepatch
locking
m68k
maintainer
media media: uapi: add MEDIA_BUS_FMT_METADATA_FIXED media bus format. 2023-05-17 11:35:36 +02:00
mic
mips
misc-devices
netlabel
networking xsk: Honor SO_BINDTODEVICE on bind 2023-07-27 08:37:23 +02:00
nios2
openrisc
parisc
PCI
pcmcia
power PM: runtime: Add pm_runtime_get_if_active() 2023-08-30 16:27:12 +02:00
powerpc
process docs: update mediator contact information in CoC doc 2022-11-25 17:42:20 +01:00
RCU
riscv
s390
scheduler
scsi
security
sh
sound ALSA: hda/sigmatel: add pin overrides for Intel DP45SG motherboard 2023-04-20 12:07:35 +02:00
sparc
sphinx docs: Fix the docs build with Sphinx 6.0 2023-01-18 11:42:01 +01:00
sphinx-static
spi
target
timers
trace tracing/histogram: Update document for KEYS_MAX size 2022-11-10 17:57:55 +01:00
translations
usb
userspace-api Documentation: seccomp: Fix user notification documentation 2021-06-03 08:59:03 +02:00
virt KVM: s390: disable migration mode when dirty tracking is disabled 2023-03-11 16:44:01 +01:00
virtual
vm arm: remove CONFIG_ARCH_HAS_HOLES_MEMORYMODEL 2022-05-15 19:54:46 +02:00
w1
watchdog
x86
xtensa
.gitignore
asm-annotations.rst
atomic_bitops.txt locking/atomic: Make test_and_*_bit() ordered on failure 2022-08-25 11:18:31 +02:00
atomic_t.txt
bus-virt-phys-mapping.txt
Changes
CodingStyle
conf.py docs/conf.py: Cope with removal of language=None in Sphinx 5.0.0 2022-06-14 18:11:49 +02:00
COPYING-logo
crc32.txt
debugging-modules.txt
debugging-via-ohci1394.txt
digsig.txt
DMA-API-HOWTO.txt
DMA-API.txt
DMA-attributes.txt Reinstate some of "swiotlb: rework "fix info leak with DMA_FROM_DEVICE"" 2022-05-25 09:14:38 +02:00
DMA-ISA-LPC.txt
docutils.conf
dontdiff
futex-requeue-pi.txt
hwspinlock.txt
index.rst
io-mapping.txt
io_ordering.txt
IPMI.txt
IRQ-affinity.txt
IRQ-domain.txt
IRQ.txt
irqflags-tracing.txt
Kconfig
kobject.txt
kprobes.txt
kref.txt
logo.gif
lzo.txt
mailbox.txt
Makefile
memory-barriers.txt
nommu-mmap.txt
padata.txt
percpu-rw-semaphore.txt
pi-futex.txt
preempt-locking.txt
rbtree.txt
remoteproc.txt
robust-futex-ABI.txt
robust-futexes.txt
rpmsg.txt
speculation.txt
static-keys.txt
SubmittingPatches
tee.txt
this_cpu_ops.txt
unaligned-memory-access.txt
xz.txt