android_kernel_samsung_msm8976/include/uapi/linux
David Herrmann d26af5a68d shm: add sealing API
If two processes share a common memory region, they usually want some
guarantees to allow safe access. This often includes:
  - one side cannot overwrite data while the other reads it
  - one side cannot shrink the buffer while the other accesses it
  - one side cannot grow the buffer beyond previously set boundaries

If there is a trust-relationship between both parties, there is no need
for policy enforcement.  However, if there's no trust relationship (eg.,
for general-purpose IPC) sharing memory-regions is highly fragile and
often not possible without local copies.  Look at the following two
use-cases:

  1) A graphics client wants to share its rendering-buffer with a
     graphics-server. The memory-region is allocated by the client for
     read/write access and a second FD is passed to the server. While
     scanning out from the memory region, the server has no guarantee that
     the client doesn't shrink the buffer at any time, requiring rather
     cumbersome SIGBUS handling.
  2) A process wants to perform an RPC on another process. To avoid huge
     bandwidth consumption, zero-copy is preferred. After a message is
     assembled in-memory and a FD is passed to the remote side, both sides
     want to be sure that neither modifies this shared copy, anymore. The
     source may have put sensible data into the message without a separate
     copy and the target may want to parse the message inline, to avoid a
     local copy.

While SIGBUS handling, POSIX mandatory locking and MAP_DENYWRITE provide
ways to achieve most of this, the first one is unproportionally ugly to
use in libraries and the latter two are broken/racy or even disabled due
to denial of service attacks.

This patch introduces the concept of SEALING.  If you seal a file, a
specific set of operations is blocked on that file forever.  Unlike locks,
seals can only be set, never removed.  Hence, once you verified a specific
set of seals is set, you're guaranteed that no-one can perform the blocked
operations on this file, anymore.

An initial set of SEALS is introduced by this patch:
  - SHRINK: If SEAL_SHRINK is set, the file in question cannot be reduced
            in size. This affects ftruncate() and open(O_TRUNC).
  - GROW: If SEAL_GROW is set, the file in question cannot be increased
          in size. This affects ftruncate(), fallocate() and write().
  - WRITE: If SEAL_WRITE is set, no write operations (besides resizing)
           are possible. This affects fallocate(PUNCH_HOLE), mmap() and
           write().
  - SEAL: If SEAL_SEAL is set, no further seals can be added to a file.
          This basically prevents the F_ADD_SEAL operation on a file and
          can be set to prevent others from adding further seals that you
          don't want.

The described use-cases can easily use these seals to provide safe use
without any trust-relationship:

  1) The graphics server can verify that a passed file-descriptor has
     SEAL_SHRINK set. This allows safe scanout, while the client is
     allowed to increase buffer size for window-resizing on-the-fly.
     Concurrent writes are explicitly allowed.
  2) For general-purpose IPC, both processes can verify that SEAL_SHRINK,
     SEAL_GROW and SEAL_WRITE are set. This guarantees that neither
     process can modify the data while the other side parses it.
     Furthermore, it guarantees that even with writable FDs passed to the
     peer, it cannot increase the size to hit memory-limits of the source
     process (in case the file-storage is accounted to the source).

The new API is an extension to fcntl(), adding two new commands:
  F_GET_SEALS: Return a bitset describing the seals on the file. This
               can be called on any FD if the underlying file supports
               sealing.
  F_ADD_SEALS: Change the seals of a given file. This requires WRITE
               access to the file and F_SEAL_SEAL may not already be set.
               Furthermore, the underlying file must support sealing and
               there may not be any existing shared mapping of that file.
               Otherwise, EBADF/EPERM is returned.
               The given seals are _added_ to the existing set of seals
               on the file. You cannot remove seals again.

The fcntl() handler is currently specific to shmem and disabled on all
files. A file needs to explicitly support sealing for this interface to
work. A separate syscall is added in a follow-up, which creates files that
support sealing. There is no intention to support this on other
file-systems. Semantics are unclear for non-volatile files and we lack any
use-case right now. Therefore, the implementation is specific to shmem.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Ryan Lortie <desrt@desrt.ca>
Cc: Lennart Poettering <lennart@poettering.net>
Cc: Daniel Mack <zonque@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Angelo G. Del Regno <kholk11@gmail.com>
2020-10-08 05:52:37 -07:00
..
android android: binder: add padding to binder_fd_array_object. 2019-07-27 21:52:07 +02:00
byteorder
caif
can
dvb
hdlc
hsi
isdn
mfd
mmc Import latest Samsung release 2017-04-18 03:43:52 +02:00
netfilter netfilter: nf_nat: add full port randomization support 2019-07-27 22:08:25 +02:00
netfilter_arp
netfilter_bridge
netfilter_ipv4
netfilter_ipv6
nfsd
raid
spi
sunrpc
tc_act
tc_ematch
tima Import latest Samsung release 2017-04-18 03:43:52 +02:00
usb USB: core: Add type-specific length check of BOS descriptors 2019-07-27 21:46:13 +02:00
wimax
Kbuild seemp: enhance support for malware detection 2015-10-20 13:55:40 +05:30
a.out.h
acct.h
adb.h
adfs_fs.h
affs_hardblocks.h
agpgart.h
aio_abi.h
android_pmem.h
apm_bios.h
arcfb.h
ashmem.h ashmem: remove cache maintenance support 2017-04-23 23:34:27 -07:00
atalk.h
atm.h
atm_eni.h
atm_he.h
atm_idt77105.h
atm_nicstar.h
atm_tcp.h
atm_zatm.h
atmapi.h
atmarp.h
atmbr2684.h
atmclip.h
atmdev.h
atmioc.h
atmlec.h
atmmpc.h
atmppp.h
atmsap.h
atmsvc.h
audit.h Import latest Samsung release 2017-04-18 03:43:52 +02:00
auto_fs.h
auto_fs4.h
auxvec.h
avtimer.h
ax25.h
b1lli.h
batterydata-interface.h
baycom.h
bfs_fs.h
binfmts.h
blkpg.h
blktrace_api.h
bpqether.h
bsg.h
btrfs.h
can.h
capability.h
capi.h
cciss_defs.h
cciss_ioctl.h
cdrom.h
cgroupstats.h
chio.h
ci-bridge-spi.h
cm4000_cs.h
cn_proc.h
coda.h
coda_psdev.h
coff.h
compat_qcedev.h msm: crypto: Modify crypto libraries for FIPS139-2 Certificate 2015-03-11 11:48:24 -07:00
compat_qseecom.h qseecom: Add new IOCTL for QSEECom_send_modified_resp_64() function 2015-06-20 08:46:19 -07:00
connector.h
const.h linux/const.h: Add _BITUL() and _BITULL() 2016-06-07 10:42:44 +02:00
coresight-stm.h
cramfs_fs.h
cuda.h
cyclades.h
cycx_cfm.h
danipc_ioctl.h
dcbnl.h
dccp.h
demod_wrapper.h
dlm.h
dlm_device.h
dlm_netlink.h
dlm_plock.h
dlmconstants.h
dm-ioctl.h
dm-log-userspace.h
dn.h
dqblk_xfs.h
edd.h
efs_fs_sb.h
elf-em.h
elf-fdpic.h
elf.h arm64: ptrace: add NT_ARM_SYSTEM_CALL regset 2015-09-24 23:50:45 -07:00
elfcore.h
ensigma_uccp330.h
epm_adc.h hwmon: epm_adc: Remove redundant support 2014-09-25 09:37:13 -07:00
errno.h
errqueue.h
esoc_ctrl.h
ethtool.h
eventpoll.h
fadvise.h
falloc.h
fanotify.h
fb.h
fcntl.h shm: add sealing API 2020-10-08 05:52:37 -07:00
fd.h
fdreg.h
fib_rules.h net: core: add UID to flows, rules, and routes 2019-07-27 21:50:59 +02:00
fiemap.h
filter.h
fips_status.h msm: crypto: Modify crypto libraries for FIPS139-2 Certificate 2015-03-11 11:48:24 -07:00
firewire-cdev.h
firewire-constants.h
flat.h
fs.h Merge remote-tracking branch 'f2fs/linux-3.10.y' into HEAD 2017-04-18 17:02:28 +02:00
fsl_hypervisor.h
fuse.h fuse: Add support for d_canonical_path 2018-02-06 13:12:18 +01:00
futex.h
gameport.h
gen_stats.h
genetlink.h
gfs2_ondisk.h
gigaset_dev.h
hbtp_input.h input: misc: hbtp-input: add event type in uevents 2015-06-01 20:09:37 -07:00
hbtp_vm.h input: misc: add support for virtual mouse 2015-03-16 22:19:45 -07:00
hdlc.h
hdlcdrv.h
hdreg.h
hid.h
hiddev.h
hidraw.h
hpet.h
hw_breakpoint.h
hysdn_if.h
i2c-dev.h
i2c.h
i2o-dev.h
i8k.h
icmp.h
icmpv6.h
idle_stats_device.h
if.h
if_addr.h
if_addrlabel.h
if_alg.h
if_arcnet.h
if_arp.h
if_bonding.h
if_bridge.h
if_cablemodem.h
if_eql.h
if_ether.h
if_fc.h
if_fddi.h
if_frad.h
if_hippi.h
if_infiniband.h
if_link.h
if_ltalk.h
if_packet.h tpacket: Notify userspace about packets with CHECKSUM_UNNECESSARY 2016-06-29 21:42:35 -07:00
if_phonet.h
if_plip.h
if_ppp.h
if_pppol2tp.h
if_pppolac.h
if_pppopns.h
if_pppox.h
if_slip.h
if_team.h
if_tun.h Import latest Samsung release 2017-04-18 03:43:52 +02:00
if_tunnel.h
if_vlan.h
if_x25.h
igmp.h
in.h
in6.h
in_route.h
inet_diag.h net: inet: diag: expose the socket mark to privileged processes. 2019-07-27 21:50:56 +02:00
inotify.h
input.h Import latest Samsung release 2017-04-18 03:43:52 +02:00
ioctl.h
ion.h
ioprio.h
ip.h ipv4: add option to drop gratuitous ARP packets 2019-08-03 00:23:56 +02:00
ip6_tunnel.h
ip_vs.h
ipa_qmi_service_v01.h msm: ipa: add new QMI support for ipa stats 2015-06-05 12:30:31 -07:00
ipc.h
ipmi.h
ipmi_msgdefs.h
ipsec.h
ipv6.h BACKPORT: ipv6 addrconf: implement RFC7559 router solicitation backoff 2019-07-27 21:51:04 +02:00
ipv6_route.h
ipx.h
irda.h
irqnr.h
isdn.h
isdn_divertif.h
isdn_ppp.h
isdnif.h
iso_fs.h
ivtv.h
ivtvfb.h
ixjuser.h
jffs2.h
joystick.h
kd.h
kdev_t.h
kernel-page-flags.h
kernel.h
kernelcapi.h
kexec.h
keyboard.h
keychord.h
keyctl.h
kvm.h
kvm_para.h
l2tp.h
limits.h
llc.h
loop.h
lp.h
magic.h sdcardfs: Change magic value 2019-07-27 21:51:48 +02:00
major.h
map_to_7segment.h
matroxfb.h
mdio.h
media.h
mei.h
memfd.h shm: add memfd_create() syscall 2020-10-08 05:52:36 -07:00
mempolicy.h
meye.h
mhi.h mhi_dev: mhi: Add MHI device driver 2015-03-23 11:55:42 -07:00
mii.h
minix_fs.h
mman.h
mmtimer.h
module.h
mqueue.h
mroute.h
mroute6.h
msdos_fs.h
msg.h
msm-buspm-dev.h msm: msm_bus: Correct the IOCTL command data type 2015-07-03 11:41:48 +05:30
msm-core-interface.h
msm_adc.h
msm_adsp.h
msm_audio.h ASoC: msm: qdsp6v2: add wakelock hook in misc driver 2015-10-15 15:48:29 +08:00
msm_audio_aac.h
msm_audio_ac3.h
msm_audio_alac.h ASoC: msm: qdsp6v2: add ALAC specific configuration parameters 2015-04-07 16:15:03 +05:30
msm_audio_amrnb.h
msm_audio_amrwb.h
msm_audio_amrwbplus.h
msm_audio_ape.h ASoC: msm: qdsp6v2: add copyright information for APE header 2015-05-19 15:03:59 +05:30
msm_audio_calibration.h ASoC: wcd_cpe_core: Add LSM topology support 2015-10-13 15:22:52 +05:30
msm_audio_mvs.h
msm_audio_qcp.h
msm_audio_sbc.h
msm_audio_voicememo.h
msm_audio_wma.h
msm_audio_wmapro.h ASoC: msm: qdsp6v2: support multi-ch and samplerate > 48K for NT wma 2015-07-19 22:25:41 -07:00
msm_charm.h
msm_dsps.h
msm_ion.h
msm_ipa.h msm: ipa: New IOCTL for adding rt\flt rule after a specific rule 2019-07-27 21:50:53 +02:00
msm_ipc.h Import latest Samsung release 2017-04-18 03:43:52 +02:00
msm_kgsl.h msm: kgsl: Add property to determine GPU bitness 2016-06-07 03:36:16 -07:00
msm_mdp.h msm: mdss: Add ioctl support for DSPP dirty flags config 2015-12-16 23:14:52 -08:00
msm_pft.h
msm_q6vdec.h
msm_q6venc.h
msm_rmnet.h rmnet_data : Changes to support Scatter Gather and GSO. 2016-04-18 08:55:09 -07:00
msm_rotator.h
msm_thermal_ioctl.h msm: thermal: Add IOCTL command in KTM to query cluster voltage plan 2014-11-05 13:52:14 -05:00
msm_vidc_dec.h msm: vidc: Enumerate codec type for Vp8 and Vp9 2015-05-29 19:13:13 +05:30
msm_vidc_enc.h
mtio.h
n_r3964.h
nbd.h
ncp.h
ncp_fs.h
ncp_mount.h
ncp_no.h
neighbour.h
net.h
net_dropmon.h
net_map.h
net_tstamp.h
netconf.h
netdevice.h
netfilter.h
netfilter_arp.h
netfilter_bridge.h
netfilter_decnet.h
netfilter_ipv4.h
netfilter_ipv6.h
netlink.h
netlink_diag.h
netrom.h
nfc.h
nfs.h
nfs2.h
nfs3.h
nfs4.h
nfs4_mount.h
nfs_fs.h
nfs_idmap.h
nfs_mount.h
nfsacl.h
nl80211.h BACKPORT: nl80211: Stop scheduled scan if netlink client disappears 2019-07-27 21:50:44 +02:00
nubus.h
nvram.h
omap3isp.h
omapfb.h
oneshot_sync.h
oom.h Import latest Samsung release 2017-04-18 03:43:52 +02:00
openvswitch.h
packet_diag.h uapi: fix linux/packet_diag.h userspace compilation error 2019-07-27 21:44:00 +02:00
param.h
parport.h
patchkey.h
pci.h
pci_regs.h
perf_event.h
personality.h
pfkeyv2.h
pg.h
phantom.h
phonet.h
pkt_cls.h
pkt_sched.h
pktcdvd.h
pmu.h
poll.h
posix_types.h
ppdev.h
ppp-comp.h
ppp-ioctl.h ppp: remove the PPPIOCDETACH ioctl 2019-07-27 21:52:16 +02:00
ppp_defs.h
pps.h
prctl.h UPSTREAM: capabilities: ambient capabilities 2018-02-06 13:12:16 +01:00
psci.h ARM/ARM64: KVM: Add common header for PSCI related defines 2014-08-15 11:45:44 -07:00
ptp_clock.h
ptrace.h
qcedev.h
qcota.h
qnx4_fs.h
qnxtypes.h
qrng.h msm: crypto: Modify crypto libraries for FIPS139-2 Certificate 2015-03-11 11:48:24 -07:00
qseecom.h Import latest Samsung release 2017-04-18 03:43:52 +02:00
quota.h
radeonfb.h
random.h BACKPORT: random: introduce getrandom(2) system call 2017-09-08 18:50:11 +00:00
raw.h
rds.h
reboot.h
reiserfs_fs.h
reiserfs_xattr.h
resource.h Import latest Samsung release 2017-04-18 03:43:52 +02:00
rfkill.h
rmnet_data.h net: rmnet_data: Add support to configure custom device name 2018-09-05 18:14:57 +02:00
rmnet_ipa_fd_ioctl.h msm: ipa: support aggregated ipa stats query 2019-07-27 21:50:51 +02:00
romfs_fs.h
rose.h
route.h
rtc.h
rtnetlink.h net: core: add UID to flows, rules, and routes 2019-07-27 21:50:59 +02:00
scc.h
sched.h sched: Move SCHED_RESET_ON_FORK into attr::sched_flags 2015-05-19 19:16:13 -07:00
screen_info.h
sctp.h
sdla.h
seccomp.h seccomp: implement SECCOMP_FILTER_FLAG_TSYNC 2015-03-19 14:52:56 -07:00
securebits.h
seemp_api.h seemp: Add support for QSSP Enhancement 2016-01-27 22:59:36 -08:00
seemp_param_id.h seemp: Add support for QSSP Enhancement 2016-01-27 22:59:36 -08:00
selinux_netlink.h
sem.h
serial.h
serial_core.h
serial_reg.h
serio.h
shm.h
signal.h
signalfd.h
snmp.h tcp: tcp_fragment() should apply sane memory limits 2019-07-27 22:11:09 +02:00
sock_diag.h net: diag: Add the ability to destroy a socket. 2016-05-18 14:36:07 +05:30
socket.h
sockev.h
sockios.h
som.h
sonet.h
sonypi.h
sound.h
soundcard.h
stat.h
stddef.h
string.h
suspend_ioctls.h
swab.h
synclink.h
sysctl.h net: ipv6: Add sysctl for minimum prefix len acceptable in RIOs. 2019-07-27 21:51:03 +02:00
sysinfo.h
taskstats.h
tcp.h
tcp_metrics.h
telephony.h
termios.h
time.h rtc: alarm: set power-on alarm via timerfd 2015-11-06 10:20:32 +08:00
times.h
timex.h
tiocl.h
tipc.h
tipc_config.h
toshiba.h
tsc.h
tty.h
tty_flags.h
types.h
udf_fs_i.h
udp.h
uhid.h
uinput.h
uio.h
ultrasound.h
un.h
unistd.h
unix_diag.h
usbdevice_fs.h USB: usbfs: allow URBs to be reaped after disconnection 2015-08-03 09:29:47 -07:00
utime.h
utsname.h
uuid.h
uvcvideo.h
v4l2-common.h
v4l2-controls.h Merge tag 'LA.BR.1.3.6-03510-8976.0' into HEAD 2017-04-18 12:11:50 +02:00
v4l2-dv-timings.h
v4l2-mediabus.h
v4l2-subdev.h
veth.h
vfio.h
vhost.h
videodev2.h msm: vidc: Add support for Vp9 decode in vidc driver 2015-06-01 21:17:14 -07:00
virtio_9p.h
virtio_balloon.h
virtio_blk.h
virtio_config.h
virtio_console.h
virtio_ids.h
virtio_net.h
virtio_pci.h
virtio_ring.h
virtio_rng.h
vm_bms.h
vm_sockets.h
vt.h
wait.h
wanrouter.h
watchdog.h
wil6210_uapi.h wil6210: atomic I/O for the card memory 2014-10-23 06:56:50 -07:00
wimax.h
wireless.h
x25.h
xattr.h
xfrm.h BACKPORT: net: xfrm: support setting an output mark. 2019-07-27 21:51:33 +02:00