314 Commits

Author SHA1 Message Date
Micah Morton
8a8dc184c7 BACKPORT: LSM: generalize flag passing to security_capable
This patch provides a general mechanism for passing flags to the
security_capable LSM hook. It replaces the specific 'audit' flag that is
used to tell security_capable whether it should log an audit message for
the given capability check. The reason for generalizing this flag
passing is so we can add an additional flag that signifies whether
security_capable is being called by a setid syscall (which is needed by
the proposed SafeSetID LSM).

Change-Id: I4ff373b2041e13808422201744f2aac23ec5b4c2
Signed-off-by: Micah Morton <mortonm@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: James Morris <james.morris@microsoft.com>
2025-10-10 05:00:50 +03:00
Michael Bestas
ada634c3e0 Merge tag 'v4.14.340-openela' into android-msm-pixel-4.14
This is the 4.14.340 OpenELA-Extended LTS stable release

* tag 'v4.14.340-openela':
  LTS: Update to 4.14.340
  fs/aio: Restrict kiocb_set_cancel_fn() to I/O submitted via libaio
  KVM: arm64: vgic-its: Test for valid IRQ in its_sync_lpi_pending_table()
  PCI/MSI: Prevent MSI hardware interrupt number truncation
  s390: use the correct count for __iowrite64_copy()
  packet: move from strlcpy with unused retval to strscpy
  ipv6: sr: fix possible use-after-free and null-ptr-deref
  nouveau: fix function cast warnings
  scsi: jazz_esp: Only build if SCSI core is builtin
  RDMA/srpt: fix function pointer cast warnings
  RDMA/srpt: Support specifying the srpt_service_guid parameter
  IB/hfi1: Fix a memleak in init_credit_return
  usb: gadget: ncm: Avoid dropping datagrams of properly parsed NTBs
  l2tp: pass correct message length to ip6_append_data
  gtp: fix use-after-free and null-ptr-deref in gtp_genl_dump_pdp()
  dm-crypt: don't modify the data when using authenticated encryption
  mm: memcontrol: switch to rcu protection in drain_all_stock()
  s390/qeth: Fix potential loss of L3-IP@ in case of network issues
  virtio-blk: Ensure no requests in virtqueues before deleting vqs.
  firewire: core: send bus reset promptly on gap count error
  hwmon: (coretemp) Enlarge per package core count limit
  regulator: pwm-regulator: Add validity checks in continuous .get_voltage
  ext4: avoid allocating blocks from corrupted group in ext4_mb_find_by_goal()
  ext4: avoid allocating blocks from corrupted group in ext4_mb_try_best_found()
  ahci: asm1166: correct count of reported ports
  fbdev: sis: Error out if pixclock equals zero
  fbdev: savage: Error out if pixclock equals zero
  wifi: mac80211: fix race condition on enabling fast-xmit
  wifi: cfg80211: fix missing interfaces when dumping
  dmaengine: shdma: increase size of 'dev_id'
  scsi: target: core: Add TMF to tmr_list handling
  sched/rt: Disallow writing invalid values to sched_rt_period_us
  sched/rt: sysctl_sched_rr_timeslice show default timeslice after reset
  sched/rt: Fix sysctl_sched_rr_timeslice intial value
  nilfs2: replace WARN_ONs for invalid DAT metadata block requests
  memcg: add refcnt for pcpu stock to avoid UAF problem in drain_all_stock()
  net/sched: Retire dsmark qdisc
  net/sched: Retire ATM qdisc
  net/sched: Retire CBQ qdisc
  LTS: Update to 4.14.339
  netfilter: nf_tables: fix pointer math issue in nft_byteorder_eval()
  lsm: new security_file_ioctl_compat() hook
  nilfs2: fix potential bug in end_buffer_async_write
  sched/membarrier: reduce the ability to hammer on sys_membarrier
  Revert "md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d"
  pmdomain: core: Move the unused cleanup to a _sync initcall
  irqchip/irq-brcmstb-l2: Add write memory barrier before exit
  nfp: use correct macro for LengthSelect in BAR config
  nilfs2: fix hang in nilfs_lookup_dirty_data_buffers()
  nilfs2: fix data corruption in dsync block recovery for small block sizes
  ALSA: hda/conexant: Add quirk for SWS JS201D
  x86/mm/ident_map: Use gbpages only where full GB page should be mapped.
  staging: iio: ad5933: fix type mismatch regression
  ext4: fix double-free of blocks due to wrong extents moved_len
  xen-netback: properly sync TX responses
  nfc: nci: free rx_data_reassembly skb on NCI device cleanup
  firewire: core: correct documentation of fw_csr_string() kernel API
  scsi: Revert "scsi: fcoe: Fix potential deadlock on &fip->ctlr_lock"
  usb: f_mass_storage: forbid async queue when shutdown happen
  USB: hub: check for alternate port before enabling A_ALT_HNP_SUPPORT
  HID: wacom: Do not register input devices until after hid_hw_start
  HID: wacom: generic: Avoid reporting a serial of '0' to userspace
  mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again
  tracing/trigger: Fix to return error if failed to alloc snapshot
  i40e: Fix waiting for queues of all VSIs to be disabled
  MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler
  net: sysfs: Fix /sys/class/net/<iface> path for statistics
  Documentation: net-sysfs: describe missing statistics
  ASoC: rt5645: Fix deadlock in rt5645_jack_detect_work()
  spi: ppc4xx: Drop write-only variable
  btrfs: send: return EOPNOTSUPP on unknown flags
  vhost: use kzalloc() instead of kmalloc() followed by memset()
  Input: atkbd - skip ATKBD_CMD_SETLEDS when skipping ATKBD_CMD_GETID
  USB: serial: cp210x: add ID for IMST iM871A-USB
  USB: serial: option: add Fibocom FM101-GL variant
  USB: serial: qcserial: add new usb-id for Dell Wireless DW5826e
  net/af_iucv: clean up a try_then_request_module()
  netfilter: nft_compat: restrict match/target protocol to u16
  netfilter: nft_compat: reject unused compat flag
  ppp_async: limit MRU to 64K
  tipc: Check the bearer type before calling tipc_udp_nl_bearer_add()
  rxrpc: Fix response to PING RESPONSE ACKs to a dead call
  inet: read sk->sk_family once in inet_recv_error()
  hwmon: (aspeed-pwm-tacho) mutex for tach reading
  atm: idt77252: fix a memleak in open_card_ubr0
  phy: ti: phy-omap-usb2: Fix NULL pointer dereference for SRP
  dmaengine: fix is_slave_direction() return false when DMA_DEV_TO_DEV
  bonding: remove print in bond_verify_device_path
  HID: apple: Add 2021 magic keyboard FN key mapping
  HID: apple: Add support for the 2021 Magic Keyboard
  HID: apple: Swap the Fn and Left Control keys on Apple keyboards
  net: sysfs: Fix /sys/class/net/<iface> path
  af_unix: fix lockdep positive in sk_diag_dump_icons()
  net: ipv4: fix a memleak in ip_setup_cork
  net: Fix one possible memleak in ip_setup_cork
  netfilter: nf_log: replace BUG_ON by WARN_ON_ONCE when putting logger
  llc: call sock_orphan() at release time
  ipv6: Ensure natural alignment of const ipv6 loopback and router addresses
  ixgbe: Fix an error handling path in ixgbe_read_iosf_sb_reg_x550()
  ixgbe: Refactor overtemp event handling
  ixgbe: Remove non-inclusive language
  net: remove unneeded break
  scsi: isci: Fix an error code problem in isci_io_request_build()
  wifi: cfg80211: fix RCU dereference in __cfg80211_bss_update
  drm/amdgpu: Release 'adev->pm.fw' before return in 'amdgpu_device_need_post()'
  ceph: fix deadlock or deadcode of misusing dget()
  virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings
  libsubcmd: Fix memory leak in uniq()
  usb: hub: Replace hardcoded quirk value with BIT() macro
  PCI: Only override AMD USB controller if required
  mfd: ti_am335x_tscadc: Fix TI SoC dependencies
  um: net: Fix return type of uml_net_start_xmit()
  um: Don't use vfprintf() for os_info()
  um: Fix naming clash between UML and scheduler
  leds: trigger: panic: Don't register panic notifier if creating the trigger failed
  clk: mmp: pxa168: Fix memory leak in pxa168_clk_init()
  clk: hi3620: Fix memory leak in hi3620_mmc_clk_init()
  media: ddbridge: fix an error code problem in ddb_probe
  IB/ipoib: Fix mcast list locking
  drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time
  ALSA: hda: Intel: add HDA_ARL PCI ID support
  ALSA: hda: Add Icelake PCI ID
  PCI: add INTEL_HDA_ARL to pci_ids.h
  media: stk1160: Fixed high volume of stk1160_dbg messages
  drm/mipi-dsi: Fix detach call without attach
  drm/framebuffer: Fix use of uninitialized variable
  drm/drm_file: fix use of uninitialized variable
  RDMA/IPoIB: Fix error code return in ipoib_mcast_join
  fast_dput(): handle underflows gracefully
  ASoC: doc: Fix undefined SND_SOC_DAPM_NOPM argument
  wifi: cfg80211: free beacon_ies when overridden from hidden BSS
  wifi: rtlwifi: rtl8723{be,ae}: using calculate_bit_shift()
  wifi: rtl8xxxu: Add additional USB IDs for RTL8192EU devices
  md: Whenassemble the array, consult the superblock of the freshest device
  ARM: dts: imx23/28: Fix the DMA controller node name
  ARM: dts: imx23-sansa: Use preferred i2c-gpios properties
  ARM: dts: imx27-apf27dev: Fix LED name
  ARM: dts: imx1: Fix sram node
  ARM: dts: imx27: Fix sram node
  ARM: dts: imx: Use flash@0,0 pattern
  ARM: dts: imx25/27-eukrea: Fix RTC node name
  ARM: dts: rockchip: fix rk3036 hdmi ports node
  scsi: libfc: Fix up timeout error in fc_fcp_rec_error()
  scsi: libfc: Don't schedule abort twice
  bpf: Add map and need_defer parameters to .map_fd_put_ptr()
  wifi: ath9k: Fix potential array-index-out-of-bounds read in ath9k_htc_txstatus()
  ARM: dts: imx7s: Fix nand-controller #size-cells
  ARM: dts: imx7s: Fix lcdif compatible
  bonding: return -ENOMEM instead of BUG in alb_upper_dev_walk
  PCI: Add no PM reset quirk for NVIDIA Spectrum devices
  scsi: lpfc: Fix possible file string name overflow when updating firmware
  ext4: unify the type of flexbg_size to unsigned int
  SUNRPC: Fix a suspicious RCU usage warning
  KVM: s390: fix setting of fpc register
  s390/ptrace: handle setting of fpc register correctly
  jfs: fix array-index-out-of-bounds in diNewExt
  rxrpc_find_service_conn_rcu: fix the usage of read_seqbegin_or_lock()
  pstore/ram: Fix crash when setting number of cpus to an odd number
  jfs: fix uaf in jfs_evict_inode
  jfs: fix array-index-out-of-bounds in dbAdjTree
  jfs: fix slab-out-of-bounds Read in dtSearch
  UBSAN: array-index-out-of-bounds in dtSplitRoot
  FS:JFS:UBSAN:array-index-out-of-bounds in dbAdjTree
  ACPI: extlog: fix NULL pointer dereference check
  PNP: ACPI: fix fortify warning
  ACPI: video: Add quirk for the Colorful X15 AT 23 Laptop
  audit: Send netlink ACK before setting connection in auditd_set
  powerpc/lib: Validate size for vector operations
  powerpc/mm: Fix build failures due to arch_reserved_kernel_pages()
  powerpc: Fix build error due to is_valid_bugaddr()
  powerpc/mm: Fix null-pointer dereference in pgtable_cache_add
  tick/sched: Preserve number of idle sleeps across CPU hotplug events
  mips: Call lose_fpu(0) before initializing fcr31 in mips_set_personality_nan
  drm/bridge: nxp-ptn3460: simplify some error checking
  drm/bridge: nxp-ptn3460: fix i2c_master_send() error checking
  drm: Don't unref the same fb many times by mistake due to deadlock handling
  gpiolib: acpi: Ignore touchpad wakeup on GPD G1619-04
  netfilter: nf_tables: reject QUEUE/DROP verdict parameters
  btrfs: defrag: reject unknown flags of btrfs_ioctl_defrag_range_args
  btrfs: don't warn if discard range is not aligned to sector
  net: fec: fix the unhandled context fault from smmu
  fjes: fix memleaks in fjes_hw_setup
  netfilter: nf_tables: restrict anonymous set and map names to 16 bytes
  net/mlx5e: fix a double-free in arfs_create_groups
  net/mlx5: Use kfree(ft->g) in arfs_create_groups()
  netlink: fix potential sleeping issue in mqueue_flush_file
  tcp: Add memory barrier to tcp_push()
  net/rds: Fix UBSAN: array-index-out-of-bounds in rds_cmsg_recv
  llc: Drop support for ETH_P_TR_802_2.
  llc: make llc_ui_sendmsg() more robust against bonding changes
  vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING
  drivers: core: fix kernel-doc markup for dev_err_probe()
  driver code: print symbolic error code
  Revert "driver core: Annotate dev_err_probe() with __must_check"
  driver core: Annotate dev_err_probe() with __must_check
  x86/CPU/AMD: Fix disabling XSAVES on AMD family 0x17 due to erratum
  powerpc: Use always instead of always-y in for crtsavres.o
  block: Remove special-casing of compound pages
  parisc/firmware: Fix F-extend for PDC addresses
  rpmsg: virtio: Free driver_override when rpmsg_remove()
  hwrng: core - Fix page fault dead lock on mmap-ed hwrng
  PM: hibernate: Enforce ordering during image compression/decompression
  crypto: api - Disallow identical driver names
  serial: sc16is7xx: add check for unsupported SPI modes during probe
  spi: introduce SPI_MODE_X_MASK macro
  driver core: add device probe log helper
  serial: sc16is7xx: set safe default SPI clock frequency
  units: add the HZ macros
  units: change from 'L' to 'UL'
  units: Add Watt units
  include/linux/units.h: add helpers for kelvin to/from Celsius conversion
  PCI: mediatek: Clear interrupt status before dispatching handler
  LTS: Update to 4.14.338
  crypto: scompress - initialize per-CPU variables on each CPU
  Revert "NFSD: Fix possible sleep during nfsd4_release_lockowner()"
  i2c: s3c24xx: fix transferring more than one message in polling mode
  i2c: s3c24xx: fix read transfers in polling mode
  kdb: Fix a potential buffer overflow in kdb_local()
  kdb: Censor attempts to set PROMPT without ENABLE_MEM_READ
  ipvs: avoid stat macros calls from preemptible context
  net: ravb: Fix dma_addr_t truncation in error case
  serial: imx: Correct clock error message in function probe()
  apparmor: avoid crash when parsed profile name is empty
  MIPS: Alchemy: Fix an out-of-bound access in db1550_dev_setup()
  MIPS: Alchemy: Fix an out-of-bound access in db1200_dev_setup()
  HID: wacom: Correct behavior when processing some confidence == false touches
  wifi: mwifiex: configure BSSID consistently when starting AP
  wifi: rtlwifi: Convert LNKCTL change to PCIe cap RMW accessors
  wifi: rtlwifi: Remove bogus and dangerous ASPM disable/enable code
  fbdev: flush deferred work in fb_deferred_io_fsync()
  ALSA: oxygen: Fix right channel of capture volume mixer
  usb: mon: Fix atomicity violation in mon_bin_vma_fault
  usb: chipidea: wait controller resume finished for wakeup irq
  usb: dwc: ep0: Update request status in dwc3_ep0_stall_restart
  usb: phy: mxs: remove CONFIG_USB_OTG condition for mxs_phy_is_otg_host()
  tick-sched: Fix idle and iowait sleeptime accounting vs CPU hotplug
  binder: fix unused alloc->free_async_space
  binder: fix race between mmput() and do_exit()
  xen-netback: don't produce zero-size SKB frags
  Input: atkbd - use ab83 as id when skipping the getid command
  binder: fix async space check for 0-sized buffers
  watchdog: bcm2835_wdt: Fix WDIOC_SETTIMEOUT handling
  watchdog: set cdev owner before adding
  gpu/drm/radeon: fix two memleaks in radeon_vm_init
  drivers/amd/pm: fix a use-after-free in kv_parse_power_table
  drm/amd/pm: fix a double-free in si_dpm_init
  media: dvbdev: drop refcount on error path in dvb_device_open()
  media: cx231xx: fix a memleak in cx231xx_init_isoc
  drm/radeon/trinity_dpm: fix a memleak in trinity_parse_power_table
  drm/radeon/dpm: fix a memleak in sumo_parse_power_table
  drm/radeon: check the alloc_workqueue return value in radeon_crtc_init()
  drm/drv: propagate errors from drm_modeset_register_all()
  drm/msm/mdp4: flush vblank event on disable
  ASoC: cs35l34: Fix GPIO name and drop legacy include
  ASoC: cs35l33: Fix GPIO name and drop legacy include
  drm/radeon: check return value of radeon_ring_lock()
  drm/radeon/r100: Fix integer overflow issues in r100_cs_track_check()
  drm/radeon/r600_cs: Fix possible int overflows in r600_cs_check_reg()
  f2fs: fix to avoid dirent corruption
  drm/bridge: Fix typo in post_disable() description
  media: pvrusb2: fix use after free on context disconnection
  RDMA/usnic: Silence uninitialized symbol smatch warnings
  ip6_tunnel: fix NEXTHDR_FRAGMENT handling in ip6_tnl_parse_tlv_enc_lim()
  Bluetooth: Fix bogus check for re-auth no supported with non-ssp
  wifi: rtlwifi: rtl8192se: using calculate_bit_shift()
  wifi: rtlwifi: rtl8192ee: using calculate_bit_shift()
  wifi: rtlwifi: rtl8192de: using calculate_bit_shift()
  rtlwifi: rtl8192de: make arrays static const, makes object smaller
  wifi: rtlwifi: rtl8192ce: using calculate_bit_shift()
  wifi: rtlwifi: rtl8192cu: using calculate_bit_shift()
  wifi: rtlwifi: rtl8192c: using calculate_bit_shift()
  wifi: rtlwifi: rtl8188ee: phy: using calculate_bit_shift()
  wifi: rtlwifi: add calculate_bit_shift()
  wifi: rtlwifi: rtl8821ae: phy: fix an undefined bitwise shift behavior
  rtlwifi: Use ffs in <foo>_phy_calculate_bit_shift
  firmware: ti_sci: Fix an off-by-one in ti_sci_debugfs_create()
  net/ncsi: Fix netlink major/minor version numbers
  ncsi: internal.h: Fix a spello
  wifi: libertas: stop selecting wext
  bpf, lpm: Fix check prefixlen before walking trie
  NFSv4.1/pnfs: Ensure we handle the error NFS4ERR_RETURNCONFLICT
  crypto: scomp - fix req->dst buffer overflow
  crypto: scompress - Use per-CPU struct instead multiple variables
  crypto: scompress - return proper error code for allocation failure
  crypto: sahara - do not resize req->src when doing hash operations
  crypto: sahara - fix processing hash requests with req->nbytes < sg->length
  crypto: sahara - improve error handling in sahara_sha_process()
  crypto: sahara - fix wait_for_completion_timeout() error handling
  crypto: sahara - fix ahash reqsize
  crypto: virtio - Wait for tasklet to complete on device remove
  pstore: ram_core: fix possible overflow in persistent_ram_init_ecc()
  crypto: sahara - fix error handling in sahara_hw_descriptor_create()
  crypto: sahara - fix processing requests with cryptlen < sg->length
  crypto: sahara - fix ahash selftest failure
  crypto: sahara - remove FLAGS_NEW_KEY logic
  crypto: af_alg - Disallow multiple in-flight AIO requests
  crypto: ccp - fix memleak in ccp_init_dm_workarea
  crypto: virtio - Handle dataq logic with tasklet
  mtd: Fix gluebi NULL pointer dereference caused by ftl notifier
  calipso: fix memory leak in netlbl_calipso_add_pass()
  netlabel: remove unused parameter in netlbl_netlink_auditinfo()
  net: netlabel: Fix kerneldoc warnings
  ACPI: video: check for error while searching for backlight device parent
  mtd: rawnand: Increment IFC_TIMEOUT_MSECS for nand controller response
  powerpc/imc-pmu: Add a null pointer check in update_events_in_group()
  powerpc/powernv: Add a null pointer check in opal_event_init()
  selftests/powerpc: Fix error handling in FPU/VMX preemption tests
  powerpc/pseries/memhp: Fix access beyond end of drmem array
  powerpc/pseries/memhotplug: Quieten some DLPAR operations
  powerpc/44x: select I2C for CURRITUCK
  powerpc: remove redundant 'default n' from Kconfig-s
  powerpc: add crtsavres.o to always-y instead of extra-y
  EDAC/thunderx: Fix possible out-of-bounds string access
  x86/lib: Fix overflow when counting digits
  coresight: etm4x: Fix width of CCITMIN field
  uio: Fix use-after-free in uio_open
  binder: fix comment on binder_alloc_new_buf() return value
  drm/crtc: fix uninitialized variable use
  Input: xpad - add Razer Wolverine V2 support
  ARC: fix spare error
  s390/scm: fix virtual vs physical address confusion
  Input: atkbd - skip ATKBD_CMD_GETID in translated mode
  reset: hisilicon: hi6220: fix Wvoid-pointer-to-enum-cast warning
  ring-buffer: Do not record in NMI if the arch does not support cmpxchg in NMI
  tracing: Add size check when printing trace_marker output
  tracing: Have large events show up as '[LINE TOO BIG]' instead of nothing
  drm/crtc: Fix uninit-value bug in drm_mode_setcrtc
  jbd2: correct the printing of write_flags in jbd2_write_superblock()
  clk: rockchip: rk3128: Fix HCLK_OTG gate register
  drm/exynos: fix a potential error pointer dereference
  ASoC: da7219: Support low DC impedance headset
  net/tg3: fix race condition in tg3_reset_task()
  ASoC: rt5650: add mutex to avoid the jack detection failure
  ASoC: cs43130: Fix incorrect frame delay configuration
  ASoC: cs43130: Fix the position of const qualifier
  f2fs: explicitly null-terminate the xattr list
  LTS: Update to 4.14.337
  ipv6: remove max_size check inline with ipv4
  ipv6: make ip6_rt_gc_expire an atomic_t
  net/dst: use a smaller percpu_counter batch for dst entries accounting
  net: add a route cache full diagnostic message
  netfilter: nf_tables: Reject tables of unsupported family
  fuse: nlookup missing decrement in fuse_direntplus_link
  mm: fix unmap_mapping_range high bits shift bug
  mm/memory-failure: check the mapcount of the precise page
  bnxt_en: Remove mis-applied code from bnxt_cfg_ntp_filters()
  asix: Add check for usbnet_get_endpoints
  net/qla3xxx: fix potential memleak in ql_alloc_buffer_queues
  net/qla3xxx: switch from 'pci_' to 'dma_' API
  LTS: create metadata for 4.14.y

 Conflicts:
	drivers/android/binder_alloc.c
	drivers/infiniband/ulp/srpt/ib_srpt.c
	drivers/usb/core/hub.c
	fs/aio.c
	fs/f2fs/namei.c
	kernel/power/swap.c

Change-Id: Ic871768afdde4511ca7dee3006c33c7d4607e280
2024-03-23 00:35:20 +02:00
Alfred Piccioni
cdb04bf58f lsm: new security_file_ioctl_compat() hook
commit f1bb47a31dff6d4b34fb14e99850860ee74bb003 upstream.

Some ioctl commands do not require ioctl permission, but are routed to
other permissions such as FILE_GETATTR or FILE_SETATTR. This routing is
done by comparing the ioctl cmd to a set of 64-bit flags (FS_IOC_*).

However, if a 32-bit process is running on a 64-bit kernel, it emits
32-bit flags (FS_IOC32_*) for certain ioctl operations. These flags are
being checked erroneously, which leads to these ioctl operations being
routed to the ioctl permission, rather than the correct file
permissions.

This was also noted in a RED-PEN finding from a while back -
"/* RED-PEN how should LSM module know it's handling 32bit? */".

This patch introduces a new hook, security_file_ioctl_compat(), that is
called from the compat ioctl syscall. All current LSMs have been changed
to support this hook.

Reviewing the three places where we are currently using
security_file_ioctl(), it appears that only SELinux needs a dedicated
compat change; TOMOYO and SMACK appear to be functional without any
change.

Cc: stable@vger.kernel.org
Fixes: 0b24dcb7f2 ("Revert "selinux: simplify ioctl checking"")
Signed-off-by: Alfred Piccioni <alpic@google.com>
Reviewed-by: Stephen Smalley <stephen.smalley.work@gmail.com>
[PM: subject tweak, line length fixes, and alignment corrections]
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit f8f51085b4be6132762ce0d8940071ccdcce2504)
[vegard: fix conflict due to missing commit
 df0ce17331e2501dbffc060041dfc6c5f85227b5 ("security: convert security
 hooks to use hlist")]
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
2024-03-08 08:21:39 +00:00
Wilson Sung
ffdcfa9ebe Merge android-4.14-stable (4.14.257) into android-msm-pixel-4.14-lts
Merge 4.14.257 into android-4.14-stable
Linux 4.14.257
    parisc: Mark cr16 CPU clocksource unstable on all SMP machines
  * serial: core: fix transmit-buffer reset and memleak
      drivers/tty/serial/serial_core.c
    serial: pl011: Add ACPI SBSA UART match id
    tty: serial: msm_serial: Deactivate RX DMA for polling support
    x86/64/mm: Map all kernel memory into trampoline_pgd
    usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect
  * xhci: Fix commad ring abort, write all 64 bits to CRCR register.
      drivers/usb/host/xhci-ring.c
    vgacon: Propagate console boot parameters before calling `vc_resize'
    parisc: Fix "make install" on newer debian releases
    parisc: Fix KBUILD_IMAGE for self-extracting kernel
    net/smc: Keep smc_close_final rc during active close
    net/rds: correct socket tunable error in rds_tcp_tune()
    net: usb: lan78xx: lan78xx_phy_init(): use PHY_POLL instead of "0" if no IRQ is available
    net/mlx4_en: Fix an use-after-free bug in mlx4_en_try_alloc_resources()
  * siphash: use _unaligned version by default
      include/linux/siphash.h
      lib/siphash.c
    net: mpls: Fix notifications when deleting a device
    net: qlogic: qlcnic: Fix a NULL pointer dereference in qlcnic_83xx_add_rings()
    natsemi: xtensa: fix section mismatch warnings
  * fget: check that the fd still exists after getting a ref to it
      fs/file.c
  * fs: add fget_many() and fput_many()
      fs/file.c
      fs/file_table.c
      include/linux/file.h
      include/linux/fs.h
    sata_fsl: fix warning in remove_proc_entry when rmmod sata_fsl
    sata_fsl: fix UAF in sata_fsl_port_stop when rmmod sata_fsl
  * kprobes: Limit max data_size of the kretprobe instances
      include/linux/kprobes.h
    vrf: Reset IPCB/IP6CB when processing outbound pkts in vrf dev xmit
    perf hist: Fix memory leak of a perf_hpp_fmt
    net: ethernet: dec: tulip: de4x5: fix possible array overflows in type3_infoblock()
    net: tulip: de4x5: fix the problem that the array 'lp->phy[8]' may be out of bound
    ethernet: hisilicon: hns: hns_dsaf_misc: fix a possible array overflow in hns_dsaf_ge_srst_by_port()
    scsi: iscsi: Unblock session then wake up error handler
  * thermal: core: Reset previous low and high trip during thermal zone init
      drivers/thermal/thermal_core.c
    btrfs: check-integrity: fix a warning on write caching disabled disk
    s390/setup: avoid using memblock_enforce_memory_limit
    platform/x86: thinkpad_acpi: Fix WWAN device disabled issue after S3 deep
  * net: return correct error code
      net/ipv4/devinet.c
    hugetlb: take PMD sharing into account when flushing tlb/caches
    NFSv42: Fix pagecache invalidation after COPY/CLONE
    ipc: WARN if trying to remove ipc object which is absent
  * shm: extend forced shm destroy to support objects from several IPC nses
      include/linux/ipc_namespace.h
      include/linux/sched/task.h
      include/linux/shm.h
    tty: hvc: replace BUG_ON() with negative return value
    xen/netfront: don't trust the backend response data blindly
    xen/netfront: disentangle tx_skb_freelist
    xen/netfront: don't read data from request on the ring page
    xen/netfront: read response from backend only once
    xen/blkfront: don't trust the backend response data blindly
    xen/blkfront: don't take local copy of a request from the ring page
    xen/blkfront: read response from backend only once
    xen: sync include/xen/interface/io/ring.h with Xen's newest version
  * fuse: release pipe buf after last use
      fs/fuse/dev.c
    NFC: add NCI_UNREG flag to eliminate the race
    proc/vmcore: fix clearing user buffer by properly using clear_user()
  * hugetlbfs: flush TLBs correctly after huge_pmd_unshare
      include/asm-generic/tlb.h
      mm/memory.c
    arm64: dts: marvell: armada-37xx: Set pcie_reset_pin to gpio function
    arm64: dts: marvell: armada-37xx: declare PCIe reset pin
    pinctrl: armada-37xx: Correct PWM pins definitions
    pinctrl: armada-37xx: add missing pin: PCIe1 Wakeup
    pinctrl: armada-37xx: Correct mpp definitions
    PCI: aardvark: Fix checking for link up via LTSSM state
    PCI: aardvark: Fix link training
  * PCI: Add PCI_EXP_LNKCTL2_TLS* macros
      include/uapi/linux/pci_regs.h
    PCI: aardvark: Fix PCIe Max Payload Size setting
    PCI: aardvark: Configure PCIe resources from 'ranges' DT property
    PCI: aardvark: Remove PCIe outbound window configuration
    PCI: aardvark: Update comment about disabling link training
    PCI: aardvark: Move PCIe reset card code to advk_pcie_train_link()
    PCI: aardvark: Fix compilation on s390
    PCI: aardvark: Don't touch PCIe registers if no card connected
    PCI: aardvark: Introduce an advk_pcie_valid_device() helper
    PCI: aardvark: Indicate error in 'val' when config read fails
    PCI: aardvark: Replace custom macros by standard linux/pci_regs.h macros
    PCI: aardvark: Issue PERST via GPIO
    PCI: aardvark: Improve link training
    PCI: aardvark: Train link immediately after enabling training
    PCI: aardvark: Wait for endpoint to be ready before training link
    PCI: aardvark: Fix a leaked reference by adding missing of_node_put()
    PCI: aardvark: Fix I/O space page leak
    s390/mm: validate VMA in PGSTE manipulation functions
  * tracing: Check pid filtering when creating events
      kernel/trace/trace_events.c
    vhost/vsock: fix incorrect used length reported to the guest
    net/smc: Don't call clcsock shutdown twice when smc shutdown
    MIPS: use 3-level pgtable for 64KB page size on MIPS_VA_BITS_48
  * tcp_cubic: fix spurious Hystart ACK train detections for not-cwnd-limited flows
      net/ipv4/tcp_cubic.c
    PM: hibernate: use correct mode for swsusp_close()
    net/smc: Ensure the active closing peer first closes clcsock
  * ipv6: fix typos in __ip6_finish_output()
      net/ipv6/ip6_output.c
    drm/vc4: fix error code in vc4_create_object()
    scsi: mpt3sas: Fix kernel panic during drive powercycle test
    ARM: socfpga: Fix crash with CONFIG_FORTIRY_SOURCE
    NFSv42: Don't fail clone() unless the OP_CLONE operation failed
  * net: ieee802154: handle iftypes as u32
      include/net/nl802154.h
    ASoC: topology: Add missing rwsem around snd_ctl_remove() calls
    ARM: dts: BCM5301X: Add interrupt properties to GPIO node
    ARM: dts: BCM5301X: Fix I2C controller interrupt
    netfilter: ipvs: Fix reuse connection if RS weight is 0
  * tracing: Fix pid filtering when triggers are attached
      kernel/trace/trace.h
    xen: detect uninitialized xenbus in xenbus_init
    xen: don't continue xenstore initialization in case of errors
  * fuse: fix page stealing
      fs/fuse/dev.c
    staging: rtl8192e: Fix use after free in _rtl92e_pci_disconnect()
    HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts
    media: cec: copy sequence field for the reply
    ALSA: ctxfi: Fix out-of-range access
  * binder: fix test regression due to sender_euid change
      drivers/android/binder.c
  * usb: hub: Fix locking issues with address0_mutex
      drivers/usb/core/hub.c
  * usb: hub: Fix usb enumeration issue due to address0 race
      drivers/usb/core/hub.c
    USB: serial: option: add Fibocom FM101-GL variants
    USB: serial: option: add Telit LE910S1 0x9200 composition
    Merge 4.14.256 into android-4.14-stable
Linux 4.14.256
    soc/tegra: pmc: Fix imbalanced clock disabling in error code path
    usb: max-3421: Use driver data instead of maintaining a list of bound devices
  * ASoC: DAPM: Cover regression by kctl change notification fix
      sound/soc/soc-dapm.c
    RDMA/netlink: Add __maybe_unused to static inline in C file
    batman-adv: Don't always reallocate the fragmentation skb head
    batman-adv: Reserve needed_*room for fragments
    batman-adv: Consider fragmentation for needed_headroom
    batman-adv: mcast: fix duplicate mcast packets from BLA backbone to mesh
    batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN
  * perf/core: Avoid put_page() when GUP fails
      kernel/events/core.c
    drm/amdgpu: fix set scaling mode Full/Full aspect/Center not works on vga and dvi connectors
    drm/udl: fix control-message timeout
  * cfg80211: call cfg80211_stop_ap when switch from P2P_GO type
      net/wireless/util.c
    parisc/sticon: fix reverse colors
    btrfs: fix memory ordering between normal and ordered work functions
  * mm: kmemleak: slob: respect SLAB_NOLEAKTRACE flag
      mm/slab.h
    hexagon: export raw I/O routines for modules
  * tun: fix bonding active backup with arp monitoring
      drivers/net/tun.c
    perf/x86/intel/uncore: Fix IIO event constraints for Skylake Server
    perf/x86/intel/uncore: Fix filter_tid mask for CHA events on Skylake Server
    NFC: reorder the logic in nfc_{un,}register_device
    NFC: reorganize the functions in nci_request
    i40e: Fix NULL ptr dereference on VSI filter sync
  * net: virtio_net_hdr_to_skb: count transport header in UFO
      include/linux/virtio_net.h
    platform/x86: hp_accel: Fix an error handling path in 'lis3lv02d_probe()'
    mips: lantiq: add support for clk_get_parent()
    mips: bcm63xx: add support for clk_get_parent()
    MIPS: generic/yamon-dt: fix uninitialized variable error
    iavf: Fix for the false positive ASQ/ARQ errors while issuing VF reset
    net: bnx2x: fix variable dereferenced before check
  * sched/core: Mitigate race cpus_share_cache()/update_top_cache_domain()
      kernel/sched/core.c
    mips: BCM63XX: ensure that CPU_SUPPORTS_32BIT_KERNEL is set
    sh: define __BIG_ENDIAN for math-emu
    sh: fix kconfig unmet dependency warning for FRAME_POINTER
    maple: fix wrong return value of maple_bus_init().
    sh: check return code of request_irq
    powerpc/dcr: Use cmplwi instead of 3-argument cmpli
    ALSA: gus: fix null pointer dereference on pointer block
    powerpc/5200: dts: fix memory node unit name
    scsi: target: Fix alua_tg_pt_gps_count tracking
    scsi: target: Fix ordered tag handling
    MIPS: sni: Fix the build
  * tty: tty_buffer: Fix the softlockup issue in flush_to_ldisc
      drivers/tty/tty_buffer.c
    usb: host: ohci-tmio: check return value after calling platform_get_resource()
    ARM: dts: omap: fix gpmc,mux-add-data type
    scsi: advansys: Fix kernel pointer leak
    usb: musb: tusb6010: check return value after calling platform_get_resource()
    scsi: lpfc: Fix list_add() corruption in lpfc_drain_txq()
    arm64: zynqmp: Fix serial compatible string
  * PCI/MSI: Destroy sysfs before freeing entries
      drivers/pci/msi.c
    parisc/entry: fix trace test in syscall exit path
  * tracing: Resize tgid_map to pid_max, not PID_MAX_DEFAULT
      kernel/trace/trace.c
  * ext4: fix lazy initialization next schedule time computation in more granular unit
      fs/ext4/super.c
  * PCI: Add PCI_EXP_DEVCTL_PAYLOAD_* macros
      include/uapi/linux/pci_regs.h
    s390/cio: check the subchannel validity for dev_busid
  * mm, oom: do not trigger out_of_memory from the #PF
      mm/oom_kill.c
  * mm, oom: pagefault_out_of_memory: don't force global OOM for dying tasks
      mm/oom_kill.c
    powerpc/bpf: Fix BPF_SUB when imm == 0x80000000
    powerpc/bpf: Validate branch ranges
    powerpc/lib: Add helper to check if offset is within conditional branch range
    ARM: 9156/1: drop cc-option fallbacks for architecture selection
    ARM: 9155/1: fix early early_iounmap()
    USB: chipidea: fix interrupt deadlock
    vsock: prevent unnecessary refcnt inc for nonblocking connect
    nfc: pn533: Fix double free when pn533_fill_fragment_skbs() fails
  * llc: fix out-of-bound array index in llc_sk_dev_hash()
      include/net/llc.h
  * mm/zsmalloc.c: close race window between zs_pool_dec_isolated() and zs_unregister_migration()
      mm/zsmalloc.c
  * bonding: Fix a use-after-free problem when bond_sysfs_slave_add() failed
      drivers/net/bonding/bond_sysfs_slave.c
    ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses
    net: davinci_emac: Fix interrupt pacing disable
    xen-pciback: Fix return in pm_ctrl_init()
    i2c: xlr: Fix a resource leak in the error handling path of 'xlr_i2c_probe()'
    scsi: qla2xxx: Turn off target reset during issue_lip
  * ar7: fix kernel builds for compiler test
      drivers/watchdog/Kconfig
    watchdog: f71808e_wdt: fix inaccurate report in WDIOC_GETTIMEOUT
    m68k: set a default value for MEMORY_RESERVE
  * dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result`
      drivers/dma/dmaengine.h
  * netfilter: nfnetlink_queue: fix OOB when mac header was cleared
      net/netfilter/nfnetlink_queue.c
    auxdisplay: ht16k33: Fix frame buffer device blanking
    auxdisplay: ht16k33: Connect backlight to fbdev
    auxdisplay: img-ascii-lcd: Fix lock-up when displaying empty string
    dmaengine: at_xdmac: fix AT_XDMAC_CC_PERID() macro
    mtd: spi-nor: hisi-sfc: Remove excessive clk_disable_unprepare()
    fs: orangefs: fix error return code of orangefs_revalidate_lookup()
    NFS: Fix deadlocks in nfs_scan_commit_list()
    PCI: aardvark: Don't spam about PIO Response Status
  * drm/plane-helper: fix uninitialized variable reference
      drivers/gpu/drm/drm_plane_helper.c
    pnfs/flexfiles: Fix misplaced barrier in nfs4_ff_layout_prepare_ds
  * rpmsg: Fix rpmsg_create_ept return when RPMSG config is not defined
      include/linux/rpmsg.h
    apparmor: fix error check
    power: supply: bq27xxx: Fix kernel crash on IRQ handler register error
    mips: cm: Convert to bitfield API to fix out-of-bounds access
    serial: xilinx_uartps: Fix race condition causing stuck TX
    ASoC: cs42l42: Defer probe if request_threaded_irq() returns EPROBE_DEFER
    ASoC: cs42l42: Correct some register default values
    RDMA/mlx4: Return missed an error if device doesn't support steering
    scsi: csiostor: Uninitialized data in csio_ln_vnp_read_cbfn()
    power: supply: rt5033_battery: Change voltage values to µV
    usb: gadget: hid: fix error code in do_config()
    serial: 8250_dw: Drop wrong use of ACPI_PTR()
    video: fbdev: chipsfb: use memset_io() instead of memset()
    memory: fsl_ifc: fix leak of irq and nand_irq in fsl_ifc_ctrl_probe
    soc/tegra: Fix an error handling path in tegra_powergate_power_up()
    arm: dts: omap3-gta04a4: accelerometer irq fix
    ALSA: hda: Reduce udelay() at SKL+ position reporting
    JFS: fix memleak in jfs_mount
    MIPS: loongson64: make CPU_LOONGSON64 depends on MIPS_FP_SUPPORT
    scsi: dc395: Fix error case unwinding
    ARM: dts: at91: tse850: the emac<->phy interface is rmii
    ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc()
    RDMA/rxe: Fix wrong port_cap_flags
    ibmvnic: Process crqs after enabling interrupts
    crypto: pcrypt - Delay write to padata->info
    net: phylink: avoid mvneta warning when setting pause parameters
    net: amd-xgbe: Toggle PLL settings during rate change
    libertas: Fix possible memory leak in probe and disconnect
    libertas_tf: Fix possible memory leak in probe and disconnect
    samples/kretprobes: Fix return value if register_kretprobe() failed
    irq: mips: avoid nested irq_enter()
    s390/gmap: don't unconditionally call pte_unmap_unlock() in __gmap_zap()
    smackfs: use netlbl_cfg_cipsov4_del() for deleting cipso_v4_doi
    PM: hibernate: fix sparse warnings
  * phy: micrel: ksz8041nl: do not use power down mode
      drivers/net/phy/micrel.c
    mwifiex: Send DELBA requests according to spec
    platform/x86: thinkpad_acpi: Fix bitwise vs. logical warning
    mmc: mxs-mmc: disable regulator on error and in the remove function
  * net: stream: don't purge sk_error_queue in sk_stream_kill_queues()
      net/core/stream.c
  * drm/msm: uninitialized variable in msm_gem_import()
      drivers/gpu/drm/msm/msm_gem.c
    ath10k: fix max antenna gain unit
  * hwmon: Fix possible memleak in __hwmon_device_register()
      drivers/hwmon/hwmon.c
    memstick: jmb38x_ms: use appropriate free function in jmb38x_ms_alloc_host()
    memstick: avoid out-of-range warning
    b43: fix a lower bounds test
    b43legacy: fix a lower bounds test
    hwrng: mtk - Force runtime pm ops for sleep ops
    crypto: qat - disregard spurious PFVF interrupts
    crypto: qat - detect PFVF collision after ACK
    ath9k: Fix potential interrupt storm on queue reset
  * cpuidle: Fix kobject memory leaks in error paths
      drivers/cpuidle/sysfs.c
    media: cx23885: Fix snd_card_free call on null card pointer
    media: si470x: Avoid card name truncation
    media: mtk-vpu: Fix a resource leak in the error handling path of 'mtk_vpu_probe()'
    media: dvb-usb: fix ununit-value in az6027_rc_query
  * cgroup: Make rebind_subsystems() disable v2 controllers all at once
      kernel/cgroup/cgroup.c
    parisc/kgdb: add kgdb_roundup() to make kgdb work with idle polling
  * task_stack: Fix end_of_stack() for architectures with upwards-growing stack
      include/linux/sched/task_stack.h
    parisc: fix warning in flush_tlb_all
    spi: bcm-qspi: Fix missing clk_disable_unprepare() on error in bcm_qspi_probe()
    ARM: 9136/1: ARMv7-M uses BE-8, not BE-32
  * gre/sit: Don't generate link-local addr if addr_gen_mode is IN6_ADDR_GEN_MODE_NONE
      net/ipv6/addrconf.c
    ARM: clang: Do not rely on lr register for stacktrace
    smackfs: use __GFP_NOFAIL for smk_cipso_doi()
    iwlwifi: mvm: disable RX-diversity in powersave
    PM: hibernate: Get block device exclusively in swsusp_check()
    mwl8k: Fix use-after-free in mwl8k_fw_state_machine()
    tracing/cfi: Fix cmp_entries_* functions signature mismatch
  * lib/xz: Validate the value before assigning it to an enum variable
      lib/xz/xz_dec_stream.c
  * lib/xz: Avoid overlapping memcpy() with invalid input with in-place decompression
      lib/xz/xz_dec_lzma2.c
    memstick: r592: Fix a UAF bug when removing the driver
    leaking_addresses: Always print a trailing newline
    ACPI: battery: Accept charges over the design capacity as full
    ath: dfs_pattern_detector: Fix possible null-pointer dereference in channel_detector_create()
  * tracefs: Have tracefs directories not set OTH permission bits by default
      fs/tracefs/inode.c
    media: usb: dvd-usb: fix uninit-value bug in dibusb_read_eeprom_byte()
    ACPICA: Avoid evaluating methods too early during system resume
    ia64: don't do IA64_CMPXCHG_DEBUG without CONFIG_PRINTK
    media: mceusb: return without resubmitting URB in case of -EPROTO error.
    media: s5p-mfc: Add checking to s5p_mfc_probe().
    media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe()
  * media: uvcvideo: Set capability in s_param
      drivers/media/usb/uvc/uvc_v4l2.c
    media: netup_unidvb: handle interrupt properly according to the firmware
    media: mt9p031: Fix corrupted frame after restarting stream
    mwifiex: Properly initialize private structure on interface type changes
    mwifiex: Run SET_BSS_MODE when changing from P2P to STATION vif-type
    x86: Increase exception stack sizes
    smackfs: Fix use-after-free in netlbl_catmap_walk()
    locking/lockdep: Avoid RCU-induced noinstr fail
    MIPS: lantiq: dma: reset correct number of channel
    MIPS: lantiq: dma: add small delay after reset
    platform/x86: wmi: do not fail if disabling fails
  * Bluetooth: fix use-after-free error in lock_sock_nested()
      net/bluetooth/l2cap_sock.c
  * Bluetooth: sco: Fix lock_sock() blockage by memcpy_from_msg()
      net/bluetooth/sco.c
    USB: iowarrior: fix control-message timeouts
    USB: serial: keyspan: fix memleak on probe errors
    iio: dac: ad5446: Fix ad5622_write() return value
  * pinctrl: core: fix possible memory leak in pinctrl_enable()
      drivers/pinctrl/core.c
  * quota: correct error number in free_dqentry()
      fs/quota/quota_tree.c
  * quota: check block number when reading the block in quota file
      fs/quota/quota_tree.c
    PCI: aardvark: Read all 16-bits from PCIE_MSI_PAYLOAD_REG
    PCI: aardvark: Fix return value of MSI domain .alloc() method
    PCI: aardvark: Do not unmask unused interrupts
    PCI: aardvark: Do not clear status bits of masked interrupts
    xen/balloon: add late_initcall_sync() for initial ballooning done
    ALSA: mixer: fix deadlock in snd_mixer_oss_set_volume
    ALSA: mixer: oss: Fix racy access to slots
  * serial: core: Fix initializing and restoring termios speed
      drivers/tty/serial/serial_core.c
      include/linux/console.h
    powerpc/85xx: Fix oops when mpc85xx_smp_guts_ids node cannot be found
    power: supply: max17042_battery: use VFSOC for capacity when no rsns
    power: supply: max17042_battery: Prevent int underflow in set_soc_threshold
    signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT
  * signal: Remove the bogus sigkill_pending in ptrace_stop
      kernel/signal.c
    RDMA/qedr: Fix NULL deref for query_qp on the GSI QP
    wcn36xx: handle connection loss indication
    libata: fix checking of DMA state
    mwifiex: Read a PCI register after writing the TX ring write pointer
    wcn36xx: Fix HT40 capability for 2Ghz band
    evm: mark evm_fixmode as __ro_after_init
    rtl8187: fix control-message timeouts
  * PCI: Mark Atheros QCA6174 to avoid bus reset
      drivers/pci/quirks.c
    ath10k: fix division by zero in send path
    ath10k: fix control-message timeout
    ath6kl: fix control-message timeout
    ath6kl: fix division by zero in send path
    mwifiex: fix division by zero in fw download path
    EDAC/sb_edac: Fix top-of-high-memory value for Broadwell/Haswell
    regulator: dt-bindings: samsung,s5m8767: correct s5m8767,pmic-buck-default-dvs-idx property
    regulator: s5m8767: do not use reset value as DVS voltage if GPIO DVS is disabled
    hwmon: (pmbus/lm25066) Add offset coefficients
    btrfs: fix lost error handling when replaying directory deletes
    vmxnet3: do not stop tx queues after netif_device_detach()
    watchdog: Fix OMAP watchdog early handling
    spi: spl022: fix Microwire full duplex mode
    xen/netfront: stop tx queues during live migration
  * bpf: Prevent increasing bpf_jit_limit above max
      include/linux/filter.h
      kernel/bpf/core.c
      net/core/sysctl_net_core.c
  * mmc: winbond: don't build on M68K
      drivers/mmc/host/Kconfig
    hyperv/vmbus: include linux/bitops.h
    sfc: Don't use netif_info before net_device setup
    cavium: Fix return values of the probe function
    scsi: qla2xxx: Fix unmap of already freed sgl
    cavium: Return negative value when pci_alloc_irq_vectors() fails
    x86/irq: Ensure PI wakeup handler is unregistered before module unload
  * ALSA: timer: Unconditionally unlink slave instances, too
      sound/core/timer.c
  * ALSA: timer: Fix use-after-free problem
      sound/core/timer.c
    ALSA: synth: missing check for possible NULL after the call to kstrdup
    ALSA: line6: fix control and interrupt message timeouts
    ALSA: 6fire: fix control and bulk message timeouts
    ALSA: ua101: fix division by zero at probe
    media: ite-cir: IR receiver stop working after receive overflow
    tpm: Check for integer overflow in tpm2_map_response_body()
    parisc: Fix ptrace check on syscall return
    mmc: dw_mmc: Dont wait for DRTO on Write RSP error
    ocfs2: fix data corruption on truncate
    libata: fix read log timeout value
    Input: i8042 - Add quirk for Fujitsu Lifebook T725
    Input: elantench - fix misreporting trackpoint coordinates
  * binder: use cred instead of task for selinux checks
      drivers/android/binder.c
      include/linux/lsm_hooks.h
      include/linux/security.h
      security/security.c
      security/selinux/hooks.c
  * binder: use euid from cred instead of using task
      drivers/android/binder.c
  * xhci: Fix USB 3.1 enumeration issues by increasing roothub power-on-good delay
      drivers/usb/host/xhci-hub.c
  * ANDROID: usb: gadget: f_accessory: Mitgate handling of non-existent USB request
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: arm64: process: Match upstream formatting when dumping memory areas
      arch/arm64/kernel/process.c
  * FROMGIT: binder: fix test regression due to sender_euid change
      drivers/android/binder.c
  * BACKPORT: binder: use cred instead of task for selinux checks
      drivers/android/binder.c
      include/linux/lsm_hooks.h
      include/linux/security.h
      security/security.c
      security/selinux/hooks.c
  * UPSTREAM: binder: use euid from cred instead of using task
      drivers/android/binder.c
    Merge 4.14.255 into android-4.14-stable
Linux 4.14.255
    rsi: fix control-message timeout
    staging: rtl8192u: fix control-message timeouts
    staging: r8712u: fix control-message timeout
    comedi: vmk80xx: fix bulk and interrupt message timeouts
    comedi: vmk80xx: fix bulk-buffer overflow
    comedi: vmk80xx: fix transfer-buffer overflows
    comedi: ni_usb6501: fix NULL-deref in command paths
    comedi: dt9812: fix DMA buffers on stack
    isofs: Fix out of bound access for corrupted isofs image
  * printk/console: Allow to disable console output by using console="" or console=null
      kernel/printk/printk.c
  * usb-storage: Add compatibility quirk flags for iODD 2531/2541
      drivers/usb/storage/unusual_devs.h
    usb: musb: Balance list entry in musb_gadget_queue
  * usb: gadget: Mark USB_FSL_QE broken on 64-bit
      drivers/usb/gadget/udc/Kconfig
    Revert "x86/kvm: fix vcpu-id indexed array sizes"
  * block: introduce multi-page bvec helpers
      include/linux/bvec.h
    IB/qib: Protect from buffer overflow in struct qib_user_sdma_pkt fields
    IB/qib: Use struct_size() helper
  * ARM: 9120/1: Revert "amba: make use of -1 IRQs warn"
      drivers/amba/bus.c
  * arch: pgtable: define MAX_POSSIBLE_PHYSMEM_BITS where needed
      include/asm-generic/pgtable.h
  * mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS
      mm/zsmalloc.c
    media: firewire: firedtv-avc: fix a buffer overflow in avc_ca_pmt()
  * scsi: core: Put LLD module refcnt after SCSI device is released
      drivers/scsi/scsi.c
      drivers/scsi/scsi_sysfs.c
  * UPSTREAM: security: selinux: allow per-file labeling for bpffs
      security/selinux/hooks.c

Bug: 210364486
Signed-off-by: JohnnLee <johnnlee@google.com>
Change-Id: I34320a77ca45e0f7d383820ce6b779c682200455
2022-01-04 06:14:00 +00:00
Todd Kjos
84b7952669 binder: use cred instead of task for selinux checks
commit 52f88693378a58094c538662ba652aff0253c4fe upstream.

Since binder was integrated with selinux, it has passed
'struct task_struct' associated with the binder_proc
to represent the source and target of transactions.
The conversion of task to SID was then done in the hook
implementations. It turns out that there are race conditions
which can result in an incorrect security context being used.

Fix by using the 'struct cred' saved during binder_open and pass
it to the selinux subsystem.

Cc: stable@vger.kernel.org # 5.14 (need backport for earlier stables)
Fixes: 79af73079d ("Add security hooks to binder and implement the hooks for SELinux.")
Suggested-by: Jann Horn <jannh@google.com>
Signed-off-by: Todd Kjos <tkjos@google.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-11-26 11:40:20 +01:00
Todd Kjos
9693ca7b52 BACKPORT: binder: use cred instead of task for selinux checks
commit 52f88693378a58094c538662ba652aff0253c4fe upstream.

Since binder was integrated with selinux, it has passed
'struct task_struct' associated with the binder_proc
to represent the source and target of transactions.
The conversion of task to SID was then done in the hook
implementations. It turns out that there are race conditions
which can result in an incorrect security context being used.

Fix by using the 'struct cred' saved during binder_open and pass
it to the selinux subsystem.

Cc: stable@vger.kernel.org # 5.14 (need backport for earlier stables)
Fixes: 79af73079d ("Add security hooks to binder and implement the hooks for SELinux.")
Suggested-by: Jann Horn <jannh@google.com>
Signed-off-by: Todd Kjos <tkjos@google.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Change-Id: Id7157515d2b08f11683aeb8ad9b8f1da075d34e7
Bug: 200688826
[ tkjos@ fixed minor conflict ]
Signed-off-by: Todd Kjos <tkjos@google.com>
2021-11-22 09:29:50 -08:00
Lucas Wei
14ed7c48f3 Merge android-4.14-q (4.14.218) into android-msm-pixel-4.14-lts
Merge 4.14.218 into android-4.14-q
Linux 4.14.218
  * fs: fix lazytime expiration handling in __writeback_single_inode()
      fs/fs-writeback.c
  * writeback: Drop I_DIRTY_TIME_EXPIRE
      fs/ext4/inode.c
      fs/fs-writeback.c
      include/linux/fs.h
      include/trace/events/writeback.h
  * fs: move I_DIRTY_INODE to fs.h
      fs/ext4/inode.c
      fs/fs-writeback.c
      include/linux/fs.h
    x86/boot/compressed: Disable relocation relaxation
  * tracing: Fix race in trace_open and buffer resize call
      kernel/trace/ring_buffer.c
  * futex: Handle faults correctly for PI futexes
      kernel/futex.c
  * futex: Simplify fixup_pi_state_owner()
      kernel/futex.c
  * futex: Use pi_state_update_owner() in put_pi_state()
      kernel/futex.c
  * rtmutex: Remove unused argument from rt_mutex_proxy_unlock()
      kernel/futex.c
      kernel/locking/rtmutex.c
      kernel/locking/rtmutex_common.h
  * futex: Provide and use pi_state_update_owner()
      kernel/futex.c
  * futex: Replace pointless printk in fixup_owner()
      kernel/futex.c
  * futex: Ensure the correct return value from futex_lock_pi()
      kernel/futex.c
  * Revert "mm/slub: fix a memory leak in sysfs_slab_add()"
      mm/slub.c
    gpio: mvebu: fix pwm .get_state period calculation
  * futex: futex_wake_op, fix sign_extend32 sign bits
      kernel/futex.c
    net: dsa: b53: fix an off by one in checking "vlan->vid"
    net_sched: avoid shift-out-of-bounds in tcindex_set_parms()
  * ipv6: create multicast route with RTPROT_KERNEL
      net/ipv6/addrconf.c
  * udp: mask TOS bits in udp_v4_early_demux()
      net/ipv4/udp.c
  * skbuff: back tiny skbs with kmalloc() in __netdev_alloc_skb() too
      net/core/skbuff.c
    sh_eth: Fix power down vs. is_opened flag ordering
    sh: dma: fix kconfig dependency for G2_DMA
  * netfilter: rpfilter: mask ecn bits before fib lookup
      net/ipv4/netfilter/ipt_rpfilter.c
  * compiler.h: Raise minimum version of GCC to 5.1 for arm64
      include/linux/compiler-gcc.h
    xhci: tegra: Delay for disabling LFPS detector
  * xhci: make sure TRB is fully written before giving it to the controller
      drivers/usb/host/xhci-ring.c
  * usb: bdc: Make bdc pci driver depend on BROKEN
      drivers/usb/gadget/udc/bdc/Kconfig
  * usb: udc: core: Use lock when write to soft_connect
      drivers/usb/gadget/udc/core.c
  * USB: ehci: fix an interrupt calltrace error
      drivers/usb/host/ehci-hub.c
  * ehci: fix EHCI host controller initialization sequence
      drivers/usb/host/ehci-hcd.c
    stm class: Fix module init return on allocation failure
    intel_th: pci: Add Alder Lake-P support
    irqchip/mips-cpu: Set IPI domain parent chip
    iio: ad5504: Fix setting power-down state
    can: vxcan: vxcan_xmit: fix use after free bug
    can: dev: can_restart: fix use after free bug
    i2c: octeon: check correct size of maximum RECV_LEN packet
    drm/nouveau/i2c/gm200: increase width of aux semaphore owner fields
    drm/nouveau/privring: ack interrupts the same way as RM
    drm/nouveau/bios: fix issue shadowing expansion ROMs
  * xen: Fix event channel callback via INTX/GSI
      include/xen/xenbus.h
  * scsi: ufs: Correct the LUN used in eh_device_reset_handler() callback
      drivers/scsi/ufs/ufshcd.c
    ASoC: Intel: haswell: Add missing pm_ops
  * drm/atomic: put state on error path
      drivers/gpu/drm/drm_atomic_helper.c
  * dm: avoid filesystem lookup in dm_get_dev_t()
      drivers/md/dm-table.c
    mmc: sdhci-xenon: fix 1.8v regulator stabilization
    ACPI: scan: Make acpi_bus_get_device() clear return pointer on error
    ALSA: hda/via: Add minimum mute flag
    ALSA: seq: oss: Fix missing error check in snd_seq_oss_synth_make_info()
    i2c: bpmp-tegra: Ignore unknown I2C_M flags
    Merge 4.14.217 into android-4.14-q
Linux 4.14.217
    spi: cadence: cache reference clock rate during probe
  * net: ipv6: Validate GSO SKB before finish IPv6 processing
      net/ipv6/ip6_output.c
  * net: skbuff: disambiguate argument and member for skb_list_walk_safe helper
      include/linux/skbuff.h
  * net: introduce skb_list_walk_safe for skb segment walking
      include/linux/skbuff.h
  * net: use skb_list_del_init() to remove from RX sublists
      include/linux/skbuff.h
    tipc: fix NULL deref in tipc_link_xmit()
    rxrpc: Fix handling of an unsupported token type in rxrpc_read()
  * net: avoid 32 x truesize under-estimation for tiny skbs
      net/core/skbuff.c
  * net: sit: unregister_netdevice on newlink's error path
      net/ipv6/sit.c
    net: stmmac: Fixed mtu channged by cache aligned
    net: dcb: Accept RTM_GETDCB messages carrying set-like DCB commands
    net: dcb: Validate netlink message in DCB handler
  * esp: avoid unneeded kmap_atomic call
      net/ipv4/esp4.c
      net/ipv6/esp6.c
    rndis_host: set proper input size for OID_GEN_PHYSICAL_MEDIUM request
    netxen_nic: fix MSI/MSI-x interrupts
    nfsd4: readdirplus shouldn't return parent of export
  * usb: ohci: Make distrust_firmware param default to false
      drivers/usb/host/ohci-hcd.c
  * netfilter: conntrack: fix reading nf_conntrack_buckets
      net/netfilter/nf_conntrack_standalone.c
    ALSA: fireface: Fix integer overflow in transmit_midi_msg()
    ALSA: firewire-tascam: Fix integer overflow in midi_port_work()
  * dm: eliminate potential source of excessive kernel log noise
      drivers/md/dm.c
    net: sunrpc: interpret the return value of kstrtou32 correctly
  * mm, slub: consider rest of partial list if acquire_slab() fails
      mm/slub.c
    RDMA/usnic: Fix memleak in find_free_vf_and_create_qp_grp
  * ext4: fix superblock checksum failure when setting password salt
      fs/ext4/ioctl.c
    NFS: nfs_igrab_and_active must first reference the superblock
    pNFS: Mark layout for return if return-on-close was not sent
    NFS4: Fix use-after-free in trace_event_raw_event_nfs4_set_lock
    ASoC: Intel: fix error code cnl_set_dsp_D0()
  * dump_common_audit_data(): fix racy accesses to ->d_name
      security/lsm_audit.c
    ARM: picoxcell: fix missing interrupt-parent properties
  * ACPI: scan: add stub acpi_create_platform_device() for !CONFIG_ACPI
      include/linux/acpi.h
    net: ethernet: fs_enet: Add missing MODULE_LICENSE
  * misdn: dsp: select CONFIG_BITREVERSE
      drivers/isdn/mISDN/Kconfig
  * arch/arc: add copy_user_page() to <asm/page.h> to fix build error on ARC
      arch/arc/include/asm/page.h
    ethernet: ucc_geth: fix definition and size of ucc_geth_tx_global_pram
    btrfs: fix transaction leak and crash after RO remount caused by qgroup rescan
    ARC: build: add boot_targets to PHONY
    ARC: build: add uImage.lzma to the top-level target
    ARC: build: remove non-existing bootpImage from KBUILD_IMAGE
  * ext4: fix bug for rename with RENAME_WHITEOUT
      fs/ext4/namei.c
  * r8152: Add Lenovo Powered USB-C Travel Hub
      drivers/net/usb/cdc_ether.c
      drivers/net/usb/r8152.c
  * dm snapshot: flush merged data before committing metadata
      drivers/md/dm-snap.c
    mm/hugetlb: fix potential missing huge page size info
    ACPI: scan: Harden acpi_device_add() against device ID overflows
    MIPS: relocatable: fix possible boot hangup with KASLR enabled
    MIPS: boot: Fix unaligned access with CONFIG_MIPS_RAW_APPENDED_DTB
  * ASoC: dapm: remove widget from dirty list on free
      sound/soc/soc-dapm.c
    Merge 4.14.216 into android-4.14-q
Linux 4.14.216
  * net: drop bogus skb with CHECKSUM_PARTIAL and offset beyond end of trimmed packet
      net/core/skbuff.c
  * block: fix use-after-free in disk_part_iter_next
      block/genhd.c
    KVM: arm64: Don't access PMCR_EL0 when no PMU is available
  * wan: ds26522: select CONFIG_BITREVERSE
      drivers/net/wan/Kconfig
    net/mlx5e: Fix two double free cases
    net/mlx5e: Fix memleak in mlx5e_create_l2_table_groups
    iommu/intel: Fix memleak in intel_irq_remapping_alloc
  * block: rsxx: select CONFIG_CRC32
      drivers/block/Kconfig
  * wil6210: select CONFIG_CRC32
      drivers/net/wireless/ath/wil6210/Kconfig
    dmaengine: xilinx_dma: fix mixed_enum_type coverity warning
    dmaengine: xilinx_dma: check dma_async_device_register return value
    spi: stm32: FIFO threshold level - fix align packet size
    cpufreq: powernow-k8: pass policy rather than use cpufreq_cpu_get()
    i2c: sprd: use a specific timeout to avoid system hang up issue
    ARM: OMAP2+: omap_device: fix idling of devices during probe
    iio: imu: st_lsm6dsx: fix edge-trigger interrupts
    iio: imu: st_lsm6dsx: flip irq return logic
    spi: pxa2xx: Fix use-after-free on unbind
    ubifs: wbuf: Don't leak kernel memory to flash
    drm/i915: Fix mismatch between misplaced vma check and vma insert
  * vmlinux.lds.h: Add PGO and AutoFDO input sections
      include/asm-generic/vmlinux.lds.h
    x86/resctrl: Don't move a task to the same resource group
    x86/resctrl: Use an IPI instead of task_work_add() to update PQR_ASSOC MSR
  * net: fix pmtu check in nopmtudisc mode
      net/ipv4/ip_tunnel.c
  * net: ip: always refragment ip defragmented packets
      net/ipv4/ip_output.c
    net: vlan: avoid leaks on register_vlan_dev() failures
  * net: cdc_ncm: correct overhead in delayed_ndp_size
      drivers/net/usb/cdc_ncm.c
  * powerpc: Fix incorrect stw{, ux, u, x} instructions in __set_pte_at
      arch/powerpc/include/asm/book3s/32/pgtable.h
      arch/powerpc/include/asm/nohash/pgtable.h
    ANDROID: cuttlefish_defconfig: add missing CONFIG_BLK_CGROUP
    Merge 4.14.215 into android-4.14-q
Linux 4.14.215
    scsi: target: Fix XCOPY NAA identifier lookup
  * KVM: x86: fix shift out of bounds reported by UBSAN
      arch/x86/kvm/mmu.h
    x86/mtrr: Correct the range check before performing MTRR type lookups
    netfilter: xt_RATEEST: reject non-null terminated string from userspace
    netfilter: ipset: fix shift-out-of-bounds in htable_bits()
  * Revert "device property: Keep secondary firmware node secondary by type"
      drivers/base/core.c
    ALSA: hda/realtek - Fix speaker volume control on Lenovo C940
    ALSA: hda/conexant: add a new hda codec CX11970
    x86/mm: Fix leak of pmd ptlock
    USB: serial: keyspan_pda: remove unused variable
  * usb: gadget: configfs: Fix use-after-free issue with udc_name
      drivers/usb/gadget/configfs.c
  * usb: gadget: configfs: Preserve function ordering after bind failure
      drivers/usb/gadget/configfs.c
  * usb: gadget: Fix spinlock lockup on usb_function_deactivate
      drivers/usb/gadget/composite.c
    USB: gadget: legacy: fix return error code in acm_ms_bind()
    usb: gadget: function: printer: Fix a memory leak for interface descriptor
    usb: gadget: f_uac2: reset wMaxPacketSize
  * usb: gadget: select CONFIG_CRC32
      drivers/usb/gadget/Kconfig
  * ALSA: usb-audio: Fix UBSAN warnings for MIDI jacks
      sound/usb/midi.c
    USB: usblp: fix DMA to stack
    USB: yurex: fix control-URB timeout handling
    USB: serial: option: add Quectel EM160R-GL
    USB: serial: option: add LongSung M5710 module support
    USB: serial: iuu_phoenix: fix DMA from stack
    usb: uas: Add PNY USB Portable SSD to unusual_uas
    usb: usbip: vhci_hcd: protect shift size
  * USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set
      drivers/usb/host/xhci.c
    usb: chipidea: ci_hdrc_imx: add missing put_device() call in usbmisc_get_init_data()
  * usb: dwc3: ulpi: Use VStsDone to detect PHY regs access completion
      drivers/usb/dwc3/core.h
    USB: cdc-acm: blacklist another IR Droid device
  * usb: gadget: enable super speed plus
      drivers/usb/gadget/configfs.c
  * crypto: ecdh - avoid buffer overflow in ecdh_set_secret()
      crypto/ecdh.c
    video: hyperv_fb: Fix the mmap() regression for v5.4.y and older
    net: systemport: set dev->max_mtu to UMAC_MAX_MTU_SIZE
    net: mvpp2: Fix GoP port 3 Networking Complex Control configurations
  * net-sysfs: take the rtnl lock when accessing xps_cpus_map and num_tc
      net/core/net-sysfs.c
  * net: sched: prevent invalid Scell_log shift count
      include/net/red.h
    vhost_net: fix ubuf refcount incorrectly when sendmsg fails
    net: usb: qmi_wwan: add Quectel EM160R-GL
  * CDC-NCM: remove "connected" log message
      drivers/net/usb/cdc_ncm.c
    net: hdlc_ppp: Fix issues when mod_timer is called while timer is running
    net: hns: fix return value check in __lb_other_process()
  * ipv4: Ignore ECN bits for fib lookups in fib_compute_spec_dst()
      net/ipv4/fib_frontend.c
    net: ethernet: ti: cpts: fix ethtool output when no ptp_clock registered
  * net-sysfs: take the rtnl lock when storing xps_cpus
      net/core/net-sysfs.c
    net: ethernet: Fix memleak in ethoc_probe
    net/ncsi: Use real net-device for response handler
    virtio_net: Fix recursive call to cpus_read_lock()
    qede: fix offload for IPIP tunnel packets
    atm: idt77252: call pci_disable_device() on error path
    ethernet: ucc_geth: set dev->max_mtu to 1518
    ethernet: ucc_geth: fix use-after-free in ucc_geth_remove()
  * depmod: handle the case of /sbin/depmod without /sbin in PATH
      scripts/depmod.sh
  * lib/genalloc: fix the overflow when size is too big
      lib/genalloc.c
    scsi: ide: Do not set the RQF_PREEMPT flag for sense requests
    scsi: ufs-pci: Ensure UFS device is in PowerDown mode for suspend-to-disk ->poweroff()
  * workqueue: Kick a worker based on the actual activation of delayed works
      kernel/workqueue.c
  * kbuild: don't hardcode depmod path
      Makefile
    Merge 4.14.214 into android-4.14-q
Linux 4.14.214
    mwifiex: Fix possible buffer overflows in mwifiex_cmd_802_11_ad_hoc_start
    iio:magnetometer:mag3110: Fix alignment and data leak issues.
    iio:imu:bmi160: Fix alignment and data leak issues
  * kdev_t: always inline major/minor helper functions
      include/linux/kdev_t.h
  * dm verity: skip verity work if I/O error when system is shutting down
      drivers/md/dm-verity-target.c
  * ALSA: pcm: Clear the full allocated memory at hw_params
      sound/core/pcm_native.c
  * module: delay kobject uevent until after module init call
      kernel/module.c
    powerpc: sysdev: add missing iounmap() on error in mpic_msgr_probe()
  * quota: Don't overflow quota file offsets
      fs/quota/quota_tree.c
  * module: set MODULE_STATE_GOING state when a module fails to load
      kernel/module.c
    rtc: sun6i: Fix memleak in sun6i_rtc_clk_init
    ALSA: seq: Use bool for snd_seq_queue internal flags
    media: gp8psk: initialize stats at power control logic
    misc: vmw_vmci: fix kernel info-leak by initializing dbells in vmci_ctx_get_chkpt_doorbells()
    reiserfs: add check for an invalid ih_entry_count
  * of: fix linker-section match-table corruption
      include/linux/of.h
  * uapi: move constants from <linux/kernel.h> to <linux/const.h>
      include/uapi/linux/const.h
      include/uapi/linux/ethtool.h
      include/uapi/linux/kernel.h
      include/uapi/linux/lightnvm.h
      include/uapi/linux/mroute6.h
      include/uapi/linux/netfilter/x_tables.h
      include/uapi/linux/netlink.h
      include/uapi/linux/sysctl.h
  * powerpc/bitops: Fix possible undefined behaviour with fls() and fls64()
      arch/powerpc/include/asm/bitops.h
    USB: serial: digi_acceleport: fix write-wakeup deadlocks
    s390/dasd: fix hanging device offline processing
    vfio/pci: Move dummy_resources_list init in vfio_pci_probe()
  * mm: memcontrol: fix excessive complexity in memory.stat reporting
      include/linux/memcontrol.h
  * mm: memcontrol: implement lruvec stat functions on top of each other
      include/linux/memcontrol.h
  * mm: memcontrol: eliminate raw access to stat and event counters
      include/linux/memcontrol.h
  * ALSA: usb-audio: fix sync-ep altsetting sanity check
      sound/usb/pcm.c
  * ALSA: usb-audio: simplify set_sync_ep_implicit_fb_quirk
      sound/usb/pcm.c
    ALSA: hda/ca0132 - Fix work handling in delayed HP detection
    md/raid10: initialize r10_bio->read_slot before use.
    x86/entry/64: Add instruction suffix
  * ANDROID: usb: f_accessory: Don't drop NULL reference in acc_disconnect()
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: f_accessory: Avoid bitfields for shared variables
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: f_accessory: Cancel any pending work before teardown
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: f_accessory: Don't corrupt global state on double registration
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: f_accessory: Fix teardown ordering in acc_release()
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: f_accessory: Add refcounting to global 'acc_dev'
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: f_accessory: Wrap '_acc_dev' in get()/put() accessors
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: f_accessory: Remove useless assignment
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: f_accessory: Remove useless non-debug prints
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: f_accessory: Remove stale comments
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: USB: f_accessory: Check dev pointer before decoding ctrl request
      drivers/usb/gadget/function/f_accessory.c
  * ANDROID: usb: gadget: f_accessory: fix CTS test stuck
      drivers/usb/gadget/function/f_accessory.c
    Merge 4.14.213 into android-4.14-q
Linux 4.14.213
  * PCI: Fix pci_slot_release() NULL pointer dereference
      drivers/pci/slot.c
    libnvdimm/namespace: Fix reaping of invalidated block-window-namespace labels
    xenbus/xenbus_backend: Disallow pending watch messages
  * xen/xenbus: Count pending messages for each watch
      include/xen/xenbus.h
    xen/xenbus/xen_bus_type: Support will_handle watch callback
  * xen/xenbus: Add 'will_handle' callback support in xenbus_watch_path()
      include/xen/xenbus.h
  * xen/xenbus: Allow watches discard events before queueing
      include/xen/xenbus.h
    xen-blkback: set ring->xenblkd to NULL after kthread_stop()
    clk: mvebu: a3700: fix the XTAL MODE pin to MPP1_9
    md/cluster: fix deadlock when node is doing resync job
    iio:imu:bmi160: Fix too large a buffer.
    iio:pressure:mpl3115: Force alignment of buffer
    iio:light:rpr0521: Fix timestamp alignment and prevent data leak.
    iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume
    iio: buffer: Fix demux update
    mtd: parser: cmdline: Fix parsing of part-names with colons
  * soc: qcom: smp2p: Safely acquire spinlock without IRQs
      drivers/soc/qcom/smp2p.c
    spi: st-ssc4: Fix unbalanced pm_runtime_disable() in probe error path
    spi: sc18is602: Don't leak SPI master in probe error path
    spi: rb4xx: Don't leak SPI master in probe error path
    spi: pic32: Don't leak DMA channels in probe error path
    spi: davinci: Fix use-after-free on unbind
    spi: spi-sh: Fix use-after-free on unbind
    drm/dp_aux_dev: check aux_dev before use in drm_dp_aux_dev_get_by_minor()
    jfs: Fix array index bounds check in dbAdjTree
    jffs2: Fix GC exit abnormally
    ceph: fix race in concurrent __ceph_remove_cap invocations
    ima: Don't modify file descriptor mode on the fly
    powerpc/powernv/memtrace: Don't leak kernel memory to user space
    powerpc/xmon: Change printk() to pr_cont()
    powerpc/rtas: Fix typo of ibm,open-errinjct in RTAS filter
    ARM: dts: at91: sama5d2: fix CAN message ram offset and size
  * KVM: arm64: Introduce handling of AArch32 TTBCR2 traps
      arch/arm64/include/asm/kvm_host.h
  * ext4: fix deadlock with fs freezing and EA inodes
      fs/ext4/inode.c
  * ext4: fix a memory leak of ext4_free_data
      fs/ext4/mballoc.c
    btrfs: fix return value mixup in btrfs_get_extent
    Btrfs: fix selftests failure due to uninitialized i_mode in test inodes
    USB: serial: keyspan_pda: fix write unthrottling
    USB: serial: keyspan_pda: fix tx-unthrottle use-after-free
    USB: serial: keyspan_pda: fix write-wakeup use-after-free
    USB: serial: keyspan_pda: fix stalled writes
    USB: serial: keyspan_pda: fix write deadlock
    USB: serial: keyspan_pda: fix dropped unthrottle interrupts
    USB: serial: mos7720: fix parallel-port state restore
    EDAC/amd64: Fix PCI component registration
  * crypto: ecdh - avoid unaligned accesses in ecdh_set_secret()
      crypto/ecdh.c
    powerpc/perf: Exclude kernel samples while counting events in user space.
    staging: comedi: mf6x4: Fix AI end-of-conversion detection
    s390/dasd: fix list corruption of lcu list
    s390/dasd: fix list corruption of pavgroup group list
    s390/dasd: prevent inconsistent LCU device data
    s390/smp: perform initial CPU reset also for SMT siblings
  * ALSA: usb-audio: Disable sample read check if firmware doesn't give back
      sound/usb/clock.c
    ALSA: pcm: oss: Fix a few more UBSAN fixes
    ALSA: hda/realtek - Enable headset mic of ASUS Q524UQK with ALC255
    ACPI: PNP: compare the string length in the matching_id()
    Revert "ACPI / resources: Use AE_CTRL_TERMINATE to terminate resources walks"
  * PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup()
      include/acpi/acpi_bus.h
    Input: cyapa_gen6 - fix out-of-bounds stack access
    media: netup_unidvb: Don't leak SPI master in probe error path
    media: sunxi-cir: ensure IR is handled when it is continuous
  * media: gspca: Fix memory leak in probe
      drivers/media/usb/gspca/gspca.c
    Input: goodix - add upside-down quirk for Teclast X98 Pro tablet
    Input: cros_ec_keyb - send 'scancodes' in addition to key events
  * fix namespaced fscaps when !CONFIG_SECURITY
      include/linux/security.h
  * cfg80211: initialize rekey_data
      net/wireless/nl80211.c
    clk: sunxi-ng: Make sure divider tables have sentinel
    clk: s2mps11: Fix a resource leak in error handling paths in the probe function
    qlcnic: Fix error code in probe
    perf record: Fix memory leak when using '--user-regs=?' to list registers
    pwm: lp3943: Dynamically allocate PWM chip base
    pwm: zx: Add missing cleanup in error path
    clk: ti: Fix memleak in ti_fapll_synth_setup
  * watchdog: coh901327: add COMMON_CLK dependency
      drivers/watchdog/Kconfig
    watchdog: qcom: Avoid context switch in restart handler
    net: korina: fix return value
    net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function
    net: bcmgenet: Fix a resource leak in an error handling path in the probe functin
    checkpatch: fix unescaped left brace
    powerpc/ps3: use dma_mapping_error()
    nfc: s3fwrn5: Release the nfc firmware
    um: chan_xterm: Fix fd leak
  * watchdog: sirfsoc: Add missing dependency on HAS_IOMEM
      drivers/watchdog/Kconfig
    irqchip/alpine-msi: Fix freeing of interrupts on allocation error path
  * ASoC: wm_adsp: remove "ctl" from list on error in wm_adsp_create_control()
      sound/soc/codecs/wm_adsp.c
    extcon: max77693: Fix modalias string
    clk: tegra: Fix duplicated SE clock entry
    x86/kprobes: Restore BTF if the single-stepping is cancelled
    nfs_common: need lock during iterate through the list
    nfsd: Fix message level for normal termination
    speakup: fix uninitialized flush_lock
    usb: oxu210hp-hcd: Fix memory leak in oxu_create
    usb: ehci-omap: Fix PM disable depth umbalance in ehci_hcd_omap_probe
    powerpc/pseries/hibernation: remove redundant cacheinfo update
    powerpc/pseries/hibernation: drop pseries_suspend_begin() from suspend ops
    scsi: fnic: Fix error return code in fnic_probe()
  * seq_buf: Avoid type mismatch for seq_buf_init
      include/linux/seq_buf.h
      include/linux/trace_seq.h
    scsi: pm80xx: Fix error return in pm8001_pci_probe()
    scsi: qedi: Fix missing destroy_workqueue() on error in __qedi_probe
    cpufreq: scpi: Add missing MODULE_ALIAS
    cpufreq: loongson1: Add missing MODULE_ALIAS
    cpufreq: st: Add missing MODULE_DEVICE_TABLE
    cpufreq: mediatek: Add missing MODULE_DEVICE_TABLE
    cpufreq: highbank: Add missing MODULE_DEVICE_TABLE
  * clocksource/drivers/arm_arch_timer: Correct fault programming of CNTKCTL_EL1.EVNTI
      drivers/clocksource/arm_arch_timer.c
  * dm ioctl: fix error return code in target_message
      drivers/md/dm-ioctl.c
    ASoC: jz4740-i2s: add missed checks for clk_get()
    net/mlx5: Properly convey driver version to firmware
    memstick: r592: Fix error return in r592_probe()
    arm64: dts: rockchip: Fix UART pull-ups on rk3328
    pinctrl: falcon: add missing put_device() call in pinctrl_falcon_probe()
    ARM: dts: at91: sama5d2: map securam as device
    clocksource/drivers/cadence_ttc: Fix memory leak in ttc_setup_clockevent()
    media: saa7146: fix array overflow in vidioc_s_audio()
    vfio-pci: Use io_remap_pfn_range() for PCI IO memory
    NFS: switch nfsiod to be an UNBOUND workqueue.
    lockd: don't use interval-based rebinding over TCP
  * SUNRPC: xprt_load_transport() needs to support the netid "rdma6"
      include/linux/sunrpc/xprt.h
    NFSv4.2: condition READDIR's mask for security label based on LSM state
    ath10k: Release some resources in an error handling path
    ath10k: Fix an error handling path
    ARM: dts: at91: at91sam9rl: fix ADC triggers
    PCI: iproc: Fix out-of-bound array accesses
  * genirq/irqdomain: Don't try to free an interrupt that has no mapping
      kernel/irq/irqdomain.c
    power: supply: bq24190_charger: fix reference leak
    ARM: dts: Remove non-existent i2c1 from 98dx3236
    HSI: omap_ssi: Don't jump to free ID in ssi_add_controller()
    media: max2175: fix max2175_set_csm_mode() error code
    mips: cdmm: fix use-after-free in mips_cdmm_bus_discover
    samples: bpf: Fix lwt_len_hist reusing previous BPF map
    media: siano: fix memory leak of debugfs members in smsdvb_hotplug
    cw1200: fix missing destroy_workqueue() on error in cw1200_init_common
    orinoco: Move context allocation after processing the skb
    ARM: dts: at91: sama5d3_xplained: add pincontrol for USB Host
    ARM: dts: at91: sama5d4_xplained: add pincontrol for USB Host
    memstick: fix a double-free bug in memstick_check
    RDMA/cxgb4: Validate the number of CQEs
    Input: omap4-keypad - fix runtime PM error handling
    drivers: soc: ti: knav_qmss_queue: Fix error return code in knav_queue_probe
    soc: ti: Fix reference imbalance in knav_dma_probe
    soc: ti: knav_qmss: fix reference leak in knav_queue_probe
    crypto: omap-aes - Fix PM disable depth imbalance in omap_aes_probe
  * powerpc/feature: Fix CPU_FTRS_ALWAYS by removing CPU_FTRS_GENERIC_32
      arch/powerpc/include/asm/cputable.h
    Input: ads7846 - fix unaligned access on 7845
    Input: ads7846 - fix integer overflow on Rt calculation
    Input: ads7846 - fix race that causes missing releases
    drm/omap: dmm_tiler: fix return error code in omap_dmm_probe()
    media: solo6x10: fix missing snd_card_free in error handling case
  * scsi: core: Fix VPD LUN ID designator priorities
      drivers/scsi/scsi_lib.c
    media: mtk-vcodec: add missing put_device() call in mtk_vcodec_release_dec_pm()
    staging: greybus: codecs: Fix reference counter leak in error handling
    MIPS: BCM47XX: fix kconfig dependency bug for BCM47XX_BCMA
    RDMa/mthca: Work around -Wenum-conversion warning
    ASoC: arizona: Fix a wrong free in wm8997_probe
    ASoC: wm8998: Fix PM disable depth imbalance on error
    mwifiex: fix mwifiex_shutdown_sw() causing sw reset failure
    spi: tegra114: fix reference leak in tegra spi ops
    spi: tegra20-sflash: fix reference leak in tegra_sflash_resume
    spi: tegra20-slink: fix reference leak in slink ops of tegra20
    spi: spi-ti-qspi: fix reference leak in ti_qspi_setup
  * Bluetooth: Fix null pointer dereference in hci_event_packet()
      net/bluetooth/hci_event.c
    arm64: dts: exynos: Correct psci compatible used on Exynos7
  * selinux: fix inode_doinit_with_dentry() LABEL_INVALID error handling
      security/selinux/hooks.c
  * ASoC: pcm: DRAIN support reactivation
      sound/soc/soc-pcm.c
    spi: img-spfi: fix reference leak in img_spfi_resume
    crypto: talitos - Fix return type of current_desc_hdr()
  * sched: Reenable interrupts in do_sched_yield()
      kernel/sched/core.c
  * sched/deadline: Fix sched_dl_global_validate()
      kernel/sched/deadline.c
      kernel/sched/sched.h
    ARM: p2v: fix handling of LPAE translation in BE mode
    x86/mm/ident_map: Check for errors from ident_pud_init()
    RDMA/rxe: Compute PSN windows correctly
  * selinux: fix error initialization in inode_doinit_with_dentry()
      security/selinux/hooks.c
    RDMA/bnxt_re: Set queue pair state when being queried
    soc: mediatek: Check if power domains can be powered on at boot time
    soc: renesas: rmobile-sysc: Fix some leaks in rmobile_init_pm_domains()
    drm/gma500: fix double free of gma_connector
  * Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt()
      net/bluetooth/hci_event.c
    md: fix a warning caused by a race between concurrent md_ioctl()s
  * crypto: af_alg - avoid undefined behavior accessing salg_name
      include/uapi/linux/if_alg.h
    media: msi2500: assign SPI bus number dynamically
  * quota: Sanity-check quota file headers on load
      fs/quota/quota_v2.c
  * serial_core: Check for port state when tty is in error state
      drivers/tty/serial/serial_core.c
    HID: i2c-hid: add Vero K147 to descriptor override
    ARM: dts: exynos: fix USB 3.0 pins supply being turned off on Odroid XU
    ARM: dts: exynos: fix USB 3.0 VBUS control and over-current pins on Exynos5410
    ARM: dts: exynos: fix roles of USB 3.0 ports on Odroid XU
    usb: chipidea: ci_hdrc_imx: Pass DISABLE_DEVICE_STREAMING flag to imx6ul
    USB: gadget: f_rndis: fix bitrate for SuperSpeed and above
  * usb: gadget: f_fs: Re-use SS descriptors for SuperSpeedPlus
      drivers/usb/gadget/function/f_fs.c
  * USB: gadget: f_midi: setup SuperSpeed Plus descriptors
      drivers/usb/gadget/function/f_midi.c
    USB: gadget: f_acm: add support for SuperSpeed Plus
    USB: serial: option: add interface-number sanity check to flag handling
    soc/tegra: fuse: Fix index bug in get_process_id
  * dm table: Remove BUG_ON(in_interrupt())
      drivers/md/dm-table.c
    scsi: mpt3sas: Increase IOCInit request timeout to 30s
    vxlan: Copy needed_tailroom from lowerdev
    vxlan: Add needed_headroom for lower device
    drm/tegra: sor: Disable clocks on error in tegra_sor_init()
  * kernel/cpu: add arch override for clear_tasks_mm_cpumask() mm handling
      kernel/cpu.c
    RDMA/cm: Fix an attempt to use non-valid pointer when cleaning timewait
    can: softing: softing_netdev_open(): fix error handling
  * scsi: bnx2i: Requires MMU
      drivers/scsi/bnx2i/Kconfig
    gpio: mvebu: fix potential user-after-free on probe
    ARM: dts: sun8i: v3s: fix GIC node memory range
    pinctrl: baytrail: Avoid clearing debounce value when turning it off
    pinctrl: merrifield: Set default bias in case no particular value given
  * drm: fix drm_dp_mst_port refcount leaks in drm_dp_mst_allocate_vcpi
      drivers/gpu/drm/drm_dp_mst_topology.c
    serial: 8250_omap: Avoid FIFO corruption caused by MDR1 access
    ALSA: pcm: oss: Fix potential out-of-bounds shift
  * USB: sisusbvga: Make console support depend on BROKEN
      drivers/usb/misc/sisusbvga/Kconfig
  * USB: UAS: introduce a quirk to set no_write_same
      drivers/usb/storage/usb.c
      include/linux/usb_usual.h
  * xhci: Give USB2 ports time to enter U3 in bus suspend
      drivers/usb/host/xhci-hub.c
  * ALSA: usb-audio: Fix control 'access overflow' errors from chmap
      sound/usb/stream.c
  * ALSA: usb-audio: Fix potential out-of-bounds shift
      sound/usb/format.c
  * USB: add RESET_RESUME quirk for Snapscan 1212
      drivers/usb/core/quirks.c
    USB: dummy-hcd: Fix uninitialized array use in init()
    mac80211: mesh: fix mesh_pathtbl_init() error path
    net: bridge: vlan: fix error return code in __vlan_add()
    net: stmmac: dwmac-meson8b: fix mask definition of the m250_sel mux
    net: stmmac: delete the eee_ctrl_timer after napi disabled
    net/mlx4_en: Handle TX error CQE
    net/mlx4_en: Avoid scheduling restart task if it is already running
  * tcp: fix cwnd-limited bug for TSO deferral where we send nothing
      net/ipv4/tcp_output.c
    net: stmmac: free tx skb buffer in stmmac_resume()
    PCI: qcom: Add missing reset for ipq806x
  * x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP
      arch/x86/include/asm/pgtable_types.h
    scsi: be2iscsi: Revert "Fix a theoretical leak in beiscsi_create_eqs()"
  * kbuild: avoid static_assert for genksyms
      include/linux/build_bug.h
    pinctrl: amd: remove debounce filter setting in IRQ type setting
    Input: i8042 - add Acer laptops to the i8042 reset list
    Input: cm109 - do not stomp on control URB
    platform/x86: acer-wmi: add automatic keyboard background light toggle key as KEY_LIGHTS_TOGGLE
    soc: fsl: dpio: Get the cpumask through cpumask_of(cpu)
  * scsi: ufs: Make sure clk scaling happens only when HBA is runtime ACTIVE
      drivers/scsi/ufs/ufshcd.c
    ARC: stack unwinding: don't assume non-current task is sleeping
    iwlwifi: mvm: fix kernel panic in case of assert during CSA
    arm64: dts: rockchip: Assign a fixed index to mmc devices on rk3399 boards.
    iwlwifi: pcie: limit memory read spin time
    spi: bcm2835aux: Restore err assignment in bcm2835aux_spi_probe
    spi: bcm2835aux: Fix use-after-free on unbind

Bug: 180663378
Change-Id: Idee3af71ad1ba834e9d8ee29090386017d40028e
Signed-off-by: Lucas Wei <lucaswei@google.com>
2021-02-26 11:17:11 +08:00
Greg Kroah-Hartman
e6fa4f96ca Merge 4.14.213 into android-4.14-q
Changes in 4.14.213
	spi: bcm2835aux: Fix use-after-free on unbind
	spi: bcm2835aux: Restore err assignment in bcm2835aux_spi_probe
	iwlwifi: pcie: limit memory read spin time
	arm64: dts: rockchip: Assign a fixed index to mmc devices on rk3399 boards.
	iwlwifi: mvm: fix kernel panic in case of assert during CSA
	ARC: stack unwinding: don't assume non-current task is sleeping
	scsi: ufs: Make sure clk scaling happens only when HBA is runtime ACTIVE
	soc: fsl: dpio: Get the cpumask through cpumask_of(cpu)
	platform/x86: acer-wmi: add automatic keyboard background light toggle key as KEY_LIGHTS_TOGGLE
	Input: cm109 - do not stomp on control URB
	Input: i8042 - add Acer laptops to the i8042 reset list
	pinctrl: amd: remove debounce filter setting in IRQ type setting
	kbuild: avoid static_assert for genksyms
	scsi: be2iscsi: Revert "Fix a theoretical leak in beiscsi_create_eqs()"
	x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP
	PCI: qcom: Add missing reset for ipq806x
	net: stmmac: free tx skb buffer in stmmac_resume()
	tcp: fix cwnd-limited bug for TSO deferral where we send nothing
	net/mlx4_en: Avoid scheduling restart task if it is already running
	net/mlx4_en: Handle TX error CQE
	net: stmmac: delete the eee_ctrl_timer after napi disabled
	net: stmmac: dwmac-meson8b: fix mask definition of the m250_sel mux
	net: bridge: vlan: fix error return code in __vlan_add()
	mac80211: mesh: fix mesh_pathtbl_init() error path
	USB: dummy-hcd: Fix uninitialized array use in init()
	USB: add RESET_RESUME quirk for Snapscan 1212
	ALSA: usb-audio: Fix potential out-of-bounds shift
	ALSA: usb-audio: Fix control 'access overflow' errors from chmap
	xhci: Give USB2 ports time to enter U3 in bus suspend
	USB: UAS: introduce a quirk to set no_write_same
	USB: sisusbvga: Make console support depend on BROKEN
	ALSA: pcm: oss: Fix potential out-of-bounds shift
	serial: 8250_omap: Avoid FIFO corruption caused by MDR1 access
	drm: fix drm_dp_mst_port refcount leaks in drm_dp_mst_allocate_vcpi
	pinctrl: merrifield: Set default bias in case no particular value given
	pinctrl: baytrail: Avoid clearing debounce value when turning it off
	ARM: dts: sun8i: v3s: fix GIC node memory range
	gpio: mvebu: fix potential user-after-free on probe
	scsi: bnx2i: Requires MMU
	can: softing: softing_netdev_open(): fix error handling
	RDMA/cm: Fix an attempt to use non-valid pointer when cleaning timewait
	kernel/cpu: add arch override for clear_tasks_mm_cpumask() mm handling
	drm/tegra: sor: Disable clocks on error in tegra_sor_init()
	vxlan: Add needed_headroom for lower device
	vxlan: Copy needed_tailroom from lowerdev
	scsi: mpt3sas: Increase IOCInit request timeout to 30s
	dm table: Remove BUG_ON(in_interrupt())
	soc/tegra: fuse: Fix index bug in get_process_id
	USB: serial: option: add interface-number sanity check to flag handling
	USB: gadget: f_acm: add support for SuperSpeed Plus
	USB: gadget: f_midi: setup SuperSpeed Plus descriptors
	usb: gadget: f_fs: Re-use SS descriptors for SuperSpeedPlus
	USB: gadget: f_rndis: fix bitrate for SuperSpeed and above
	usb: chipidea: ci_hdrc_imx: Pass DISABLE_DEVICE_STREAMING flag to imx6ul
	ARM: dts: exynos: fix roles of USB 3.0 ports on Odroid XU
	ARM: dts: exynos: fix USB 3.0 VBUS control and over-current pins on Exynos5410
	ARM: dts: exynos: fix USB 3.0 pins supply being turned off on Odroid XU
	HID: i2c-hid: add Vero K147 to descriptor override
	serial_core: Check for port state when tty is in error state
	quota: Sanity-check quota file headers on load
	media: msi2500: assign SPI bus number dynamically
	crypto: af_alg - avoid undefined behavior accessing salg_name
	md: fix a warning caused by a race between concurrent md_ioctl()s
	Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt()
	drm/gma500: fix double free of gma_connector
	soc: renesas: rmobile-sysc: Fix some leaks in rmobile_init_pm_domains()
	soc: mediatek: Check if power domains can be powered on at boot time
	RDMA/bnxt_re: Set queue pair state when being queried
	selinux: fix error initialization in inode_doinit_with_dentry()
	RDMA/rxe: Compute PSN windows correctly
	x86/mm/ident_map: Check for errors from ident_pud_init()
	ARM: p2v: fix handling of LPAE translation in BE mode
	sched/deadline: Fix sched_dl_global_validate()
	sched: Reenable interrupts in do_sched_yield()
	crypto: talitos - Fix return type of current_desc_hdr()
	spi: img-spfi: fix reference leak in img_spfi_resume
	ASoC: pcm: DRAIN support reactivation
	selinux: fix inode_doinit_with_dentry() LABEL_INVALID error handling
	arm64: dts: exynos: Correct psci compatible used on Exynos7
	Bluetooth: Fix null pointer dereference in hci_event_packet()
	spi: spi-ti-qspi: fix reference leak in ti_qspi_setup
	spi: tegra20-slink: fix reference leak in slink ops of tegra20
	spi: tegra20-sflash: fix reference leak in tegra_sflash_resume
	spi: tegra114: fix reference leak in tegra spi ops
	mwifiex: fix mwifiex_shutdown_sw() causing sw reset failure
	ASoC: wm8998: Fix PM disable depth imbalance on error
	ASoC: arizona: Fix a wrong free in wm8997_probe
	RDMa/mthca: Work around -Wenum-conversion warning
	MIPS: BCM47XX: fix kconfig dependency bug for BCM47XX_BCMA
	staging: greybus: codecs: Fix reference counter leak in error handling
	media: mtk-vcodec: add missing put_device() call in mtk_vcodec_release_dec_pm()
	scsi: core: Fix VPD LUN ID designator priorities
	media: solo6x10: fix missing snd_card_free in error handling case
	drm/omap: dmm_tiler: fix return error code in omap_dmm_probe()
	Input: ads7846 - fix race that causes missing releases
	Input: ads7846 - fix integer overflow on Rt calculation
	Input: ads7846 - fix unaligned access on 7845
	powerpc/feature: Fix CPU_FTRS_ALWAYS by removing CPU_FTRS_GENERIC_32
	crypto: omap-aes - Fix PM disable depth imbalance in omap_aes_probe
	soc: ti: knav_qmss: fix reference leak in knav_queue_probe
	soc: ti: Fix reference imbalance in knav_dma_probe
	drivers: soc: ti: knav_qmss_queue: Fix error return code in knav_queue_probe
	Input: omap4-keypad - fix runtime PM error handling
	RDMA/cxgb4: Validate the number of CQEs
	memstick: fix a double-free bug in memstick_check
	ARM: dts: at91: sama5d4_xplained: add pincontrol for USB Host
	ARM: dts: at91: sama5d3_xplained: add pincontrol for USB Host
	orinoco: Move context allocation after processing the skb
	cw1200: fix missing destroy_workqueue() on error in cw1200_init_common
	media: siano: fix memory leak of debugfs members in smsdvb_hotplug
	samples: bpf: Fix lwt_len_hist reusing previous BPF map
	mips: cdmm: fix use-after-free in mips_cdmm_bus_discover
	media: max2175: fix max2175_set_csm_mode() error code
	HSI: omap_ssi: Don't jump to free ID in ssi_add_controller()
	ARM: dts: Remove non-existent i2c1 from 98dx3236
	power: supply: bq24190_charger: fix reference leak
	genirq/irqdomain: Don't try to free an interrupt that has no mapping
	PCI: iproc: Fix out-of-bound array accesses
	ARM: dts: at91: at91sam9rl: fix ADC triggers
	ath10k: Fix an error handling path
	ath10k: Release some resources in an error handling path
	NFSv4.2: condition READDIR's mask for security label based on LSM state
	SUNRPC: xprt_load_transport() needs to support the netid "rdma6"
	lockd: don't use interval-based rebinding over TCP
	NFS: switch nfsiod to be an UNBOUND workqueue.
	vfio-pci: Use io_remap_pfn_range() for PCI IO memory
	media: saa7146: fix array overflow in vidioc_s_audio()
	clocksource/drivers/cadence_ttc: Fix memory leak in ttc_setup_clockevent()
	ARM: dts: at91: sama5d2: map securam as device
	pinctrl: falcon: add missing put_device() call in pinctrl_falcon_probe()
	arm64: dts: rockchip: Fix UART pull-ups on rk3328
	memstick: r592: Fix error return in r592_probe()
	net/mlx5: Properly convey driver version to firmware
	ASoC: jz4740-i2s: add missed checks for clk_get()
	dm ioctl: fix error return code in target_message
	clocksource/drivers/arm_arch_timer: Correct fault programming of CNTKCTL_EL1.EVNTI
	cpufreq: highbank: Add missing MODULE_DEVICE_TABLE
	cpufreq: mediatek: Add missing MODULE_DEVICE_TABLE
	cpufreq: st: Add missing MODULE_DEVICE_TABLE
	cpufreq: loongson1: Add missing MODULE_ALIAS
	cpufreq: scpi: Add missing MODULE_ALIAS
	scsi: qedi: Fix missing destroy_workqueue() on error in __qedi_probe
	scsi: pm80xx: Fix error return in pm8001_pci_probe()
	seq_buf: Avoid type mismatch for seq_buf_init
	scsi: fnic: Fix error return code in fnic_probe()
	powerpc/pseries/hibernation: drop pseries_suspend_begin() from suspend ops
	powerpc/pseries/hibernation: remove redundant cacheinfo update
	usb: ehci-omap: Fix PM disable depth umbalance in ehci_hcd_omap_probe
	usb: oxu210hp-hcd: Fix memory leak in oxu_create
	speakup: fix uninitialized flush_lock
	nfsd: Fix message level for normal termination
	nfs_common: need lock during iterate through the list
	x86/kprobes: Restore BTF if the single-stepping is cancelled
	clk: tegra: Fix duplicated SE clock entry
	extcon: max77693: Fix modalias string
	ASoC: wm_adsp: remove "ctl" from list on error in wm_adsp_create_control()
	irqchip/alpine-msi: Fix freeing of interrupts on allocation error path
	watchdog: sirfsoc: Add missing dependency on HAS_IOMEM
	um: chan_xterm: Fix fd leak
	nfc: s3fwrn5: Release the nfc firmware
	powerpc/ps3: use dma_mapping_error()
	checkpatch: fix unescaped left brace
	net: bcmgenet: Fix a resource leak in an error handling path in the probe functin
	net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function
	net: korina: fix return value
	watchdog: qcom: Avoid context switch in restart handler
	watchdog: coh901327: add COMMON_CLK dependency
	clk: ti: Fix memleak in ti_fapll_synth_setup
	pwm: zx: Add missing cleanup in error path
	pwm: lp3943: Dynamically allocate PWM chip base
	perf record: Fix memory leak when using '--user-regs=?' to list registers
	qlcnic: Fix error code in probe
	clk: s2mps11: Fix a resource leak in error handling paths in the probe function
	clk: sunxi-ng: Make sure divider tables have sentinel
	cfg80211: initialize rekey_data
	fix namespaced fscaps when !CONFIG_SECURITY
	Input: cros_ec_keyb - send 'scancodes' in addition to key events
	Input: goodix - add upside-down quirk for Teclast X98 Pro tablet
	media: gspca: Fix memory leak in probe
	media: sunxi-cir: ensure IR is handled when it is continuous
	media: netup_unidvb: Don't leak SPI master in probe error path
	Input: cyapa_gen6 - fix out-of-bounds stack access
	PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup()
	Revert "ACPI / resources: Use AE_CTRL_TERMINATE to terminate resources walks"
	ACPI: PNP: compare the string length in the matching_id()
	ALSA: hda/realtek - Enable headset mic of ASUS Q524UQK with ALC255
	ALSA: pcm: oss: Fix a few more UBSAN fixes
	ALSA: usb-audio: Disable sample read check if firmware doesn't give back
	s390/smp: perform initial CPU reset also for SMT siblings
	s390/dasd: prevent inconsistent LCU device data
	s390/dasd: fix list corruption of pavgroup group list
	s390/dasd: fix list corruption of lcu list
	staging: comedi: mf6x4: Fix AI end-of-conversion detection
	powerpc/perf: Exclude kernel samples while counting events in user space.
	crypto: ecdh - avoid unaligned accesses in ecdh_set_secret()
	EDAC/amd64: Fix PCI component registration
	USB: serial: mos7720: fix parallel-port state restore
	USB: serial: keyspan_pda: fix dropped unthrottle interrupts
	USB: serial: keyspan_pda: fix write deadlock
	USB: serial: keyspan_pda: fix stalled writes
	USB: serial: keyspan_pda: fix write-wakeup use-after-free
	USB: serial: keyspan_pda: fix tx-unthrottle use-after-free
	USB: serial: keyspan_pda: fix write unthrottling
	Btrfs: fix selftests failure due to uninitialized i_mode in test inodes
	btrfs: fix return value mixup in btrfs_get_extent
	ext4: fix a memory leak of ext4_free_data
	ext4: fix deadlock with fs freezing and EA inodes
	KVM: arm64: Introduce handling of AArch32 TTBCR2 traps
	ARM: dts: at91: sama5d2: fix CAN message ram offset and size
	powerpc/rtas: Fix typo of ibm,open-errinjct in RTAS filter
	powerpc/xmon: Change printk() to pr_cont()
	powerpc/powernv/memtrace: Don't leak kernel memory to user space
	ima: Don't modify file descriptor mode on the fly
	ceph: fix race in concurrent __ceph_remove_cap invocations
	jffs2: Fix GC exit abnormally
	jfs: Fix array index bounds check in dbAdjTree
	drm/dp_aux_dev: check aux_dev before use in drm_dp_aux_dev_get_by_minor()
	spi: spi-sh: Fix use-after-free on unbind
	spi: davinci: Fix use-after-free on unbind
	spi: pic32: Don't leak DMA channels in probe error path
	spi: rb4xx: Don't leak SPI master in probe error path
	spi: sc18is602: Don't leak SPI master in probe error path
	spi: st-ssc4: Fix unbalanced pm_runtime_disable() in probe error path
	soc: qcom: smp2p: Safely acquire spinlock without IRQs
	mtd: parser: cmdline: Fix parsing of part-names with colons
	iio: buffer: Fix demux update
	iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume
	iio:light:rpr0521: Fix timestamp alignment and prevent data leak.
	iio:pressure:mpl3115: Force alignment of buffer
	iio:imu:bmi160: Fix too large a buffer.
	md/cluster: fix deadlock when node is doing resync job
	clk: mvebu: a3700: fix the XTAL MODE pin to MPP1_9
	xen-blkback: set ring->xenblkd to NULL after kthread_stop()
	xen/xenbus: Allow watches discard events before queueing
	xen/xenbus: Add 'will_handle' callback support in xenbus_watch_path()
	xen/xenbus/xen_bus_type: Support will_handle watch callback
	xen/xenbus: Count pending messages for each watch
	xenbus/xenbus_backend: Disallow pending watch messages
	libnvdimm/namespace: Fix reaping of invalidated block-window-namespace labels
	PCI: Fix pci_slot_release() NULL pointer dereference
	Linux 4.14.213

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I53f9bcc2f4e19857f9709d3a3658ca2bc68eef82
2020-12-29 14:19:27 +01:00
Greg Kroah-Hartman
89616f108f Merge 4.14.213 into android-4.14-stable
Changes in 4.14.213
	spi: bcm2835aux: Fix use-after-free on unbind
	spi: bcm2835aux: Restore err assignment in bcm2835aux_spi_probe
	iwlwifi: pcie: limit memory read spin time
	arm64: dts: rockchip: Assign a fixed index to mmc devices on rk3399 boards.
	iwlwifi: mvm: fix kernel panic in case of assert during CSA
	ARC: stack unwinding: don't assume non-current task is sleeping
	scsi: ufs: Make sure clk scaling happens only when HBA is runtime ACTIVE
	soc: fsl: dpio: Get the cpumask through cpumask_of(cpu)
	platform/x86: acer-wmi: add automatic keyboard background light toggle key as KEY_LIGHTS_TOGGLE
	Input: cm109 - do not stomp on control URB
	Input: i8042 - add Acer laptops to the i8042 reset list
	pinctrl: amd: remove debounce filter setting in IRQ type setting
	kbuild: avoid static_assert for genksyms
	scsi: be2iscsi: Revert "Fix a theoretical leak in beiscsi_create_eqs()"
	x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP
	PCI: qcom: Add missing reset for ipq806x
	net: stmmac: free tx skb buffer in stmmac_resume()
	tcp: fix cwnd-limited bug for TSO deferral where we send nothing
	net/mlx4_en: Avoid scheduling restart task if it is already running
	net/mlx4_en: Handle TX error CQE
	net: stmmac: delete the eee_ctrl_timer after napi disabled
	net: stmmac: dwmac-meson8b: fix mask definition of the m250_sel mux
	net: bridge: vlan: fix error return code in __vlan_add()
	mac80211: mesh: fix mesh_pathtbl_init() error path
	USB: dummy-hcd: Fix uninitialized array use in init()
	USB: add RESET_RESUME quirk for Snapscan 1212
	ALSA: usb-audio: Fix potential out-of-bounds shift
	ALSA: usb-audio: Fix control 'access overflow' errors from chmap
	xhci: Give USB2 ports time to enter U3 in bus suspend
	USB: UAS: introduce a quirk to set no_write_same
	USB: sisusbvga: Make console support depend on BROKEN
	ALSA: pcm: oss: Fix potential out-of-bounds shift
	serial: 8250_omap: Avoid FIFO corruption caused by MDR1 access
	drm: fix drm_dp_mst_port refcount leaks in drm_dp_mst_allocate_vcpi
	pinctrl: merrifield: Set default bias in case no particular value given
	pinctrl: baytrail: Avoid clearing debounce value when turning it off
	ARM: dts: sun8i: v3s: fix GIC node memory range
	gpio: mvebu: fix potential user-after-free on probe
	scsi: bnx2i: Requires MMU
	can: softing: softing_netdev_open(): fix error handling
	RDMA/cm: Fix an attempt to use non-valid pointer when cleaning timewait
	kernel/cpu: add arch override for clear_tasks_mm_cpumask() mm handling
	drm/tegra: sor: Disable clocks on error in tegra_sor_init()
	vxlan: Add needed_headroom for lower device
	vxlan: Copy needed_tailroom from lowerdev
	scsi: mpt3sas: Increase IOCInit request timeout to 30s
	dm table: Remove BUG_ON(in_interrupt())
	soc/tegra: fuse: Fix index bug in get_process_id
	USB: serial: option: add interface-number sanity check to flag handling
	USB: gadget: f_acm: add support for SuperSpeed Plus
	USB: gadget: f_midi: setup SuperSpeed Plus descriptors
	usb: gadget: f_fs: Re-use SS descriptors for SuperSpeedPlus
	USB: gadget: f_rndis: fix bitrate for SuperSpeed and above
	usb: chipidea: ci_hdrc_imx: Pass DISABLE_DEVICE_STREAMING flag to imx6ul
	ARM: dts: exynos: fix roles of USB 3.0 ports on Odroid XU
	ARM: dts: exynos: fix USB 3.0 VBUS control and over-current pins on Exynos5410
	ARM: dts: exynos: fix USB 3.0 pins supply being turned off on Odroid XU
	HID: i2c-hid: add Vero K147 to descriptor override
	serial_core: Check for port state when tty is in error state
	quota: Sanity-check quota file headers on load
	media: msi2500: assign SPI bus number dynamically
	crypto: af_alg - avoid undefined behavior accessing salg_name
	md: fix a warning caused by a race between concurrent md_ioctl()s
	Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt()
	drm/gma500: fix double free of gma_connector
	soc: renesas: rmobile-sysc: Fix some leaks in rmobile_init_pm_domains()
	soc: mediatek: Check if power domains can be powered on at boot time
	RDMA/bnxt_re: Set queue pair state when being queried
	selinux: fix error initialization in inode_doinit_with_dentry()
	RDMA/rxe: Compute PSN windows correctly
	x86/mm/ident_map: Check for errors from ident_pud_init()
	ARM: p2v: fix handling of LPAE translation in BE mode
	sched/deadline: Fix sched_dl_global_validate()
	sched: Reenable interrupts in do_sched_yield()
	crypto: talitos - Fix return type of current_desc_hdr()
	spi: img-spfi: fix reference leak in img_spfi_resume
	ASoC: pcm: DRAIN support reactivation
	selinux: fix inode_doinit_with_dentry() LABEL_INVALID error handling
	arm64: dts: exynos: Correct psci compatible used on Exynos7
	Bluetooth: Fix null pointer dereference in hci_event_packet()
	spi: spi-ti-qspi: fix reference leak in ti_qspi_setup
	spi: tegra20-slink: fix reference leak in slink ops of tegra20
	spi: tegra20-sflash: fix reference leak in tegra_sflash_resume
	spi: tegra114: fix reference leak in tegra spi ops
	mwifiex: fix mwifiex_shutdown_sw() causing sw reset failure
	ASoC: wm8998: Fix PM disable depth imbalance on error
	ASoC: arizona: Fix a wrong free in wm8997_probe
	RDMa/mthca: Work around -Wenum-conversion warning
	MIPS: BCM47XX: fix kconfig dependency bug for BCM47XX_BCMA
	staging: greybus: codecs: Fix reference counter leak in error handling
	media: mtk-vcodec: add missing put_device() call in mtk_vcodec_release_dec_pm()
	scsi: core: Fix VPD LUN ID designator priorities
	media: solo6x10: fix missing snd_card_free in error handling case
	drm/omap: dmm_tiler: fix return error code in omap_dmm_probe()
	Input: ads7846 - fix race that causes missing releases
	Input: ads7846 - fix integer overflow on Rt calculation
	Input: ads7846 - fix unaligned access on 7845
	powerpc/feature: Fix CPU_FTRS_ALWAYS by removing CPU_FTRS_GENERIC_32
	crypto: omap-aes - Fix PM disable depth imbalance in omap_aes_probe
	soc: ti: knav_qmss: fix reference leak in knav_queue_probe
	soc: ti: Fix reference imbalance in knav_dma_probe
	drivers: soc: ti: knav_qmss_queue: Fix error return code in knav_queue_probe
	Input: omap4-keypad - fix runtime PM error handling
	RDMA/cxgb4: Validate the number of CQEs
	memstick: fix a double-free bug in memstick_check
	ARM: dts: at91: sama5d4_xplained: add pincontrol for USB Host
	ARM: dts: at91: sama5d3_xplained: add pincontrol for USB Host
	orinoco: Move context allocation after processing the skb
	cw1200: fix missing destroy_workqueue() on error in cw1200_init_common
	media: siano: fix memory leak of debugfs members in smsdvb_hotplug
	samples: bpf: Fix lwt_len_hist reusing previous BPF map
	mips: cdmm: fix use-after-free in mips_cdmm_bus_discover
	media: max2175: fix max2175_set_csm_mode() error code
	HSI: omap_ssi: Don't jump to free ID in ssi_add_controller()
	ARM: dts: Remove non-existent i2c1 from 98dx3236
	power: supply: bq24190_charger: fix reference leak
	genirq/irqdomain: Don't try to free an interrupt that has no mapping
	PCI: iproc: Fix out-of-bound array accesses
	ARM: dts: at91: at91sam9rl: fix ADC triggers
	ath10k: Fix an error handling path
	ath10k: Release some resources in an error handling path
	NFSv4.2: condition READDIR's mask for security label based on LSM state
	SUNRPC: xprt_load_transport() needs to support the netid "rdma6"
	lockd: don't use interval-based rebinding over TCP
	NFS: switch nfsiod to be an UNBOUND workqueue.
	vfio-pci: Use io_remap_pfn_range() for PCI IO memory
	media: saa7146: fix array overflow in vidioc_s_audio()
	clocksource/drivers/cadence_ttc: Fix memory leak in ttc_setup_clockevent()
	ARM: dts: at91: sama5d2: map securam as device
	pinctrl: falcon: add missing put_device() call in pinctrl_falcon_probe()
	arm64: dts: rockchip: Fix UART pull-ups on rk3328
	memstick: r592: Fix error return in r592_probe()
	net/mlx5: Properly convey driver version to firmware
	ASoC: jz4740-i2s: add missed checks for clk_get()
	dm ioctl: fix error return code in target_message
	clocksource/drivers/arm_arch_timer: Correct fault programming of CNTKCTL_EL1.EVNTI
	cpufreq: highbank: Add missing MODULE_DEVICE_TABLE
	cpufreq: mediatek: Add missing MODULE_DEVICE_TABLE
	cpufreq: st: Add missing MODULE_DEVICE_TABLE
	cpufreq: loongson1: Add missing MODULE_ALIAS
	cpufreq: scpi: Add missing MODULE_ALIAS
	scsi: qedi: Fix missing destroy_workqueue() on error in __qedi_probe
	scsi: pm80xx: Fix error return in pm8001_pci_probe()
	seq_buf: Avoid type mismatch for seq_buf_init
	scsi: fnic: Fix error return code in fnic_probe()
	powerpc/pseries/hibernation: drop pseries_suspend_begin() from suspend ops
	powerpc/pseries/hibernation: remove redundant cacheinfo update
	usb: ehci-omap: Fix PM disable depth umbalance in ehci_hcd_omap_probe
	usb: oxu210hp-hcd: Fix memory leak in oxu_create
	speakup: fix uninitialized flush_lock
	nfsd: Fix message level for normal termination
	nfs_common: need lock during iterate through the list
	x86/kprobes: Restore BTF if the single-stepping is cancelled
	clk: tegra: Fix duplicated SE clock entry
	extcon: max77693: Fix modalias string
	ASoC: wm_adsp: remove "ctl" from list on error in wm_adsp_create_control()
	irqchip/alpine-msi: Fix freeing of interrupts on allocation error path
	watchdog: sirfsoc: Add missing dependency on HAS_IOMEM
	um: chan_xterm: Fix fd leak
	nfc: s3fwrn5: Release the nfc firmware
	powerpc/ps3: use dma_mapping_error()
	checkpatch: fix unescaped left brace
	net: bcmgenet: Fix a resource leak in an error handling path in the probe functin
	net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function
	net: korina: fix return value
	watchdog: qcom: Avoid context switch in restart handler
	watchdog: coh901327: add COMMON_CLK dependency
	clk: ti: Fix memleak in ti_fapll_synth_setup
	pwm: zx: Add missing cleanup in error path
	pwm: lp3943: Dynamically allocate PWM chip base
	perf record: Fix memory leak when using '--user-regs=?' to list registers
	qlcnic: Fix error code in probe
	clk: s2mps11: Fix a resource leak in error handling paths in the probe function
	clk: sunxi-ng: Make sure divider tables have sentinel
	cfg80211: initialize rekey_data
	fix namespaced fscaps when !CONFIG_SECURITY
	Input: cros_ec_keyb - send 'scancodes' in addition to key events
	Input: goodix - add upside-down quirk for Teclast X98 Pro tablet
	media: gspca: Fix memory leak in probe
	media: sunxi-cir: ensure IR is handled when it is continuous
	media: netup_unidvb: Don't leak SPI master in probe error path
	Input: cyapa_gen6 - fix out-of-bounds stack access
	PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup()
	Revert "ACPI / resources: Use AE_CTRL_TERMINATE to terminate resources walks"
	ACPI: PNP: compare the string length in the matching_id()
	ALSA: hda/realtek - Enable headset mic of ASUS Q524UQK with ALC255
	ALSA: pcm: oss: Fix a few more UBSAN fixes
	ALSA: usb-audio: Disable sample read check if firmware doesn't give back
	s390/smp: perform initial CPU reset also for SMT siblings
	s390/dasd: prevent inconsistent LCU device data
	s390/dasd: fix list corruption of pavgroup group list
	s390/dasd: fix list corruption of lcu list
	staging: comedi: mf6x4: Fix AI end-of-conversion detection
	powerpc/perf: Exclude kernel samples while counting events in user space.
	crypto: ecdh - avoid unaligned accesses in ecdh_set_secret()
	EDAC/amd64: Fix PCI component registration
	USB: serial: mos7720: fix parallel-port state restore
	USB: serial: keyspan_pda: fix dropped unthrottle interrupts
	USB: serial: keyspan_pda: fix write deadlock
	USB: serial: keyspan_pda: fix stalled writes
	USB: serial: keyspan_pda: fix write-wakeup use-after-free
	USB: serial: keyspan_pda: fix tx-unthrottle use-after-free
	USB: serial: keyspan_pda: fix write unthrottling
	Btrfs: fix selftests failure due to uninitialized i_mode in test inodes
	btrfs: fix return value mixup in btrfs_get_extent
	ext4: fix a memory leak of ext4_free_data
	ext4: fix deadlock with fs freezing and EA inodes
	KVM: arm64: Introduce handling of AArch32 TTBCR2 traps
	ARM: dts: at91: sama5d2: fix CAN message ram offset and size
	powerpc/rtas: Fix typo of ibm,open-errinjct in RTAS filter
	powerpc/xmon: Change printk() to pr_cont()
	powerpc/powernv/memtrace: Don't leak kernel memory to user space
	ima: Don't modify file descriptor mode on the fly
	ceph: fix race in concurrent __ceph_remove_cap invocations
	jffs2: Fix GC exit abnormally
	jfs: Fix array index bounds check in dbAdjTree
	drm/dp_aux_dev: check aux_dev before use in drm_dp_aux_dev_get_by_minor()
	spi: spi-sh: Fix use-after-free on unbind
	spi: davinci: Fix use-after-free on unbind
	spi: pic32: Don't leak DMA channels in probe error path
	spi: rb4xx: Don't leak SPI master in probe error path
	spi: sc18is602: Don't leak SPI master in probe error path
	spi: st-ssc4: Fix unbalanced pm_runtime_disable() in probe error path
	soc: qcom: smp2p: Safely acquire spinlock without IRQs
	mtd: parser: cmdline: Fix parsing of part-names with colons
	iio: buffer: Fix demux update
	iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume
	iio:light:rpr0521: Fix timestamp alignment and prevent data leak.
	iio:pressure:mpl3115: Force alignment of buffer
	iio:imu:bmi160: Fix too large a buffer.
	md/cluster: fix deadlock when node is doing resync job
	clk: mvebu: a3700: fix the XTAL MODE pin to MPP1_9
	xen-blkback: set ring->xenblkd to NULL after kthread_stop()
	xen/xenbus: Allow watches discard events before queueing
	xen/xenbus: Add 'will_handle' callback support in xenbus_watch_path()
	xen/xenbus/xen_bus_type: Support will_handle watch callback
	xen/xenbus: Count pending messages for each watch
	xenbus/xenbus_backend: Disallow pending watch messages
	libnvdimm/namespace: Fix reaping of invalidated block-window-namespace labels
	PCI: Fix pci_slot_release() NULL pointer dereference
	Linux 4.14.213

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ic39f6cbb08d6b12ddb9f5372eb14ff80f2bff04e
2020-12-29 14:17:49 +01:00
Serge Hallyn
e7f7033799 fix namespaced fscaps when !CONFIG_SECURITY
[ Upstream commit ed9b25d1970a4787ac6a39c2091e63b127ecbfc1 ]

Namespaced file capabilities were introduced in 8db6c34f1d .
When userspace reads an xattr for a namespaced capability, a
virtualized representation of it is returned if the caller is
in a user namespace owned by the capability's owning rootid.
The function which performs this virtualization was not hooked
up if CONFIG_SECURITY=n.  Therefore in that case the original
xattr was shown instead of the virtualized one.

To test this using libcap-bin (*1),

$ v=$(mktemp)
$ unshare -Ur setcap cap_sys_admin-eip $v
$ unshare -Ur setcap -v cap_sys_admin-eip $v
/tmp/tmp.lSiIFRvt8Y: OK

"setcap -v" verifies the values instead of setting them, and
will check whether the rootid value is set.  Therefore, with
this bug un-fixed, and with CONFIG_SECURITY=n, setcap -v will
fail:

$ v=$(mktemp)
$ unshare -Ur setcap cap_sys_admin=eip $v
$ unshare -Ur setcap -v cap_sys_admin=eip $v
nsowner[got=1000, want=0],/tmp/tmp.HHDiOOl9fY differs in []

Fix this bug by calling cap_inode_getsecurity() in
security_inode_getsecurity() instead of returning
-EOPNOTSUPP, when CONFIG_SECURITY=n.

*1 - note, if libcap is too old for getcap to have the '-n'
option, then use verify-caps instead.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=209689
Cc: Hervé Guillemet <herve@guillemet.org>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Serge Hallyn <shallyn@cisco.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Signed-off-by: James Morris <jamorris@linux.microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-12-29 13:47:04 +01:00
Joel Fernandes (Google)
0160b1739d BACKPORT: perf_event: Add support for LSM and SELinux checks
In current mainline, the degree of access to perf_event_open(2) system
call depends on the perf_event_paranoid sysctl.  This has a number of
limitations:

1. The sysctl is only a single value. Many types of accesses are controlled
   based on the single value thus making the control very limited and
   coarse grained.
2. The sysctl is global, so if the sysctl is changed, then that means
   all processes get access to perf_event_open(2) opening the door to
   security issues.

This patch adds LSM and SELinux access checking which will be used in
Android to access perf_event_open(2) for the purposes of attaching BPF
programs to tracepoints, perf profiling and other operations from
userspace. These operations are intended for production systems.

5 new LSM hooks are added:
1. perf_event_open: This controls access during the perf_event_open(2)
   syscall itself. The hook is called from all the places that the
   perf_event_paranoid sysctl is checked to keep it consistent with the
   systctl. The hook gets passed a 'type' argument which controls CPU,
   kernel and tracepoint accesses (in this context, CPU, kernel and
   tracepoint have the same semantics as the perf_event_paranoid sysctl).
   Additionally, I added an 'open' type which is similar to
   perf_event_paranoid sysctl == 3 patch carried in Android and several other
   distros but was rejected in mainline [1] in 2016.

2. perf_event_alloc: This allocates a new security object for the event
   which stores the current SID within the event. It will be useful when
   the perf event's FD is passed through IPC to another process which may
   try to read the FD. Appropriate security checks will limit access.

3. perf_event_free: Called when the event is closed.

4. perf_event_read: Called from the read(2) and mmap(2) syscalls for the event.

5. perf_event_write: Called from the ioctl(2) syscalls for the event.

[1] https://lwn.net/Articles/696240/

Since Peter had suggest LSM hooks in 2016 [1], I am adding his
Suggested-by tag below.

To use this patch, we set the perf_event_paranoid sysctl to -1 and then
apply selinux checking as appropriate (default deny everything, and then
add policy rules to give access to domains that need it). In the future
we can remove the perf_event_paranoid sysctl altogether.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Co-developed-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: James Morris <jmorris@namei.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: rostedt@goodmis.org
Cc: Yonghong Song <yhs@fb.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: jeffv@google.com
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: primiano@google.com
Cc: Song Liu <songliubraving@fb.com>
Cc: rsavitski@google.com
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Matthew Garrett <matthewgarrett@google.com>
Link: https://lkml.kernel.org/r/20191014170308.70668-1-joel@joelfernandes.org

(cherry picked from commit da97e18458fb42d7c00fac5fd1c56a3896ec666e)
[ Ryan Savitski: adapted for older APIs, and folded in upstream
  ae79d5588a04 (perf/core: Fix !CONFIG_PERF_EVENTS build warnings and
  failures). This should fix the build errors from the previous backport
  attempt, where certain configurations would end up with functions
  referring to the perf_event struct prior to its declaration (and
  therefore declaring it with a different scope). ]
Bug: 137092007

(cherry picked from commit ca96898263)
[ Ryan Savitski: almost a clean application of the 4.14 common kernel's
  backport (aosp/1204338). Removed selinux_state arguments, and resolved
  two minor conflicts within events/core.c. ]
Change-Id: Id5f0439041027c36d1185f361f02144258bf0ecb
Signed-off-by: Ryan Savitski <rsavitski@google.com>
2020-01-22 23:11:52 +00:00
Joel Fernandes (Google)
ca96898263 BACKPORT: perf_event: Add support for LSM and SELinux checks
In current mainline, the degree of access to perf_event_open(2) system
call depends on the perf_event_paranoid sysctl.  This has a number of
limitations:

1. The sysctl is only a single value. Many types of accesses are controlled
   based on the single value thus making the control very limited and
   coarse grained.
2. The sysctl is global, so if the sysctl is changed, then that means
   all processes get access to perf_event_open(2) opening the door to
   security issues.

This patch adds LSM and SELinux access checking which will be used in
Android to access perf_event_open(2) for the purposes of attaching BPF
programs to tracepoints, perf profiling and other operations from
userspace. These operations are intended for production systems.

5 new LSM hooks are added:
1. perf_event_open: This controls access during the perf_event_open(2)
   syscall itself. The hook is called from all the places that the
   perf_event_paranoid sysctl is checked to keep it consistent with the
   systctl. The hook gets passed a 'type' argument which controls CPU,
   kernel and tracepoint accesses (in this context, CPU, kernel and
   tracepoint have the same semantics as the perf_event_paranoid sysctl).
   Additionally, I added an 'open' type which is similar to
   perf_event_paranoid sysctl == 3 patch carried in Android and several other
   distros but was rejected in mainline [1] in 2016.

2. perf_event_alloc: This allocates a new security object for the event
   which stores the current SID within the event. It will be useful when
   the perf event's FD is passed through IPC to another process which may
   try to read the FD. Appropriate security checks will limit access.

3. perf_event_free: Called when the event is closed.

4. perf_event_read: Called from the read(2) and mmap(2) syscalls for the event.

5. perf_event_write: Called from the ioctl(2) syscalls for the event.

[1] https://lwn.net/Articles/696240/

Since Peter had suggest LSM hooks in 2016 [1], I am adding his
Suggested-by tag below.

To use this patch, we set the perf_event_paranoid sysctl to -1 and then
apply selinux checking as appropriate (default deny everything, and then
add policy rules to give access to domains that need it). In the future
we can remove the perf_event_paranoid sysctl altogether.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Co-developed-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: James Morris <jmorris@namei.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: rostedt@goodmis.org
Cc: Yonghong Song <yhs@fb.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: jeffv@google.com
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: primiano@google.com
Cc: Song Liu <songliubraving@fb.com>
Cc: rsavitski@google.com
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Matthew Garrett <matthewgarrett@google.com>
Link: https://lkml.kernel.org/r/20191014170308.70668-1-joel@joelfernandes.org

(cherry picked from commit da97e18458fb42d7c00fac5fd1c56a3896ec666e)
[ Ryan Savitski: adapted for older APIs, and folded in upstream
  ae79d5588a04 (perf/core: Fix !CONFIG_PERF_EVENTS build warnings and
  failures). This should fix the build errors from the previous backport
  attempt, where certain configurations would end up with functions
  referring to the perf_event struct prior to its declaration (and
  therefore declaring it with a different scope). ]
Bug: 137092007
Change-Id: Iece194b3519dc5016ccbe127fc4e5c425ee7c442
Signed-off-by: Ryan Savitski <rsavitski@google.com>
2020-01-10 15:17:57 +00:00
Jeffrey Vander Stoep
7753861270 Revert "BACKPORT: perf_event: Add support for LSM and SELinux checks"
This reverts commit f81151cd3a.

Reason for revert: collides with aosp/1137243 and breaks build

Change-Id: I6d0216ccaa1a759fb1732c07601f5877b81a5f03
Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
2020-01-09 10:37:25 +00:00
Joel Fernandes (Google)
f81151cd3a BACKPORT: perf_event: Add support for LSM and SELinux checks
In current mainline, the degree of access to perf_event_open(2) system
call depends on the perf_event_paranoid sysctl.  This has a number of
limitations:

1. The sysctl is only a single value. Many types of accesses are controlled
   based on the single value thus making the control very limited and
   coarse grained.
2. The sysctl is global, so if the sysctl is changed, then that means
   all processes get access to perf_event_open(2) opening the door to
   security issues.

This patch adds LSM and SELinux access checking which will be used in
Android to access perf_event_open(2) for the purposes of attaching BPF
programs to tracepoints, perf profiling and other operations from
userspace. These operations are intended for production systems.

5 new LSM hooks are added:
1. perf_event_open: This controls access during the perf_event_open(2)
   syscall itself. The hook is called from all the places that the
   perf_event_paranoid sysctl is checked to keep it consistent with the
   systctl. The hook gets passed a 'type' argument which controls CPU,
   kernel and tracepoint accesses (in this context, CPU, kernel and
   tracepoint have the same semantics as the perf_event_paranoid sysctl).
   Additionally, I added an 'open' type which is similar to
   perf_event_paranoid sysctl == 3 patch carried in Android and several other
   distros but was rejected in mainline [1] in 2016.

2. perf_event_alloc: This allocates a new security object for the event
   which stores the current SID within the event. It will be useful when
   the perf event's FD is passed through IPC to another process which may
   try to read the FD. Appropriate security checks will limit access.

3. perf_event_free: Called when the event is closed.

4. perf_event_read: Called from the read(2) and mmap(2) syscalls for the event.

5. perf_event_write: Called from the ioctl(2) syscalls for the event.

[1] https://lwn.net/Articles/696240/

Since Peter had suggest LSM hooks in 2016 [1], I am adding his
Suggested-by tag below.

To use this patch, we set the perf_event_paranoid sysctl to -1 and then
apply selinux checking as appropriate (default deny everything, and then
add policy rules to give access to domains that need it). In the future
we can remove the perf_event_paranoid sysctl altogether.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Co-developed-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: James Morris <jmorris@namei.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: rostedt@goodmis.org
Cc: Yonghong Song <yhs@fb.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: jeffv@google.com
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: primiano@google.com
Cc: Song Liu <songliubraving@fb.com>
Cc: rsavitski@google.com
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Matthew Garrett <matthewgarrett@google.com>
Link: https://lkml.kernel.org/r/20191014170308.70668-1-joel@joelfernandes.org

Bug: 137092007
Change-Id: Ibb356813b0b2f0cedab7806ee21ce4c00469be32
(cherry picked from commit da97e18458fb42d7c00fac5fd1c56a3896ec666e)
[ Ryan Savitski:
  Adapted for older APIs, e.g. hlist -> list, removed refs to
  selinux_state. No new functionality. ]
Signed-off-by: Ryan Savitski <rsavitski@google.com>
2020-01-08 14:29:48 +00:00
Shivaprasad Hongal
367c46b11c Enable hardware based FBE on f2fs and adapt ext4 fs
Hardware File Based Encryption (FBE) uses inline crypto
engine to encrypt the user data.
1. security/pfk: changes to support per file
   encryption for f2fs using hardware crypto engine.
2. fs/ext4: adapted crypto APIs for generic crypto layer.
3. fs/f2fs: support hardware crypto engine based per file
   encryption.
4. fs/crypto: export APIs to support hardware crypto
   engine based per file encryption.
5. security/pfe: added wrapped key support based on
   upstream changes.
Other changes made to provide support framework for per
file encryption.

Reverting commit e02a4e21f6 ("ext4: Add HW File Based
Encryption on ext4 file system") and adding changes to
have FBE in sync with upstream implementation of FBE.

Change-Id: I17f9909c43ba744eb874f6d237745fbf88a2b848
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
2018-08-22 10:56:07 -07:00
Dinesh K Garg
e02a4e21f6 ext4: Add HW File Based Encryption on ext4 file system
HW File Based Encryption (FBE) uses Crypto Engine to
encrypt the user data with unique key for each file.
File name and data both are encrypted with this feature.
  1. security/pfk: New module to support per file
     encryption using CE.
  2. fs/ext4: changes made to support using crypto engine
     to encyrpt the data.
Other changes made to provide support framework for per
file encryption.

Change-Id: Idea3f6f8bf954c60c3c6caa3d9b048d87fcacbe4
Signed-off-by: Dinesh K Garg <dineshg@codeaurora.org>
2018-06-11 23:09:54 -07:00
Jakub Kicinski
535abe47ef UPSTREAM: security: bpf: replace include of linux/bpf.h with forward declarations
Touching linux/bpf.h makes us rebuild a surprisingly large
portion of the kernel.  Remove the unnecessary dependency
from security.h, it only needs forward declarations.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

Bug: 30950746
Change-Id: I93d4210845e7e2c748f13e260010b71d91864093

(cherry picked from commit 1495dc9f0a711a54f8fec849ce7f3a8f585a11e5)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Chenbo Feng
3479b1366c BACKPORT: security: bpf: Add LSM hooks for bpf object related syscall
Introduce several LSM hooks for the syscalls that will allow the
userspace to access to eBPF object such as eBPF programs and eBPF maps.
The security check is aimed to enforce a per object security protection
for eBPF object so only processes with the right priviliges can
read/write to a specific map or use a specific eBPF program. Besides
that, a general security hook is added before the multiplexer of bpf
syscall to check the cmd and the attribute used for the command. The
actual security module can decide which command need to be checked and
how the cmd should be checked.

Signed-off-by: Chenbo Feng <fengc@google.com>
Acked-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Bug: 30950746
Change-Id: Ieb3ac74392f531735fc7c949b83346a5f587a77b

(cherry picked from commit afdb09c720b62b8090584c11151d856df330e57d)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Linus Torvalds
7f85565a3f Merge tag 'selinux-pr-20170831' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux
Pull selinux updates from Paul Moore:
 "A relatively quiet period for SELinux, 11 patches with only two/three
  having any substantive changes.

  These noteworthy changes include another tweak to the NNP/nosuid
  handling, per-file labeling for cgroups, and an object class fix for
  AF_UNIX/SOCK_RAW sockets; the rest of the changes are minor tweaks or
  administrative updates (Stephen's email update explains the file
  explosion in the diffstat).

  Everything passes the selinux-testsuite"

[ Also a couple of small patches from the security tree from Tetsuo
  Handa for Tomoyo and LSM cleanup. The separation of security policy
  updates wasn't all that clean - Linus ]

* tag 'selinux-pr-20170831' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
  selinux: constify nf_hook_ops
  selinux: allow per-file labeling for cgroupfs
  lsm_audit: update my email address
  selinux: update my email address
  MAINTAINERS: update the NetLabel and Labeled Networking information
  selinux: use GFP_NOWAIT in the AVC kmem_caches
  selinux: Generalize support for NNP/nosuid SELinux domain transitions
  selinux: genheaders should fail if too many permissions are defined
  selinux: update the selinux info in MAINTAINERS
  credits: update Paul Moore's info
  selinux: Assign proper class to PF_UNIX/SOCK_RAW sockets
  tomoyo: Update URLs in Documentation/admin-guide/LSM/tomoyo.rst
  LSM: Remove security_task_create() hook.
2017-09-12 13:21:00 -07:00
Linus Torvalds
dd198ce714 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull namespace updates from Eric Biederman:
 "Life has been busy and I have not gotten half as much done this round
  as I would have liked. I delayed it so that a minor conflict
  resolution with the mips tree could spend a little time in linux-next
  before I sent this pull request.

  This includes two long delayed user namespace changes from Kirill
  Tkhai. It also includes a very useful change from Serge Hallyn that
  allows the security capability attribute to be used inside of user
  namespaces. The practical effect of this is people can now untar
  tarballs and install rpms in user namespaces. It had been suggested to
  generalize this and encode some of the namespace information
  information in the xattr name. Upon close inspection that makes the
  things that should be hard easy and the things that should be easy
  more expensive.

  Then there is my bugfix/cleanup for signal injection that removes the
  magic encoding of the siginfo union member from the kernel internal
  si_code. The mips folks reported the case where I had used FPE_FIXME
  me is impossible so I have remove FPE_FIXME from mips, while at the
  same time including a return statement in that case to keep gcc from
  complaining about unitialized variables.

  I almost finished the work to get make copy_siginfo_to_user a trivial
  copy to user. The code is available at:

     git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git neuter-copy_siginfo_to_user-v3

  But I did not have time/energy to get the code posted and reviewed
  before the merge window opened.

  I was able to see that the security excuse for just copying fields
  that we know are initialized doesn't work in practice there are buggy
  initializations that don't initialize the proper fields in siginfo. So
  we still sometimes copy unitialized data to userspace"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
  Introduce v3 namespaced file capabilities
  mips/signal: In force_fcr31_sig return in the impossible case
  signal: Remove kernel interal si_code magic
  fcntl: Don't use ambiguous SIG_POLL si_codes
  prctl: Allow local CAP_SYS_ADMIN changing exe_file
  security: Use user_namespace::level to avoid redundant iterations in cap_capable()
  userns,pidns: Verify the userns for new pid namespaces
  signal/testing: Don't look for __SI_FAULT in userspace
  signal/mips: Document a conflict with SI_USER with SIGFPE
  signal/sparc: Document a conflict with SI_USER with SIGFPE
  signal/ia64: Document a conflict with SI_USER with SIGFPE
  signal/alpha: Document a conflict with SI_USER for SIGTRAP
2017-09-11 18:34:47 -07:00
Serge E. Hallyn
8db6c34f1d Introduce v3 namespaced file capabilities
Root in a non-initial user ns cannot be trusted to write a traditional
security.capability xattr.  If it were allowed to do so, then any
unprivileged user on the host could map his own uid to root in a private
namespace, write the xattr, and execute the file with privilege on the
host.

However supporting file capabilities in a user namespace is very
desirable.  Not doing so means that any programs designed to run with
limited privilege must continue to support other methods of gaining and
dropping privilege.  For instance a program installer must detect
whether file capabilities can be assigned, and assign them if so but set
setuid-root otherwise.  The program in turn must know how to drop
partial capabilities, and do so only if setuid-root.

This patch introduces v3 of the security.capability xattr.  It builds a
vfs_ns_cap_data struct by appending a uid_t rootid to struct
vfs_cap_data.  This is the absolute uid_t (that is, the uid_t in user
namespace which mounted the filesystem, usually init_user_ns) of the
root id in whose namespaces the file capabilities may take effect.

When a task asks to write a v2 security.capability xattr, if it is
privileged with respect to the userns which mounted the filesystem, then
nothing should change.  Otherwise, the kernel will transparently rewrite
the xattr as a v3 with the appropriate rootid.  This is done during the
execution of setxattr() to catch user-space-initiated capability writes.
Subsequently, any task executing the file which has the noted kuid as
its root uid, or which is in a descendent user_ns of such a user_ns,
will run the file with capabilities.

Similarly when asking to read file capabilities, a v3 capability will
be presented as v2 if it applies to the caller's namespace.

If a task writes a v3 security.capability, then it can provide a uid for
the xattr so long as the uid is valid in its own user namespace, and it
is privileged with CAP_SETFCAP over its namespace.  The kernel will
translate that rootid to an absolute uid, and write that to disk.  After
this, a task in the writer's namespace will not be able to use those
capabilities (unless rootid was 0), but a task in a namespace where the
given uid is root will.

Only a single security.capability xattr may exist at a time for a given
file.  A task may overwrite an existing xattr so long as it is
privileged over the inode.  Note this is a departure from previous
semantics, which required privilege to remove a security.capability
xattr.  This check can be re-added if deemed useful.

This allows a simple setxattr to work, allows tar/untar to work, and
allows us to tar in one namespace and untar in another while preserving
the capability, without risking leaking privilege into a parent
namespace.

Example using tar:

 $ cp /bin/sleep sleepx
 $ mkdir b1 b2
 $ lxc-usernsexec -m b:0:100000:1 -m b:1:$(id -u):1 -- chown 0:0 b1
 $ lxc-usernsexec -m b:0:100001:1 -m b:1:$(id -u):1 -- chown 0:0 b2
 $ lxc-usernsexec -m b:0:100000:1000 -- tar --xattrs-include=security.capability --xattrs -cf b1/sleepx.tar sleepx
 $ lxc-usernsexec -m b:0:100001:1000 -- tar --xattrs-include=security.capability --xattrs -C b2 -xf b1/sleepx.tar
 $ lxc-usernsexec -m b:0:100001:1000 -- getcap b2/sleepx
   b2/sleepx = cap_sys_admin+ep
 # /opt/ltp/testcases/bin/getv3xattr b2/sleepx
   v3 xattr, rootid is 100001

A patch to linux-test-project adding a new set of tests for this
functionality is in the nsfscaps branch at github.com/hallyn/ltp

Changelog:
   Nov 02 2016: fix invalid check at refuse_fcap_overwrite()
   Nov 07 2016: convert rootid from and to fs user_ns
   (From ebiederm: mar 28 2017)
     commoncap.c: fix typos - s/v4/v3
     get_vfs_caps_from_disk: clarify the fs_ns root access check
     nsfscaps: change the code split for cap_inode_setxattr()
   Apr 09 2017:
       don't return v3 cap for caps owned by current root.
      return a v2 cap for a true v2 cap in non-init ns
   Apr 18 2017:
      . Change the flow of fscap writing to support s_user_ns writing.
      . Remove refuse_fcap_overwrite().  The value of the previous
        xattr doesn't matter.
   Apr 24 2017:
      . incorporate Eric's incremental diff
      . move cap_convert_nscap to setxattr and simplify its usage
   May 8, 2017:
      . fix leaking dentry refcount in cap_inode_getsecurity

Signed-off-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
2017-09-01 14:57:15 -05:00
Kees Cook
2af6228026 LSM: drop bprm_secureexec hook
This removes the bprm_secureexec hook since the logic has been folded into
the bprm_set_creds hook for all LSMs now.

Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: John Johansen <john.johansen@canonical.com>
Acked-by: James Morris <james.l.morris@oracle.com>
Acked-by: Serge Hallyn <serge@hallyn.com>
2017-08-01 12:03:10 -07:00
Kees Cook
46d98eb4e1 commoncap: Refactor to remove bprm_secureexec hook
The commoncap implementation of the bprm_secureexec hook is the only LSM
that depends on the final call to its bprm_set_creds hook (since it may
be called for multiple files, it ignores bprm->called_set_creds). As a
result, it cannot safely _clear_ bprm->secureexec since other LSMs may
have set it.  Instead, remove the bprm_secureexec hook by introducing a
new flag to bprm specific to commoncap: cap_elevated. This is similar to
cap_effective, but that is used for a specific subset of elevated
privileges, and exists solely to track state from bprm_set_creds to
bprm_secureexec. As such, it will be removed in the next patch.

Here, set the new bprm->cap_elevated flag when setuid/setgid has happened
from bprm_fill_uid() or fscapabilities have been prepared. This temporarily
moves the bprm_secureexec hook to a static inline. The helper will be
removed in the next patch; this makes the step easier to review and bisect,
since this does not introduce any changes to inputs nor outputs to the
"elevated privileges" calculation.

The new flag is merged with the bprm->secureexec flag in setup_new_exec()
since this marks the end of any further prepare_binprm() calls.

Cc: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Acked-by: James Morris <james.l.morris@oracle.com>
Acked-by: Serge Hallyn <serge@hallyn.com>
2017-08-01 12:03:08 -07:00
Tetsuo Handa
3cf2993145 LSM: Remove security_task_create() hook.
Since commit a79be23860 ("selinux: Use task_alloc hook rather than
task_create hook") changed to use task_alloc hook, task_create hook is
no longer used.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <james.l.morris@oracle.com>
2017-07-18 17:24:03 +10:00
James Morris
5965453d5e Merge branch 'stable-4.13' of git://git.infradead.org/users/pcmoore/selinux into next 2017-06-23 11:55:57 +10:00
Scott Mayhew
0b4d3452b8 security/selinux: allow security_sb_clone_mnt_opts to enable/disable native labeling behavior
When an NFSv4 client performs a mount operation, it first mounts the
NFSv4 root and then does path walk to the exported path and performs a
submount on that, cloning the security mount options from the root's
superblock to the submount's superblock in the process.

Unless the NFS server has an explicit fsid=0 export with the
"security_label" option, the NFSv4 root superblock will not have
SBLABEL_MNT set, and neither will the submount superblock after cloning
the security mount options.  As a result, setxattr's of security labels
over NFSv4.2 will fail.  In a similar fashion, NFSv4.2 mounts mounted
with the context= mount option will not show the correct labels because
the nfs_server->caps flags of the cloned superblock will still have
NFS_CAP_SECURITY_LABEL set.

Allowing the NFSv4 client to enable or disable SECURITY_LSM_NATIVE_LABELS
behavior will ensure that the SBLABEL_MNT flag has the correct value
when the client traverses from an exported path without the
"security_label" option to one with the "security_label" option and
vice versa.  Similarly, checking to see if SECURITY_LSM_NATIVE_LABELS is
set upon return from security_sb_clone_mnt_opts() and clearing
NFS_CAP_SECURITY_LABEL if necessary will allow the correct labels to
be displayed for NFSv4.2 mounts mounted with the context= mount option.

Resolves: https://github.com/SELinuxProject/selinux-kernel/issues/35

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Reviewed-by: Stephen Smalley <sds@tycho.nsa.gov>
Tested-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
2017-06-09 16:17:47 -04:00
John Johansen
6623ec7c4d securityfs: add the ability to support symlinks
Signed-off-by: John Johansen <john.johansen@canonical.com>
Reviewed-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Kees Cook <keescook@chromium.org>
2017-06-08 12:51:43 -07:00
Daniel Jurgens
47a2b338fe IB/core: Enforce security on management datagrams
Allocate and free a security context when creating and destroying a MAD
agent.  This context is used for controlling access to PKeys and sending
and receiving SMPs.

When sending or receiving a MAD check that the agent has permission to
access the PKey for the Subnet Prefix of the port.

During MAD and snoop agent registration for SMI QPs check that the
calling process has permission to access the manage the subnet  and
register a callback with the LSM to be notified of policy changes. When
notificaiton of a policy change occurs recheck permission and set a flag
indicating sending and receiving SMPs is allowed.

When sending and receiving MADs check that the agent has access to the
SMI if it's on an SMI QP.  Because security policy can change it's
possible permission was allowed when creating the agent, but no longer
is.

Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Acked-by: Doug Ledford <dledford@redhat.com>
[PM: remove the LSM hook init code]
Signed-off-by: Paul Moore <paul@paul-moore.com>
2017-05-23 12:27:21 -04:00
Daniel Jurgens
8f408ab64b selinux lsm IB/core: Implement LSM notification system
Add a generic notificaiton mechanism in the LSM. Interested consumers
can register a callback with the LSM and security modules can produce
events.

Because access to Infiniband QPs are enforced in the setup phase of a
connection security should be enforced again if the policy changes.
Register infiniband devices for policy change notification and check all
QPs on that device when the notification is received.

Add a call to the notification mechanism from SELinux when the AVC
cache changes or setenforce is cleared.

Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Acked-by: James Morris <james.l.morris@oracle.com>
Acked-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
2017-05-23 12:27:11 -04:00
Daniel Jurgens
d291f1a652 IB/core: Enforce PKey security on QPs
Add new LSM hooks to allocate and free security contexts and check for
permission to access a PKey.

Allocate and free a security context when creating and destroying a QP.
This context is used for controlling access to PKeys.

When a request is made to modify a QP that changes the port, PKey index,
or alternate path, check that the QP has permission for the PKey in the
PKey table index on the subnet prefix of the port. If the QP is shared
make sure all handles to the QP also have access.

Store which port and PKey index a QP is using. After the reset to init
transition the user can modify the port, PKey index and alternate path
independently. So port and PKey settings changes can be a merge of the
previous settings and the new ones.

In order to maintain access control if there are PKey table or subnet
prefix change keep a list of all QPs are using each PKey index on
each port. If a change occurs all QPs using that device and port must
have access enforced for the new cache settings.

These changes add a transaction to the QP modify process. Association
with the old port and PKey index must be maintained if the modify fails,
and must be removed if it succeeds. Association with the new port and
PKey index must be established prior to the modify and removed if the
modify fails.

1. When a QP is modified to a particular Port, PKey index or alternate
   path insert that QP into the appropriate lists.

2. Check permission to access the new settings.

3. If step 2 grants access attempt to modify the QP.

4a. If steps 2 and 3 succeed remove any prior associations.

4b. If ether fails remove the new setting associations.

If a PKey table or subnet prefix changes walk the list of QPs and
check that they have permission. If not send the QP to the error state
and raise a fatal error event. If it's a shared QP make sure all the
QPs that share the real_qp have permission as well. If the QP that
owns a security structure is denied access the security structure is
marked as such and the QP is added to an error_list. Once the moving
the QP to error is complete the security structure mark is cleared.

Maintaining the lists correctly turns QP destroy into a transaction.
The hardware driver for the device frees the ib_qp structure, so while
the destroy is in progress the ib_qp pointer in the ib_qp_security
struct is undefined. When the destroy process begins the ib_qp_security
structure is marked as destroying. This prevents any action from being
taken on the QP pointer. After the QP is destroyed successfully it
could still listed on an error_list wait for it to be processed by that
flow before cleaning up the structure.

If the destroy fails the QPs port and PKey settings are reinserted into
the appropriate lists, the destroying flag is cleared, and access control
is enforced, in case there were any cache changes during the destroy
flow.

To keep the security changes isolated a new file is used to hold security
related functionality.

Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Acked-by: Doug Ledford <dledford@redhat.com>
[PM: merge fixup in ib_verbs.h and uverbs_cmd.c]
Signed-off-by: Paul Moore <paul@paul-moore.com>
2017-05-23 12:26:59 -04:00
Tetsuo Handa
e4e55b47ed LSM: Revive security_task_alloc() hook and per "struct task_struct" security blob.
We switched from "struct task_struct"->security to "struct cred"->security
in Linux 2.6.29. But not all LSM modules were happy with that change.
TOMOYO LSM module is an example which want to use per "struct task_struct"
security blob, for TOMOYO's security context is defined based on "struct
task_struct" rather than "struct cred". AppArmor LSM module is another
example which want to use it, for AppArmor is currently abusing the cred
a little bit to store the change_hat and setexeccon info. Although
security_task_free() hook was revived in Linux 3.4 because Yama LSM module
wanted to release per "struct task_struct" security blob,
security_task_alloc() hook and "struct task_struct"->security field were
not revived. Nowadays, we are getting proposals of lightweight LSM modules
which want to use per "struct task_struct" security blob.

We are already allowing multiple concurrent LSM modules (up to one fully
armored module which uses "struct cred"->security field or exclusive hooks
like security_xfrm_state_pol_flow_match(), plus unlimited number of
lightweight modules which do not use "struct cred"->security nor exclusive
hooks) as long as they are built into the kernel. But this patch does not
implement variable length "struct task_struct"->security field which will
become needed when multiple LSM modules want to use "struct task_struct"->
security field. Although it won't be difficult to implement variable length
"struct task_struct"->security field, let's think about it after we merged
this patch.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Serge Hallyn <serge@hallyn.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Tested-by: Djalal Harouni <tixxdz@gmail.com>
Acked-by: José Bollo <jobol@nonadev.net>
Cc: Paul Moore <paul@paul-moore.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Eric Paris <eparis@parisplace.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: James Morris <james.l.morris@oracle.com>
Cc: José Bollo <jobol@nonadev.net>
Signed-off-by: James Morris <james.l.morris@oracle.com>
2017-03-28 11:05:14 +11:00
Stephen Smalley
791ec491c3 prlimit,security,selinux: add a security hook for prlimit
When SELinux was first added to the kernel, a process could only get
and set its own resource limits via getrlimit(2) and setrlimit(2), so no
MAC checks were required for those operations, and thus no security hooks
were defined for them. Later, SELinux introduced a hook for setlimit(2)
with a check if the hard limit was being changed in order to be able to
rely on the hard limit value as a safe reset point upon context
transitions.

Later on, when prlimit(2) was added to the kernel with the ability to get
or set resource limits (hard or soft) of another process, LSM/SELinux was
not updated other than to pass the target process to the setrlimit hook.
This resulted in incomplete control over both getting and setting the
resource limits of another process.

Add a new security_task_prlimit() hook to the check_prlimit_permission()
function to provide complete mediation.  The hook is only called when
acting on another task, and only if the existing DAC/capability checks
would allow access.  Pass flags down to the hook to indicate whether the
prlimit(2) call will read, write, or both read and write the resource
limits of the target process.

The existing security_task_setrlimit() hook is left alone; it continues
to serve a purpose in supporting the ability to make decisions based on
the old and/or new resource limit values when setting limits.  This
is consistent with the DAC/capability logic, where
check_prlimit_permission() performs generic DAC/capability checks for
acting on another task, while do_prlimit() performs a capability check
based on a comparison of the old and new resource limits.  Fix the
inline documentation for the hook to match the code.

Implement the new hook for SELinux.  For setting resource limits, we
reuse the existing setrlimit permission.  Note that this does overload
the setrlimit permission to mean the ability to set the resource limit
(soft or hard) of another process or the ability to change one's own
hard limit.  For getting resource limits, a new getrlimit permission
is defined.  This was not originally defined since getrlimit(2) could
only be used to obtain a process' own limits.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: James Morris <james.l.morris@oracle.com>
2017-03-06 10:43:47 +11:00
Linus Torvalds
f1ef09fde1 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull namespace updates from Eric Biederman:
 "There is a lot here. A lot of these changes result in subtle user
  visible differences in kernel behavior. I don't expect anything will
  care but I will revert/fix things immediately if any regressions show
  up.

  From Seth Forshee there is a continuation of the work to make the vfs
  ready for unpriviled mounts. We had thought the previous changes
  prevented the creation of files outside of s_user_ns of a filesystem,
  but it turns we missed the O_CREAT path. Ooops.

  Pavel Tikhomirov and Oleg Nesterov worked together to fix a long
  standing bug in the implemenation of PR_SET_CHILD_SUBREAPER where only
  children that are forked after the prctl are considered and not
  children forked before the prctl. The only known user of this prctl
  systemd forks all children after the prctl. So no userspace
  regressions will occur. Holding earlier forked children to the same
  rules as later forked children creates a semantic that is sane enough
  to allow checkpoing of processes that use this feature.

  There is a long delayed change by Nikolay Borisov to limit inotify
  instances inside a user namespace.

  Michael Kerrisk extends the API for files used to maniuplate
  namespaces with two new trivial ioctls to allow discovery of the
  hierachy and properties of namespaces.

  Konstantin Khlebnikov with the help of Al Viro adds code that when a
  network namespace exits purges it's sysctl entries from the dcache. As
  in some circumstances this could use a lot of memory.

  Vivek Goyal fixed a bug with stacked filesystems where the permissions
  on the wrong inode were being checked.

  I continue previous work on ptracing across exec. Allowing a file to
  be setuid across exec while being ptraced if the tracer has enough
  credentials in the user namespace, and if the process has CAP_SETUID
  in it's own namespace. Proc files for setuid or otherwise undumpable
  executables are now owned by the root in the user namespace of their
  mm. Allowing debugging of setuid applications in containers to work
  better.

  A bug I introduced with permission checking and automount is now
  fixed. The big change is to mark the mounts that the kernel initiates
  as a result of an automount. This allows the permission checks in sget
  to be safely suppressed for this kind of mount. As the permission
  check happened when the original filesystem was mounted.

  Finally a special case in the mount namespace is removed preventing
  unbounded chains in the mount hash table, and making the semantics
  simpler which benefits CRIU.

  The vfs fix along with related work in ima and evm I believe makes us
  ready to finish developing and merge fully unprivileged mounts of the
  fuse filesystem. The cleanups of the mount namespace makes discussing
  how to fix the worst case complexity of umount. The stacked filesystem
  fixes pave the way for adding multiple mappings for the filesystem
  uids so that efficient and safer containers can be implemented"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
  proc/sysctl: Don't grab i_lock under sysctl_lock.
  vfs: Use upper filesystem inode in bprm_fill_uid()
  proc/sysctl: prune stale dentries during unregistering
  mnt: Tuck mounts under others instead of creating shadow/side mounts.
  prctl: propagate has_child_subreaper flag to every descendant
  introduce the walk_process_tree() helper
  nsfs: Add an ioctl() to return owner UID of a userns
  fs: Better permission checking for submounts
  exit: fix the setns() && PR_SET_CHILD_SUBREAPER interaction
  vfs: open() with O_CREAT should not create inodes with unknown ids
  nsfs: Add an ioctl() to return the namespace type
  proc: Better ownership of files for non-dumpable tasks in user namespaces
  exec: Remove LSM_UNSAFE_PTRACE_CAP
  exec: Test the ptracer's saved cred to see if the tracee can gain caps
  exec: Don't reset euid and egid when the tracee has CAP_SETUID
  inotify: Convert to using per-namespace limits
2017-02-23 20:33:51 -08:00
Eric W. Biederman
9227dd2a84 exec: Remove LSM_UNSAFE_PTRACE_CAP
With previous changes every location that tests for
LSM_UNSAFE_PTRACE_CAP also tests for LSM_UNSAFE_PTRACE making the
LSM_UNSAFE_PTRACE_CAP redundant, so remove it.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2017-01-24 12:03:08 +13:00
Stephen Smalley
3a2f5a59a6 security,selinux,smack: kill security_task_wait hook
As reported by yangshukui, a permission denial from security_task_wait()
can lead to a soft lockup in zap_pid_ns_processes() since it only expects
sys_wait4() to return 0 or -ECHILD. Further, security_task_wait() can
in general lead to zombies; in the absence of some way to automatically
reparent a child process upon a denial, the hook is not useful.  Remove
the security hook and its implementations in SELinux and Smack.  Smack
already removed its check from its hook.

Reported-by: yangshukui <yangshukui@huawei.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
2017-01-12 11:10:57 -05:00
Stephen Smalley
b21507e272 proc,security: move restriction on writing /proc/pid/attr nodes to proc
Processes can only alter their own security attributes via
/proc/pid/attr nodes.  This is presently enforced by each individual
security module and is also imposed by the Linux credentials
implementation, which only allows a task to alter its own credentials.
Move the check enforcing this restriction from the individual
security modules to proc_pid_attr_write() before calling the security hook,
and drop the unnecessary task argument to the security hook since it can
only ever be the current task.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
2017-01-09 10:07:31 -05:00
James Morris
de2f4b3453 Merge branch 'stable-4.9' of git://git.infradead.org/users/pcmoore/selinux into next 2016-09-19 12:27:10 +10:00
Mickaël Salaün
a4f4528a31 module: Fully remove the kernel_module_from_file hook
Remove remaining kernel_module_from_file hook left by commit
a1db742094 ("module: replace copy_module_from_fd with kernel version")

Signed-off-by: Mickaël Salaün <mic@digikod.net>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
2016-08-09 10:58:57 +10:00
Vivek Goyal
2602625b7e security, overlayfs: Provide hook to correctly label newly created files
During a new file creation we need to make sure new file is created with the
right label. New file is created in upper/ so effectively file should get
label as if task had created file in upper/.

We switched to mounter's creds for actual file creation. Also if there is a
whiteout present, then file will be created in work/ dir first and then
renamed in upper. In none of the cases file will be labeled as we want it to
be.

This patch introduces a new hook dentry_create_files_as(), which determines
the label/context dentry will get if it had been created by task in upper
and modify passed set of creds appropriately. Caller makes use of these new
creds for file creation.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
[PM: fix whitespace issues found with checkpatch.pl]
[PM: changes to use stat->mode in ovl_create_or_link()]
Signed-off-by: Paul Moore <paul@paul-moore.com>
2016-08-08 20:46:46 -04:00
Vivek Goyal
121ab822ef security,overlayfs: Provide security hook for copy up of xattrs for overlay file
Provide a security hook which is called when xattrs of a file are being
copied up. This hook is called once for each xattr and LSM can return
0 if the security module wants the xattr to be copied up, 1 if the
security module wants the xattr to be discarded on the copy, -EOPNOTSUPP
if the security module does not handle/manage the xattr, or a -errno
upon an error.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
[PM: whitespace cleanup for checkpatch.pl]
Signed-off-by: Paul Moore <paul@paul-moore.com>
2016-08-08 20:42:13 -04:00
Vivek Goyal
d8ad8b4961 security, overlayfs: provide copy up security hook for unioned files
Provide a security hook to label new file correctly when a file is copied
up from lower layer to upper layer of a overlay/union mount.

This hook can prepare a new set of creds which are suitable for new file
creation during copy up. Caller will use new creds to create file and then
revert back to old creds and release new creds.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
[PM: whitespace cleanup to appease checkpatch.pl]
Signed-off-by: Paul Moore <paul@paul-moore.com>
2016-08-08 20:06:53 -04:00
Al Viro
4f3ccd7657 qstr: constify dentry_init_security
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-07-20 23:30:06 -04:00
Linus Torvalds
c52b76185b Merge branch 'work.const-path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull 'struct path' constification update from Al Viro:
 "'struct path' is passed by reference to a bunch of Linux security
  methods; in theory, there's nothing to stop them from modifying the
  damn thing and LSM community being what it is, sooner or later some
  enterprising soul is going to decide that it's a good idea.

  Let's remove the temptation and constify all of those..."

* 'work.const-path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  constify ima_d_path()
  constify security_sb_pivotroot()
  constify security_path_chroot()
  constify security_path_{link,rename}
  apparmor: remove useless checks for NULL ->mnt
  constify security_path_{mkdir,mknod,symlink}
  constify security_path_{unlink,rmdir}
  apparmor: constify common_perm_...()
  apparmor: constify aa_path_link()
  apparmor: new helper - common_path_perm()
  constify chmod_common/security_path_chmod
  constify security_sb_mount()
  constify chown_common/security_path_chown
  tomoyo: constify assorted struct path *
  apparmor_path_truncate(): path->mnt is never NULL
  constify vfs_truncate()
  constify security_path_truncate()
  [apparmor] constify struct path * in a bunch of helpers
2016-05-17 14:41:03 -07:00
Baolin Wang
457db29bfc security: Introduce security_settime64()
security_settime() uses a timespec, which is not year 2038 safe
on 32bit systems. Thus this patch introduces the security_settime64()
function with timespec64 type. We also convert the cap_settime() helper
function to use the 64bit types.

This patch then moves security_settime() to the header file as an
inline helper function so that existing users can be iteratively
converted.

None of the existing hooks is using the timespec argument and therefor
the patch is not making any functional changes.

Cc: Serge Hallyn <serge.hallyn@canonical.com>,
Cc: James Morris <james.l.morris@oracle.com>,
Cc: "Serge E. Hallyn" <serge@hallyn.com>,
Cc: Paul Moore <pmoore@redhat.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Kees Cook <keescook@chromium.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Reviewed-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
[jstultz: Reworded commit message]
Signed-off-by: John Stultz <john.stultz@linaro.org>
2016-04-22 11:48:30 -07:00
Al Viro
3b73b68c05 constify security_sb_pivotroot()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-03-28 00:47:52 -04:00
Al Viro
77b286c0d2 constify security_path_chroot()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-03-28 00:47:51 -04:00
Al Viro
3ccee46ab4 constify security_path_{link,rename}
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-03-28 00:47:36 -04:00
Al Viro
d360775217 constify security_path_{mkdir,mknod,symlink}
... as well as unix_mknod() and may_o_create()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-03-28 00:47:27 -04:00
Al Viro
989f74e050 constify security_path_{unlink,rmdir}
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-03-28 00:47:27 -04:00
Al Viro
be01f9f28e constify chmod_common/security_path_chmod
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-03-28 00:47:25 -04:00