linux/tools
Günther Noack b9f5ce27c8
landlock: Support file truncation
Introduce the LANDLOCK_ACCESS_FS_TRUNCATE flag for file truncation.

This flag hooks into the path_truncate, file_truncate and
file_alloc_security LSM hooks and covers file truncation using
truncate(2), ftruncate(2), open(2) with O_TRUNC, as well as creat().

This change also increments the Landlock ABI version, updates
corresponding selftests, and updates code documentation to document
the flag.

In security/security.c, allocate security blobs at pointer-aligned
offsets. This fixes the problem where one LSM's security blob can
shift another LSM's security blob to an unaligned address (reported
by Nathan Chancellor).

The following operations are restricted:

open(2): requires the LANDLOCK_ACCESS_FS_TRUNCATE right if a file gets
implicitly truncated as part of the open() (e.g. using O_TRUNC).

Notable special cases:
* open(..., O_RDONLY|O_TRUNC) can truncate files as well in Linux
* open() with O_TRUNC does *not* need the TRUNCATE right when it
  creates a new file.

truncate(2) (on a path): requires the LANDLOCK_ACCESS_FS_TRUNCATE
right.

ftruncate(2) (on a file): requires that the file had the TRUNCATE
right when it was previously opened. File descriptors acquired by
other means than open(2) (e.g. memfd_create(2)) continue to support
truncation with ftruncate(2).

Cc: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Günther Noack <gnoack3000@gmail.com>
Acked-by: Paul Moore <paul@paul-moore.com> (LSM)
Link: https://lore.kernel.org/r/20221018182216.301684-5-gnoack3000@gmail.com
Signed-off-by: Mickaël Salaün <mic@digikod.net>
2022-10-19 09:01:44 +02:00
..
accounting
arch tools arch x86: Sync the msr-index.h copy with the kernel sources 2022-10-15 10:13:16 -03:00
bootconfig
bpf Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-10-03 17:44:18 -07:00
build tools build: Display logical OR of a feature flavors 2022-10-04 08:55:19 -03:00
certs
cgroup iocost_monitor: reorder BlkgIterator 2022-09-23 16:57:10 -10:00
counter
debugging tools: Add new "test" taint to kernel-chktaint 2022-09-07 14:51:12 -06:00
edid
firewire
firmware
gpio
hv tools: hv: kvp: remove unnecessary (void*) conversions 2022-09-05 16:55:20 +00:00
iio iio: event_monitor: add pitch, yaw and roll modifiers 2022-09-21 18:42:55 +01:00
include perf tools changes for v6.1: 1st batch 2022-10-11 15:02:25 -07:00
io_uring
kvm/kvm_stat
laptop
leds
lib libperf: Do not include non-UAPI linux/compiler.h header 2022-10-14 10:44:20 -03:00
memory-model tools/memory-model: Clarify LKMM's limitations in litmus-tests.txt 2022-08-31 05:15:31 -07:00
objtool - Yu Zhao's Multi-Gen LRU patches are here. They've been under test in 2022-10-10 17:53:04 -07:00
pci
pcmcia
perf perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet 2022-10-15 10:13:16 -03:00
power More power management updates for 6.1-rc1 2022-10-10 13:39:03 -07:00
rcu
scripts
spi
testing landlock: Support file truncation 2022-10-19 09:01:44 +02:00
thermal tools/thermal: Fix possible path truncations 2022-08-03 19:28:46 +02:00
time
tracing rtla: Consolidate and show all necessary libraries that failed for building 2022-08-10 12:03:02 -04:00
usb
verification rv/monitor: Add __init/__exit annotations to module init/exit funcs 2022-09-26 18:10:51 -04:00
virtio virtio_test: fixup for vq reset 2022-09-27 18:30:49 -04:00
vm tools/vm/page_owner_sort: fix -f option 2022-09-11 20:25:51 -07:00
wmi
Makefile