android_kernel_google_msm/security
Jeff Layton 45ab3fb2a2 locks: add new fcntl cmd values for handling file private locks
Due to some unfortunate history, POSIX locks have very strange and
unhelpful semantics. The thing that usually catches people by surprise
is that they are dropped whenever the process closes any file descriptor
associated with the inode.

This is extremely problematic for people developing file servers that
need to implement byte-range locks. Developers often need a "lock
management" facility to ensure that file descriptors are not closed
until all of the locks associated with the inode are finished.

Additionally, "classic" POSIX locks are owned by the process. Locks
taken between threads within the same process won't conflict with one
another, which renders them useless for synchronization between threads.

This patchset adds a new type of lock that attempts to address these
issues. These locks conflict with classic POSIX read/write locks, but
have semantics that are more like BSD locks with respect to inheritance
and behavior on close.

This is implemented primarily by changing how fl_owner field is set for
these locks. Instead of having them owned by the files_struct of the
process, they are instead owned by the filp on which they were acquired.
Thus, they are inherited across fork() and are only released when the
last reference to a filp is put.

These new semantics prevent them from being merged with classic POSIX
locks, even if they are acquired by the same process. These locks will
also conflict with classic POSIX locks even if they are acquired by
the same process or on the same file descriptor.

The new locks are managed using a new set of cmd values to the fcntl()
syscall. The initial implementation of this converts these values to
"classic" cmd values at a fairly high level, and the details are not
exposed to the underlying filesystem. We may eventually want to push
this handing out to the lower filesystem code but for now I don't
see any need for it.

Also, note that with this implementation the new cmd values are only
available via fcntl64() on 32-bit arches. There's little need to
add support for legacy apps on a new interface like this.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Change-Id: I35691bdfed9cadcbbcb6ff6804d9eea1db661ddc
2021-01-24 09:56:22 +00:00
..
apparmor nick kvfree() from apparmor 2014-11-18 15:13:23 -08:00
integrity evm: check xattr value length and type in evm_inode_setxattr() 2015-02-02 17:05:06 +08:00
keys Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
selinux locks: add new fcntl cmd values for handling file private locks 2021-01-24 09:56:22 +00:00
smack Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
tomoyo consitify do_mount() arguments 2015-07-13 11:17:52 -07:00
yama Yama: handle 32-bit userspace prctl 2012-10-07 08:32:28 -07:00
capability.c consitify do_mount() arguments 2015-07-13 11:17:52 -07:00
commoncap.c UPSTREAM: capabilities: ambient capabilities 2017-09-01 13:38:08 +03:00
device_cgroup.c cgroup: remove cgroup_subsys argument from callbacks 2012-02-02 09:20:22 -08:00
inode.c vfs: Add permission2 for filesystems with per mount permissions 2017-09-22 19:12:07 +03:00
Kconfig FROMLIST: security,perf: Allow further restriction of perf_event_open 2016-06-20 19:00:29 +00:00
lsm_audit.c security: lsm_audit: add ioctl specific auditing 2015-04-20 09:42:31 -07:00
Makefile security: Yama LSM 2012-02-10 09:18:52 +11:00
min_addr.c mmap_min_addr check CAP_SYS_RAWIO only for write 2010-04-23 08:56:31 +10:00
security.c consitify do_mount() arguments 2015-07-13 11:17:52 -07:00