mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-05 19:31:57 -04:00
* remotes/origin/tmp-4c8fb32:
ANDROID: GKI: add Trimble symbol list
UPSTREAM: selinux: ignore unknown extended permissions
ANDROID: ABI: Update allowed list for galaxy
Revert "netfilter: Replace zero-length array with flexible-array member"
Revert "tracing: Constify string literal data member in struct trace_event_call"
Revert "skb_expand_head() adjust skb->truesize incorrectly"
Linux 5.4.289
ftrace: use preempt_enable/disable notrace macros to avoid double fault
mm: vmscan: account for free pages to prevent infinite Loop in throttle_direct_reclaim()
drm: adv7511: Drop dsi single lane support
net/sctp: Prevent autoclose integer overflow in sctp_association_init()
sky2: Add device ID 11ab:4373 for Marvell 88E8075
pinctrl: mcp23s08: Fix sleeping in atomic context due to regmap locking
RDMA/uverbs: Prevent integer overflow issue
modpost: fix the missed iteration for the max bit in do_input()
modpost: fix input MODULE_DEVICE_TABLE() built for 64-bit on 32-bit host
ARC: build: Try to guess GCC variant of cross compiler
irqchip/gic: Correct declaration of *percpu_base pointer in union gic_base
net: usb: qmi_wwan: add Telit FE910C04 compositions
bpf: fix potential error return
sound: usb: format: don't warn that raw DSD is unsupported
wifi: mac80211: wake the queues in case of failure in resume
ila: serialize calls to nf_register_net_hooks()
af_packet: fix vlan_get_protocol_dgram() vs MSG_PEEK
af_packet: fix vlan_get_tci() vs MSG_PEEK
ALSA: usb-audio: US16x08: Initialize array before use
net: llc: reset skb->transport_header
netfilter: nft_set_hash: unaligned atomic read on struct nft_set_ext
netfilter: Replace zero-length array with flexible-array member
netrom: check buffer length before accessing it
drm/bridge: adv7511_audio: Update Audio InfoFrame properly
drm: bridge: adv7511: Enable SPDIF DAI
RDMA/bnxt_re: Fix max_qp_wrs reported
RDMA/bnxt_re: Fix reporting hw_ver in query_device
RDMA/bnxt_re: Add check for path mtu in modify_qp
RDMA/mlx5: Enforce same type port association for multiport RoCE
net/mlx5: Make API mlx5_core_is_ecpf accept const pointer
IB/mlx5: Introduce and use mlx5_core_is_vf()
Drivers: hv: util: Avoid accessing a ringbuffer not initialized yet
selinux: ignore unknown extended permissions
ipv6: prevent possible UAF in ip6_xmit()
skb_expand_head() adjust skb->truesize incorrectly
btrfs: avoid monopolizing a core when activating a swap file
tracing: Constify string literal data member in struct trace_event_call
bpf: fix recursive lock when verdict program return SK_PASS
ipv6: fix possible UAF in ip6_finish_output2()
ipv6: use skb_expand_head in ip6_xmit
ipv6: use skb_expand_head in ip6_finish_output2
skbuff: introduce skb_expand_head()
MIPS: Probe toolchain support of -msym32
epoll: Add synchronous wakeup support for ep_poll_callback
virtio-blk: don't keep queue frozen during system suspend
scsi: mpt3sas: Diag-Reset when Doorbell-In-Use bit is set during driver load time
platform/x86: asus-nb-wmi: Ignore unknown event 0xCF
regmap: Use correct format specifier for logging range errors
scsi: megaraid_sas: Fix for a potential deadlock
scsi: qla1280: Fix hw revision numbering for ISP1020/1040
tracing/kprobe: Make trace_kprobe's module callback called after jump_label update
mtd: rawnand: fix double free in atmel_pmecc_create_user()
dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset
dmaengine: mv_xor: fix child node refcount handling in early exit
phy: core: Fix that API devm_phy_destroy() fails to destroy the phy
phy: core: Fix that API devm_phy_put() fails to release the phy
phy: core: Fix an OF node refcount leakage in of_phy_provider_lookup()
phy: core: Fix an OF node refcount leakage in _of_phy_get()
mtd: diskonchip: Cast an operand to prevent potential overflow
nfsd: restore callback functionality for NFSv4.0
bpf: Check negative offsets in __bpf_skb_min_len()
media: dvb-frontends: dib3000mb: fix uninit-value in dib3000_write_reg
of: Fix refcount leakage for OF node returned by __of_get_dma_parent()
of: Fix error path in of_parse_phandle_with_args_map()
udmabuf: also check for F_SEAL_FUTURE_WRITE
nilfs2: prevent use of deleted inode
of/irq: Fix using uninitialized variable @addr_len in API of_irq_parse_one()
NFS/pnfs: Fix a live lock between recalled layouts and layoutget
btrfs: tree-checker: reject inline extent items with 0 ref count
zram: refuse to use zero sized block device as backing device
sh: clk: Fix clk_enable() to return 0 on NULL clk
USB: serial: option: add Telit FE910C04 rmnet compositions
USB: serial: option: add MediaTek T7XX compositions
USB: serial: option: add Netprisma LCUK54 modules for WWAN Ready
USB: serial: option: add MeiG Smart SLM770A
USB: serial: option: add TCL IK512 MBIM & ECM
efivarfs: Fix error on non-existent file
i2c: riic: Always round-up when calculating bus period
chelsio/chtls: prevent potential integer overflow on 32bit
mmc: sdhci-tegra: Remove SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC quirk
netfilter: ipset: Fix for recursive locking warning
net: ethernet: bgmac-platform: fix an OF node reference leak
net: hinic: Fix cleanup in create_rxqs/txqs()
ionic: use ee->offset when returning sprom data
net/smc: check sndbuf_space again after NOSPACE flag is set in smc_poll
erofs: fix incorrect symlink detection in fast symlink
erofs: fix order >= MAX_ORDER warning due to crafted negative i_size
drm/i915: Fix memory leak by correcting cache object name in error handler
i2c: pnx: Fix timeout in wait functions
PCI: Add ACS quirk for Broadcom BCM5760X NIC
ALSA: usb: Fix UBSAN warning in parse_audio_unit()
PCI/AER: Disable AER service on suspend
usb: dwc2: gadget: Don't write invalid mapped sg entries into dma_desc with iommu enabled
net: sched: fix ordering of qlen adjustment
UPSTREAM: ALSA: usb-audio: Fix a DMA to stack memory bug
Linux 5.4.288
ALSA: usb-audio: Fix a DMA to stack memory bug
xen/netfront: fix crash when removing device
tracing/kprobes: Skip symbol counting logic for module symbols in create_local_trace_kprobe()
KVM: arm64: Ignore PMCNTENSET_EL0 while checking for overflow status
blk-iocost: Avoid using clamp() on inuse in __propagate_weights()
blk-iocost: fix weight updates of inner active iocgs
blk-iocost: clamp inuse and skip noops in __propagate_weights()
ACPICA: events/evxfregn: don't release the ContextMutex that was never acquired
net/sched: netem: account for backlog updates from child qdisc
qca_spi: Make driver probing reliable
qca_spi: Fix clock speed for multiple QCA7000
ACPI: resource: Fix memory resource type union access
net: lapb: increase LAPB_HEADER_LEN
tipc: fix NULL deref in cleanup_bearer()
batman-adv: Do not let TT changes list grows indefinitely
batman-adv: Remove uninitialized data in full table TT response
batman-adv: Do not send uninitialized TT changes
bpf, sockmap: Fix update element with same
xfs: don't drop errno values when we fail to ficlone the entire range
usb: gadget: u_serial: Fix the issue that gs_start_io crashed due to accessing null pointer
usb: ehci-hcd: fix call balance of clocks handling routines
usb: dwc2: hcd: Fix GetPortStatus & SetPortFeature
ata: sata_highbank: fix OF node reference leak in highbank_initialize_phys()
usb: host: max3421-hcd: Correctly abort a USB request.
UPSTREAM: ALSA: usb-audio: Fix out of bounds reads when finding clock sources
UPSTREAM: ALSA: usb-audio: Fix potential out-of-bound accesses for Extigy and Mbox devices
Revert "cgroup: Make operations on the cgroup root_list RCU safe"
Revert "cgroup: Move rcu_head up near the top of cgroup_root"
Linux 5.4.287
bpf, xdp: Update devmap comments to reflect napi/rcu usage
ALSA: usb-audio: Fix out of bounds reads when finding clock sources
PCI: rockchip-ep: Fix address translation unit programming
Revert "drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read()"
modpost: Add .irqentry.text to OTHER_SECTIONS
ocfs2: Revert "ocfs2: fix the la space leak when unmounting an ocfs2 volume"
jffs2: Fix rtime decompressor
jffs2: Prevent rtime decompress memory corruption
KVM: arm64: vgic-its: Clear ITE when DISCARD frees an ITE
KVM: arm64: vgic-its: Clear DTE when MAPD unmaps a device
KVM: arm64: vgic-its: Add a data length check in vgic_its_save_*
perf/x86/intel/pt: Fix buffer full but size is 0 case
Revert "unicode: Don't special case ignorable code points"
bpf: fix OOB devmap writes when deleting elements
xdp: Simplify devmap cleanup
misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle
powerpc/prom_init: Fixup missing powermac #size-cells
usb: chipidea: udc: handle USB Error Interrupt if IOC not set
i3c: Use i3cdev->desc->info instead of calling i3c_device_get_info() to avoid deadlock
PCI: Add ACS quirk for Wangxun FF5xxx NICs
PCI: Add 'reset_subordinate' to reset hierarchy below bridge
f2fs: fix f2fs_bug_on when uninstalling filesystem call f2fs_evict_inode.
nvdimm: rectify the illogical code within nd_dax_probe()
pinctrl: qcom-pmic-gpio: add support for PM8937
scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset
scsi: st: Don't modify unknown block number in MTIOCGET
leds: class: Protect brightness_show() with led_cdev->led_access mutex
tracing: Use atomic64_inc_return() in trace_clock_counter()
netpoll: Use rcu_access_pointer() in __netpoll_setup
net/neighbor: clear error in case strict check is not set
rocker: fix link status detection in rocker_carrier_init()
ASoC: hdmi-codec: reorder channel allocation list
Bluetooth: btusb: Add RTL8852BE device 0489:e123 to device tables
wifi: brcmfmac: Fix oops due to NULL pointer dereference in brcmf_sdiod_sglist_rw()
wifi: ipw2x00: libipw_rx_any(): fix bad alignment
drm/amdgpu: set the right AMDGPU sg segment limitation
jfs: add a check to prevent array-index-out-of-bounds in dbAdjTree
jfs: fix array-index-out-of-bounds in jfs_readdir
jfs: fix shift-out-of-bounds in dbSplit
jfs: array-index-out-of-bounds fix in dtReadFirst
wifi: ath5k: add PCI ID for Arcadyan devices
wifi: ath5k: add PCI ID for SX76X
net: inet6: do not leave a dangling sk pointer in inet6_create()
net: inet: do not leave a dangling sk pointer in inet_create()
net: ieee802154: do not leave a dangling sk pointer in ieee802154_create()
net: af_can: do not leave a dangling sk pointer in can_create()
Bluetooth: L2CAP: do not leave dangling sk pointer on error in l2cap_sock_create()
af_packet: avoid erroring out after sock_init_data() in packet_create()
net/sched: cbs: Fix integer overflow in cbs_set_port_rate()
net: ethernet: fs_enet: Use %pa to format resource_size_t
net: fec_mpc52xx_phy: Use %pa to format resource_size_t
samples/bpf: Fix a resource leak
drm/radeon/r600_cs: Fix possible int overflow in r600_packet3_check()
drm/mcde: Enable module autoloading
drm: panel-orientation-quirks: Add quirk for AYA NEO 2 model
media: cx231xx: Add support for Dexatek USB Video Grabber 1d19:6108
media: uvcvideo: Add a quirk for the Kaiweets KTI-W02 infrared camera
s390/cpum_sf: Handle CPU hotplug remove during sampling
mmc: core: Further prevent card detect during shutdown
regmap: detach regmap from dev on regmap_exit
dma-buf: fix dma_fence_array_signaled v4
bcache: revert replacing IS_ERR_OR_NULL with IS_ERR again
nilfs2: fix potential out-of-bounds memory access in nilfs_find_entry()
scsi: qla2xxx: Remove check req_sg_cnt should be equal to rsp_sg_cnt
scsi: qla2xxx: Supported speed displayed incorrectly for VPorts
scsi: qla2xxx: Fix NVMe and NPIV connect issue
ocfs2: update seq_file index in ocfs2_dlm_seq_next
tracing: Fix cmp_entries_dup() to respect sort() comparison rules
HID: wacom: fix when get product name maybe null pointer
bpf: Fix exact match conditions in trie_get_next_key()
bpf: Handle BPF_EXIST and BPF_NOEXIST for LPM trie
ocfs2: free inode when ocfs2_get_init_inode() fails
spi: mpc52xx: Add cancel_work_sync before module remove
tcp_bpf: Fix the sk_mem_uncharge logic in tcp_bpf_sendmsg
drm/sti: Add __iomem for mixer_dbg_mxn's parameter
gpio: grgpio: Add NULL check in grgpio_probe
gpio: grgpio: use a helper variable to store the address of ofdev->dev
crypto: x86/aegis128 - access 32-bit arguments as 32-bit
x86/asm: Reorder early variables
xen: Fix the issue of resource not being properly released in xenbus_dev_probe()
xen/xenbus: fix locking
xenbus/backend: Protect xenbus callback with lock
xenbus/backend: Add memory pressure handler callback
xen/xenbus: reference count registered modules
netfilter: nft_set_hash: skip duplicated elements pending gc run
netfilter: ipset: Hold module reference while requesting a module
igb: Fix potential invalid memory access in igb_init_module()
net/qed: allow old cards not supporting "num_images" to work
tipc: Fix use-after-free of kernel socket in cleanup_bearer().
tipc: add new AEAD key structure for user API
tipc: enable creating a "preliminary" node
tipc: add reference counter to bearer
dccp: Fix memory leak in dccp_feat_change_recv
net/ipv6: release expired exception dst cached in socket
can: j1939: j1939_session_new(): fix skb reference counting
net/sched: tbf: correct backlog statistic for GSO packets
netfilter: x_tables: fix LED ID check in led_tg_check()
ipvs: fix UB due to uninitialized stack access in ip_vs_protocol_init()
can: sun4i_can: sun4i_can_err(): fix {rx,tx}_errors statistics
can: sun4i_can: sun4i_can_err(): call can_change_state() even if cf is NULL
watchdog: mediatek: Make sure system reset gets asserted in mtk_wdt_restart()
iTCO_wdt: mask NMI_NOW bit for update_no_reboot_bit() call
drm/etnaviv: flush shader L1 cache after user commandstream
nfsd: fix nfs4_openowner leak when concurrent nfsd4_open occur
nfsd: make sure exp active before svc_export_show
dm thin: Add missing destroy_work_on_stack()
i3c: master: Fix miss free init_dyn_addr at i3c_master_put_i3c_addrs()
util_macros.h: fix/rework find_closest() macros
ad7780: fix division by zero in ad7780_write_raw()
clk: qcom: gcc-qcs404: fix initial rate of GPLL3
ftrace: Fix regression with module command in stack_trace_filter
ovl: Filter invalid inodes with missing lookup function
media: platform: allegro-dvt: Fix possible memory leak in allocate_buffers_internal()
media: gspca: ov534-ov772x: Fix off-by-one error in set_frame_rate()
media: venus: Fix pm_runtime_set_suspended() with runtime pm enabled
media: ts2020: fix null-ptr-deref in ts2020_probe()
media: i2c: tc358743: Fix crash in the probe error path when using polling
btrfs: ref-verify: fix use-after-free after invalid ref action
quota: flush quota_release_work upon quota writeback
ASoC: fsl_micfil: fix the naming style for mask definition
sh: intc: Fix use-after-free bug in register_intc_controller()
sunrpc: clear XPRT_SOCK_UPD_TIMEOUT when reset transport
SUNRPC: Replace internal use of SOCKWQ_ASYNC_NOSPACE
SUNRPC: correct error code comment in xs_tcp_setup_socket()
modpost: remove incorrect code in do_eisa_entry()
rtc: ab-eoz9: don't fail temperature reads on undervoltage notification
9p/xen: fix release of IRQ
9p/xen: fix init sequence
block: return unsigned int from bdev_io_min
jffs2: fix use of uninitialized variable
ubifs: authentication: Fix use-after-free in ubifs_tnc_end_commit
ubi: fastmap: Fix duplicate slab cache names while attaching
ubifs: Correct the total block count by deducting journal reservation
rtc: check if __rtc_read_time was successful in rtc_timer_do_work()
rtc: abx80x: Fix WDT bit position of the status register
rtc: st-lpc: Use IRQF_NO_AUTOEN flag in request_irq()
NFSv4.0: Fix a use-after-free problem in the asynchronous open()
um: Always dump trace for specified task in show_stack
um: Clean up stacktrace dump
um: add show_stack_loglvl()
um/sysrq: remove needless variable sp
um: Fix the return value of elf_core_copy_task_fpregs
um: Fix potential integer overflow during physmem setup
rpmsg: glink: Propagate TX failures in intentless mode as well
SUNRPC: make sure cache entry active before cache_show
NFSD: Prevent a potential integer overflow
lib: string_helpers: silence snprintf() output truncation warning
usb: dwc3: gadget: Fix checking for number of TRBs left
ALSA: hda/realtek: Apply quirk for Medion E15433
ALSA: hda/realtek: Fix Internal Speaker and Mic boost of Infinix Y4 Max
ALSA: hda/realtek: Set PCBeep to default value for ALC274
ALSA: hda/realtek: Update ALC225 depop procedure
media: wl128x: Fix atomicity violation in fmc_send_cmd()
HID: wacom: Interpret tilt data from Intuos Pro BT as signed values
block: fix ordering between checking BLK_MQ_S_STOPPED request adding
arm64: tls: Fix context-switching of tpidrro_el0 when kpti is enabled
sh: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK
um: vector: Do not use drvdata in release
serial: 8250: omap: Move pm_runtime_get_sync
um: net: Do not use drvdata in release
um: ubd: Do not use drvdata in release
ubi: wl: Put source PEB into correct list if trying locking LEB failed
spi: Fix acpi deferred irq probe
netfilter: ipset: add missing range check in bitmap_ip_uadt
Revert "serial: sh-sci: Clean sci_ports[0] after at earlycon exit"
serial: sh-sci: Clean sci_ports[0] after at earlycon exit
Revert "usb: gadget: composite: fix OS descriptors w_value logic"
Bluetooth: Fix type of len in rfcomm_sock_getsockopt{,_old}()
tty: ldsic: fix tty_ldisc_autoload sysctl's proc_handler
comedi: Flush partial mappings in error case
PCI: Fix use-after-free of slot->bus on hot remove
ASoC: codecs: Fix atomicity violation in snd_soc_component_get_drvdata()
jfs: xattr: check invalid xattr size more strictly
ext4: fix FS_IOC_GETFSMAP handling
ext4: supress data-race warnings in ext4_free_inodes_{count,set}()
ALSA: usb-audio: Fix potential out-of-bound accesses for Extigy and Mbox devices
soc: qcom: socinfo: fix revision check in qcom_socinfo_probe()
cgroup: Move rcu_head up near the top of cgroup_root
cgroup: Make operations on the cgroup root_list RCU safe
usb: ehci-spear: fix call balance of sehci clk handling routines
apparmor: fix 'Do simple duplicate message elimination'
staging: greybus: uart: clean up TIOCGSERIAL
misc: apds990x: Fix missing pm_runtime_disable()
USB: chaoskey: Fix possible deadlock chaoskey_list_lock
USB: chaoskey: fail open after removal
usb: yurex: make waiting on yurex_write interruptible
usb: using mutex lock and supporting O_NONBLOCK flag in iowarrior_read()
ipmr: fix tables suspicious RCU usage
ipmr: convert /proc handlers to rcu_read_lock()
net: stmmac: dwmac-socfpga: Set RX watchdog interrupt as broken
marvell: pxa168_eth: fix call balance of pep->clk handling routines
net: usb: lan78xx: Fix refcounting and autosuspend on invalid WoL configuration
tg3: Set coherent DMA mask bits to 31 for BCM57766 chipsets
net: usb: lan78xx: Fix memory leak on device unplug by freeing PHY device
power: supply: core: Remove might_sleep() from power_supply_put()
vfio/pci: Properly hide first-in-list PCIe extended capability
NFSD: Fix nfsd4_shutdown_copy()
NFSD: Cap the number of bytes copied by nfs4_reset_recoverydir()
NFSD: Prevent NULL dereference in nfsd4_process_cb_update()
rpmsg: glink: use only lower 16-bits of param2 for CMD_OPEN name length
rpmsg: glink: Fix GLINK command prefix
rpmsg: glink: Send READ_NOTIFY command in FIFO full case
rpmsg: glink: Add TX_DATA_CONT command while sending
perf trace: Avoid garbage when not printing a syscall's arguments
perf trace: Do not lose last events in a race
m68k: coldfire/device.c: only build FEC when HW macros are defined
m68k: mcfgpio: Fix incorrect register offset for CONFIG_M5441x
PCI: cpqphp: Fix PCIBIOS_* return value confusion
PCI: cpqphp: Use PCI_POSSIBLE_ERROR() to check config reads
perf probe: Correct demangled symbols in C++ program
perf cs-etm: Don't flush when packet_queue fills up
clk: clk-axi-clkgen: make sure to enable the AXI bus clock
clk: axi-clkgen: use devm_platform_ioremap_resource() short-hand
dt-bindings: clock: axi-clkgen: include AXI clk
dt-bindings: clock: adi,axi-clkgen: convert old binding to yaml format
fbdev: sh7760fb: Fix a possible memory leak in sh7760fb_alloc_mem()
fbdev/sh7760fb: Alloc DMA memory from hardware device
powerpc/sstep: make emulate_vsx_load and emulate_vsx_store static
ocfs2: fix uninitialized value in ocfs2_file_read_iter()
scsi: qedi: Fix a possible memory leak in qedi_alloc_and_init_sb()
scsi: qedf: Fix a possible memory leak in qedf_alloc_and_init_sb()
scsi: fusion: Remove unused variable 'rc'
scsi: bfa: Fix use-after-free in bfad_im_module_exit()
mfd: rt5033: Fix missing regmap_del_irq_chip()
RDMA/bnxt_re: Check cqe flags to know imm_data vs inv_irkey
mtd: rawnand: atmel: Fix possible memory leak
cpufreq: loongson2: Unregister platform_driver on failure
mfd: intel_soc_pmic_bxtwc: Use IRQ domain for PMIC devices
mfd: intel_soc_pmic_bxtwc: Use IRQ domain for TMU device
mfd: intel_soc_pmic_bxtwc: Use IRQ domain for USB Type-C device
mfd: intel_soc_pmic_bxtwc: Use dev_err_probe()
mfd: da9052-spi: Change read-mask to write-mask
mfd: tps65010: Use IRQF_NO_AUTOEN flag in request_irq() to fix race
powerpc/vdso: Flag VDSO64 entry points as functions
trace/trace_event_perf: remove duplicate samples on the first tracepoint event
netpoll: Use rcu_access_pointer() in netpoll_poll_lock
ALSA: 6fire: Release resources at card release
ALSA: caiaq: Use snd_card_free_when_closed() at disconnection
ALSA: us122l: Use snd_card_free_when_closed() at disconnection
net: rfkill: gpio: Add check for clk_enable()
selftests: net: really check for bg process completion
bpf, sockmap: Fix sk_msg_reset_curr
bpf, sockmap: Several fixes to bpf_msg_pop_data
bpf, sockmap: Several fixes to bpf_msg_push_data
drm/etnaviv: hold GPU lock across perfmon sampling
drm/etnaviv: fix power register offset on GC300
drm/etnaviv: dump: fix sparse warnings
drm/msm/adreno: Use IRQF_NO_AUTOEN flag in request_irq()
drm/panfrost: Remove unused id_mask from struct panfrost_model
wifi: mwifiex: Fix memcpy() field-spanning write warning in mwifiex_config_scan()
bpf: Fix the xdp_adjust_tail sample prog issue
ASoC: fsl_micfil: fix regmap_write_bits usage
ASoC: fsl_micfil: use GENMASK to define register bit fields
ASoC: fsl_micfil: do not define SHIFT/MASK for single bits
ASoC: fsl_micfil: Drop unnecessary register read
dt-bindings: vendor-prefixes: Add NeoFidelity, Inc
drm/imx/ipuv3: Use IRQF_NO_AUTOEN flag in request_irq()
wifi: mwifiex: Use IRQF_NO_AUTOEN flag in request_irq()
wifi: p54: Use IRQF_NO_AUTOEN flag in request_irq()
drm/omap: Fix locking in omap_gem_new_dmabuf()
wifi: ath9k: add range check for conn_rsp_epid in htc_connect_service()
drm/mm: Mark drm_mm_interval_tree*() functions with __maybe_unused
firmware: arm_scpi: Check the DVFS OPP count returned by the firmware
regmap: irq: Set lockdep class for hierarchical IRQ domains
ARM: dts: cubieboard4: Fix DCDC5 regulator constraints
tpm: fix signed/unsigned bug when checking event logs
efi/tpm: Pass correct address to memblock_reserve
mmc: mmc_spi: drop buggy snprintf()
soc: qcom: geni-se: fix array underflow in geni_se_clk_tbl_get()
soc: ti: smartreflex: Use IRQF_NO_AUTOEN flag in request_irq()
time: Fix references to _msecs_to_jiffies() handling of values
crypto: cavium - Fix an error handling path in cpt_ucode_load_fw()
crypto: bcm - add error check in the ahash_hmac_init function
crypto: cavium - Fix the if condition to exit loop after timeout
crypto: pcrypt - Call crypto layer directly when padata_do_parallel() return -EBUSY
EDAC/fsl_ddr: Fix bad bit shift operations
EDAC/bluefield: Fix potential integer overflow
firmware: google: Unregister driver_info on failure
firmware: google: Unregister driver_info on failure and exit in gsmi
hfsplus: don't query the device logical block size multiple times
s390/syscalls: Avoid creation of arch/arch/ directory
acpi/arm64: Adjust error handling procedure in gtdt_parse_timer_block()
m68k: mvme147: Reinstate early console
m68k: mvme16x: Add and use "mvme16x.h"
m68k: mvme147: Fix SCSI controller IRQ numbers
nvme-pci: fix freeing of the HMB descriptor table
initramfs: avoid filename buffer overrun
mips: asm: fix warning when disabling MIPS_FP_SUPPORT
x86/xen/pvh: Annotate indirect branch as safe
nvme: fix metadata handling in nvme-passthrough
NFSD: Force all NFSv4.2 COPY requests to be synchronous
cifs: Fix buffer overflow when parsing NFS reparse points
ipmr: Fix access to mfc_cache_list without lock held
proc/softirqs: replace seq_printf with seq_put_decimal_ull_width
ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div()
ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate()
regulator: rk808: Add apply_bit for BUCK3 on RK809
soc: qcom: Add check devm_kasprintf() returned value
net: usb: qmi_wwan: add Quectel RG650V
x86/amd_nb: Fix compile-testing without CONFIG_AMD_NB
ALSA: hda/realtek: Add subwoofer quirk for Infinix ZERO BOOK 13
selftests/watchdog-test: Fix system accidentally reset after watchdog-test
mac80211: fix user-power when emulating chanctx
ASoC: Intel: bytcr_rt5640: Add DMI quirk for Vexia Edu Atla 10 tablet
mm: revert "mm: shmem: fix data-race in shmem_getattr()"
kbuild: Use uname for LINUX_COMPILE_HOST detection
media: dvbdev: fix the logic when DVB_DYNAMIC_MINORS is not set
Revert "mmc: dw_mmc: Fix IDMAC operation with pages bigger than 4K"
nilfs2: fix null-ptr-deref in block_dirty_buffer tracepoint
ocfs2: fix UBSAN warning in ocfs2_verify_volume()
nilfs2: fix null-ptr-deref in block_touch_buffer tracepoint
KVM: VMX: Bury Intel PT virtualization (guest/host mode) behind CONFIG_BROKEN
ocfs2: uncache inode which has failed entering the group
net/mlx5e: kTLS, Fix incorrect page refcounting
net/mlx5: fs, lock FTE when checking if active
netlink: terminate outstanding dump on socket close
Revert "UPSTREAM: unicode: Don't special case ignorable code points"
Reapply "UPSTREAM: unicode: Don't special case ignorable code points"
Revert "UPSTREAM: unicode: Don't special case ignorable code points"
UPSTREAM: net/sched: stop qdisc_tree_reduce_backlog on TC_H_ROOT
ANDROID: add file for recording allowed ABI breaks
Revert "spi: Fix deadlock when adding SPI controllers on SPI buses"
Revert "spi: fix use-after-free of the add_lock mutex"
ANDROID: declare sp_in_global outside of CONFIG_FRAME_POINTER
BACKPORT: RISC-V: Stop relying on GCC's register allocator's hueristics
UPSTREAM: x86/percpu: Clean up percpu_add_op()
UPSTREAM: x86/percpu: Clean up percpu_from_op()
UPSTREAM: x86/percpu: Clean up percpu_to_op()
UPSTREAM: x86/percpu: Introduce size abstraction macros
BACKPORT: FROMGIT: binder: add delivered_freeze to debugfs output
BACKPORT: FROMGIT: binder: fix memleak of proc->delivered_freeze
FROMGIT: binder: allow freeze notification for dead nodes
FROMGIT: binder: fix BINDER_WORK_CLEAR_FREEZE_NOTIFICATION debug logs
FROMGIT: binder: fix BINDER_WORK_FROZEN_BINDER debug logs
BACKPORT: FROMGIT: binder: fix freeze UAF in binder_release_work()
FROMGIT: binder: fix OOB in binder_add_freeze_work()
FROMGIT: binder: fix node UAF in binder_add_freeze_work()
Linux 5.4.286
mm: avoid leaving partial pfn mappings around in error case
9p: fix slab cache name creation for real
mm: add remap_pfn_range_notrack
mm/memory.c: make remap_pfn_range() reject unaligned addr
mm: fix ambiguous comments for better code readability
mm: clarify a confusing comment for remap_pfn_range()
md/raid10: improve code of mrdev in raid10_sync_request
net: usb: qmi_wwan: add Fibocom FG132 0x0112 composition
fs: Fix uninitialized value issue in from_kuid and from_kgid
powerpc/powernv: Free name on error in opal_event_init()
sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML
bpf: use kvzmalloc to allocate BPF verifier environment
HID: multitouch: Add quirk for HONOR MagicBook Art 14 touchpad
9p: Avoid creating multiple slab caches with the same name
ALSA: usb-audio: Add endianness annotations
vsock/virtio: Initialization of the dangling pointer occurring in vsk->trans
hv_sock: Initializing vsk->trans to NULL to prevent a dangling pointer
ftrace: Fix possible use-after-free issue in ftrace_location()
NFSD: Fix NFSv4's PUTPUBFH operation
ALSA: usb-audio: Add quirks for Dell WD19 dock
ALSA: usb-audio: Support jack detection on Dell dock
ocfs2: remove entry once instead of null-ptr-dereference in ocfs2_xa_remove()
irqchip/gic-v3: Force propagation of the active state with a read-back
USB: serial: option: add Quectel RG650V
USB: serial: option: add Fibocom FG132 0x0112 composition
USB: serial: qcserial: add support for Sierra Wireless EM86xx
USB: serial: io_edgeport: fix use after free in debug printk
usb: musb: sunxi: Fix accessing an released usb phy
fs/proc: fix compile warning about variable 'vmcore_mmap_ops'
media: uvcvideo: Skip parsing frames of type UVC_VS_UNDEFINED in uvc_parse_format
net: bridge: xmit: make sure we have at least eth header len bytes
spi: fix use-after-free of the add_lock mutex
spi: Fix deadlock when adding SPI controllers on SPI buses
mtd: rawnand: protect access to rawnand devices while in suspend
btrfs: reinitialize delayed ref list after deleting it from the list
nfs: Fix KMSAN warning in decode_getfattr_attrs()
dm-unstriped: cast an operand to sector_t to prevent potential uint32_t overflow
dm cache: fix potential out-of-bounds access on the first resume
dm cache: optimize dirty bit checking with find_next_bit when resizing
dm cache: fix out-of-bounds access to the dirty bitset when resizing
dm cache: correct the number of origin blocks to match the target length
drm/amdgpu: prevent NULL pointer dereference if ATIF is not supported
drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read()
pwm: imx-tpm: Use correct MODULO value for EPWM mode
media: v4l2-tpg: prevent the risk of a division by zero
media: cx24116: prevent overflows on SNR calculus
media: s5p-jpeg: prevent buffer overflows
ALSA: firewire-lib: fix return value on fail in amdtp_tscm_init()
media: adv7604: prevent underflow condition when reporting colorspace
media: dvb_frontend: don't play tricks with underflow values
media: dvbdev: prevent the risk of out of memory access
media: stb0899_algo: initialize cfr before using it
net: hns3: fix kernel crash when uninstalling driver
can: c_can: fix {rx,tx}_errors statistics
sctp: properly validate chunk size in sctp_sf_ootb()
net: enetc: set MAC address to the VF net_device
enetc: simplify the return expression of enetc_vf_set_mac_addr()
security/keys: fix slab-out-of-bounds in key_task_permission
HID: core: zero-initialize the report buffer
ARM: dts: rockchip: Fix the realtek audio codec on rk3036-kylin
ARM: dts: rockchip: Fix the spi controller on rk3036
ARM: dts: rockchip: drop grf reference from rk3036 hdmi
ARM: dts: rockchip: fix rk3036 acodec node
arm64: dts: rockchip: Remove #cooling-cells from fan on Theobroma lion
arm64: dts: rockchip: Fix bluetooth properties on Rock960 boards
arm64: dts: rockchip: Remove hdmi's 2nd interrupt on rk3328
arm64: dts: rockchip: Fix rt5651 compatible value on rk3399-sapphire-excavator
ANDROID: GKI: Enable SERIAL_8250_DW
UPSTREAM: USB: media: uvcvideo: Skip parsing frames of type UVC_VS_UNDEFINED in uvc_parse_format
Revert "genetlink: hold RCU in genlmsg_mcast()"
Revert "arm64: probes: Fix uprobes for big-endian kernels"
Revert "arm64/uprobes: change the uprobe_opcode_t typedef to fix the sparse warning"
Revert "inet: inet_defrag: prevent sk release while still in use"
Linux 5.4.285
mm: krealloc: Fix MTE false alarm in __do_krealloc
mac80211: always have ieee80211_sta_restart()
vt: prevent kernel-infoleak in con_font_get()
Revert "drm/mipi-dsi: Set the fwnode for mipi_dsi_device"
mm: shmem: fix data-race in shmem_getattr()
nilfs2: fix kernel bug due to missing clearing of checked flag
ocfs2: pass u64 to ocfs2_truncate_inline maybe overflow
riscv: Remove unused GENERATING_ASM_OFFSETS
nilfs2: fix potential deadlock with newly created symlinks
staging: iio: frequency: ad9832: fix division by zero in ad9832_calc_freqreg()
wifi: iwlegacy: Clear stale interrupts before resuming device
wifi: ath10k: Fix memory leak in management tx
wifi: mac80211: do not pass a stopped vif to the driver in .get_txpower
Revert "driver core: Fix uevent_show() vs driver detach race"
xhci: Fix Link TRB DMA in command ring stopped completion event
usb: phy: Fix API devm_usb_put_phy() can not release the phy
usbip: tools: Fix detach_port() invalid port error path
misc: sgi-gru: Don't disable preemption in GRU driver
net: amd: mvme147: Fix probe banner message
firmware: arm_sdei: Fix the input parameter of cpuhp_remove_state()
drivers/misc: ti-st: Remove unneeded variable in st_tty_open
netfilter: nft_payload: sanitize offset and length before calling skb_checksum()
net: skip offload for NETIF_F_IPV6_CSUM if ipv6 header contains extension
net: support ip generic csum processing in skb_csum_hwoffload_help
bpf: Fix out-of-bounds write in trie_get_next_key()
net/sched: stop qdisc_tree_reduce_backlog on TC_H_ROOT
gtp: allow -1 to be specified as file description from userspace
gtp: simplify error handling code in 'gtp_encap_enable()'
dt-bindings: gpu: Convert Samsung Image Rotator to dt-schema
ASoC: cs42l51: Fix some error handling paths in cs42l51_probe()
wifi: iwlwifi: mvm: Fix response handling in iwl_mvm_send_recovery_cmd()
wifi: iwlwifi: mvm: disconnect station vifs if recovery failed
mac80211: Add support to trigger sta disconnect on hardware restart
mac80211: do drv_reconfig_complete() before restarting all
wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys
cgroup: Fix potential overflow issue when checking max_depth
xfrm: validate new SA's prefixlen using SA family when sel.family is unset
arm64/uprobes: change the uprobe_opcode_t typedef to fix the sparse warning
selinux: improve error checking in sel_write_load()
hv_netvsc: Fix VF namespace also in synthetic NIC NETDEV_REGISTER event
ALSA: hda/realtek: Add subwoofer quirk for Acer Predator G9-593
nilfs2: fix kernel bug due to missing clearing of buffer delay flag
ACPI: button: Add DMI quirk for Samsung Galaxy Book2 to fix initial lid detection issue
ACPI: resource: Add LG 16T90SP to irq1_level_low_skip_override[]
drm/amd: Guard against bad data for ATIF ACPI method
ALSA: hda/realtek: Update default depop procedure
ALSA: firewire-lib: Avoid division by zero in apply_constraint_to_size()
posix-clock: posix-clock: Fix unbalanced locking in pc_clock_settime()
r8169: avoid unsolicited interrupts
net: sched: fix use-after-free in taprio_change()
net: usb: usbnet: fix name regression
be2net: fix potential memory leak in be_xmit()
net/sun3_82586: fix potential memory leak in sun3_82586_send_packet()
tracing: Consider the NULL character when validating the event length
jfs: Fix sanity check in dbMount
udf: fix uninit-value use in udf_get_fileshortad
drm/vboxvideo: Replace fake VLA at end of vbva_mouse_pointer_shape with real VLA
KVM: s390: gaccess: Check if guest address is in memslot
KVM: s390: gaccess: Cleanup access to guest pages
KVM: s390: gaccess: Refactor access address range check
KVM: s390: gaccess: Refactor gpa and length calculation
arm64: probes: Fix uprobes for big-endian kernels
arm64:uprobe fix the uprobe SWBP_INSN in big-endian
Bluetooth: bnep: fix wild-memory-access in proto_unregister
usb: typec: altmode should keep reference to parent
smb: client: fix OOBs when building SMB2_IOCTL request
genetlink: hold RCU in genlmsg_mcast()
net: systemport: fix potential memory leak in bcm_sysport_xmit()
net: ethernet: aeroflex: fix potential memory leak in greth_start_xmit_gbit()
macsec: don't increment counters for an unrelated SA
drm/msm/dsi: fix 32-bit signed integer extension in pclk_rate calculation
RDMA/bnxt_re: Return more meaningful error
ipv4: give an IPv4 dev to blackhole_netdev
RDMA/cxgb4: Fix RDMA_CM_EVENT_UNREACHABLE error for iWARP
ARM: dts: bcm2837-rpi-cm3-io3: Fix HDMI hpd-gpio pin
RDMA/bnxt_re: Fix incorrect AVID type in WQE structure
mac80211: Fix NULL ptr deref for injected rate info
erofs: fix lz4 inplace decompression
nilfs2: propagate directory read errors from nilfs_find_entry()
x86/apic: Always explicitly disarm TSC-deadline timer
x86/resctrl: Annotate get_mem_config() functions as __init
parport: Proper fix for array out-of-bounds access
USB: serial: option: add Telit FN920C04 MBIM compositions
USB: serial: option: add support for Quectel EG916Q-GL
xhci: Fix incorrect stream context type macro
Bluetooth: btusb: Fix regression with fake CSR controllers 0a12:0001
Bluetooth: Remove debugfs directory on module init failure
iio: adc: ti-ads124s08: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig
iio: proximity: mb1232: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig
iio: light: opt3001: add missing full-scale range value
iio: hid-sensors: Fix an error handling path in _hid_sensor_set_report_latency()
iio: adc: ti-ads8688: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig
iio: dac: stm32-dac-core: add missing select REGMAP_MMIO in Kconfig
iio: dac: ltc1660: add missing select REGMAP_SPI in Kconfig
drm/vmwgfx: Handle surface check failure correctly
blk-rq-qos: fix crash on rq_qos_wait vs. rq_qos_wake_function race
x86/cpufeatures: Define X86_FEATURE_AMD_IBPB_RET
KVM: s390: Change virtual to physical address access in diag 0x258 handler
s390/sclp_vt220: Convert newlines to CRLF instead of LFCR
KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin()
wifi: mac80211: fix potential key use-after-free
mm/swapfile: skip HugeTLB pages for unuse_vma
fat: fix uninitialized variable
PCI: Add function 0 DMA alias quirk for Glenfly Arise chip
tracing/kprobes: Fix symbol counting logic by looking at modules as well
tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols
arm64: probes: Fix simulate_ldr*_literal()
arm64: probes: Remove broken LDR (literal) uprobe support
posix-clock: Fix missing timespec64 check in pc_clock_settime()
nouveau/dmem: Fix vulnerability in migrate_to_ram upon copy error
net: Fix an unsafe loop on the list
hid: intel-ish-hid: Fix uninitialized variable 'rv' in ish_fw_xfer_direct_dma
usb: storage: ignore bogus device raised by JieLi BR21 USB sound chip
usb: xhci: Fix problem with xhci resume from suspend
usb: dwc3: core: Stop processing of pending events if controller is halted
Revert "usb: yurex: Replace snprintf() with the safer scnprintf() variant"
HID: plantronics: Workaround for an unexcepted opposite volume key
CDC-NCM: avoid overflow in sanity checking
resource: fix region_intersects() vs add_memory_driver_managed()
lockdep: fix deadlock issue between lockdep and rcu
locking/lockdep: Avoid potential access of invalid memory in lock_class
locking/lockdep: Rework lockdep_lock
locking/lockdep: Fix bad recursion pattern
slip: make slhc_remember() more robust against malicious packets
ppp: fix ppp_async_encode() illegal access
sctp: ensure sk_state is set to CLOSED if hashing fails in sctp_listen_start
net: annotate lockless accesses to sk->sk_max_ack_backlog
net: annotate lockless accesses to sk->sk_ack_backlog
net: ibm: emac: mal: fix wrong goto
net/sched: accept TCA_STAB only for root qdisc
igb: Do not bring the device up after non-fatal error
gpio: aspeed: Use devm_clk api to manage clock source
gpio: aspeed: Add the flush write to ensure the write complete.
Bluetooth: RFCOMM: FIX possible deadlock in rfcomm_sk_state_change
netfilter: br_netfilter: fix panic with metadata_dst skb
tcp: fix tcp_enter_recovery() to zero retrans_stamp when it's safe
tcp: fix to allow timestamp undo if no retransmits were sent
SUNRPC: Fix integer overflow in decode_rc_list()
ice: fix VLAN replay after reset
RDMA/rxe: Fix seg fault in rxe_comp_queue_pkt
fbdev: sisfb: Fix strbuf array overflow
driver core: bus: Return -EIO instead of 0 when show/store invalid bus attribute
tools/iio: Add memory allocation failure check for trigger_name
virtio_pmem: Check device status before requesting flush
usb: dwc2: Adjust the timing of USB Driver Interrupt Registration in the Crashkernel Scenario
usb: chipidea: udc: enable suspend interrupt after usb reset
media: videobuf2-core: clear memory related fields in __vb2_plane_dmabuf_put()
ntb: ntb_hw_switchtec: Fix use after free vulnerability in switchtec_ntb_remove due to race condition
PCI: Mark Creative Labs EMU20k2 INTx masking as broken
i2c: i801: Use a different adapter-name for IDF adapters
PCI: Add ACS quirk for Qualcomm SA8775P
clk: bcm: bcm53573: fix OF node leak in init
ktest.pl: Avoid false positives with grub2 skip regex
s390/cpum_sf: Remove WARN_ON_ONCE statements
ext4: nested locking for xattr inode
s390/mm: Add cond_resched() to cmm_alloc/free_pages()
s390/facility: Disable compile time optimization for decompressor code
bpf: Check percpu map value size first
Input: synaptics-rmi4 - fix UAF of IRQ domain on driver removal
virtio_console: fix misc probe bugs
tracing: Have saved_cmdlines arrays all in one allocation
drm/crtc: fix uninitialized variable use even harder
tracing: Remove precision vsnprintf() check from print event
net: ethernet: cortina: Drop TSO support
unicode: Don't special case ignorable code points
ext4: fix inode tree inconsistency caused by ENOMEM
ACPI: battery: Fix possible crash when unregistering a battery hook
ACPI: battery: Simplify battery hook locking
r8169: add tally counter fields added with RTL8125
r8169: Fix spelling mistake: "tx_underun" -> "tx_underrun"
clk: qcom: clk-rpmh: Fix overflow in BCM vote
clk: qcom: rpmh: Simplify clk_rpmh_bcm_send_cmd()
nfsd: fix delegation_blocked() to block correctly for at least 30 seconds
nfsd: use ktime_get_seconds() for timestamps
uprobes: fix kernel info leak via "[uprobes]" vma
arm64: errata: Expand speculative SSBS workaround once more
arm64: cputype: Add Neoverse-N3 definitions
arm64: Add Cortex-715 CPU part definition
i2c: qcom-geni: Use IRQF_NO_AUTOEN flag in request_irq()
i2c: qcom-geni: Grow a dev pointer to simplify code
i2c: qcom-geni: Let firmware specify irq trigger flags
gpio: davinci: fix lazy disable
btrfs: wait for fixup workers before stopping cleaner kthread during umount
btrfs: fix a NULL pointer dereference when failed to start a new trasacntion
ACPI: resource: Add Asus ExpertBook B2502CVA to irq1_level_low_skip_override[]
ACPI: resource: Add Asus Vivobook X1704VAP to irq1_level_low_skip_override[]
Input: adp5589-keys - fix adp5589_gpio_get_value()
rtc: at91sam9: fix OF node leak in probe() error path
tomoyo: fallback to realpath if symlink's pathname does not exist
iio: magnetometer: ak8975: Fix reading for ak099xx sensors
media: venus: fix use after free bug in venus_remove due to race condition
media: uapi/linux/cec.h: cec_msg_set_reply_to: zero flags
media: sun4i_csi: Implement link validate for sun4i_csi subdev
clk: rockchip: fix error for unknown clocks
aoe: fix the potential use-after-free problem in more places
riscv: define ILLEGAL_POINTER_VALUE for 64bit
ocfs2: fix possible null-ptr-deref in ocfs2_set_buffer_uptodate
ocfs2: fix null-ptr-deref when journal load failed.
ocfs2: remove unreasonable unlock in ocfs2_read_blocks
ocfs2: cancel dqi_sync_work before freeing oinfo
ocfs2: reserve space for inline xattr before attaching reflink tree
ocfs2: fix uninit-value in ocfs2_get_block()
ocfs2: fix the la space leak when unmounting an ocfs2 volume
mm: krealloc: consider spare memory for __GFP_ZERO
jbd2: stop waiting for space when jbd2_cleanup_journal_tail() returns error
drm: omapdrm: Add missing check for alloc_ordered_workqueue
of/irq: Support #msi-cells=<0> in of_msi_get_domain
parisc: Fix stack start for ADDR_NO_RANDOMIZE personality
parisc: Fix 64-bit userspace syscall path
ext4: fix incorrect tid assumption in ext4_wait_for_tail_page_commit()
ext4: fix double brelse() the buffer of the extents path
ext4: aovid use-after-free in ext4_ext_insert_extent()
ext4: fix incorrect tid assumption in __jbd2_log_wait_for_space()
ext4: propagate errors from ext4_find_extent() in ext4_insert_range()
ext4: no need to continue when the number of entries is 1
ALSA: core: add isascii() check to card ID generator
drm: Consistently use struct drm_mode_rect for FB_DAMAGE_CLIPS
parisc: Fix itlb miss handler for 64-bit programs
perf/core: Fix small negative period being ignored
spi: bcm63xx: Fix module autoloading
firmware: tegra: bpmp: Drop unused mbox_client_to_bpmp()
i2c: xiic: Wait for TX empty to avoid missed TX NAKs
i2c: stm32f7: Do not prepare/unprepare clock during runtime suspend/resume
selftests: vDSO: fix vDSO symbols lookup for powerpc64
selftests: breakpoints: use remaining time to check if suspend succeed
spi: s3c64xx: fix timeout counters in flush_fifo
ext4: fix i_data_sem unlock order in ext4_ind_migrate()
ext4: ext4_search_dir should return a proper error
of/irq: Refer to actual buffer size in of_irq_parse_one()
drm/radeon/r100: Handle unknown family in r100_cp_init_microcode()
scsi: aacraid: Rearrange order of struct aac_srb_unit
drm/printer: Allow NULL data in devcoredump printer
drm/amd/display: Initialize get_bytes_per_element's default to 1
drm/amd/display: Fix index out of bounds in degamma hardware format translation
drm/amd/display: Check stream before comparing them
jfs: Fix uninit-value access of new_ea in ea_buffer
jfs: check if leafidx greater than num leaves per dmap tree
jfs: Fix uaf in dbFreeBits
jfs: UBSAN: shift-out-of-bounds in dbFindBits
ata: sata_sil: Rename sil_blacklist to sil_quirks
power: reset: brcmstb: Do not go into infinite loop if reset fails
fbdev: pxafb: Fix possible use after free in pxafb_task()
x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments()
ALSA: hdsp: Break infinite MIDI input flush loop
ALSA: asihpi: Fix potential OOB array access
signal: Replace BUG_ON()s
nfp: Use IRQF_NO_AUTOEN flag in request_irq()
wifi: mwifiex: Fix memcpy() field-spanning write warning in mwifiex_cmd_802_11_scan_ext()
proc: add config & param to block forcing mem writes
ACPICA: iasl: handle empty connection_node
tcp: avoid reusing FIN_WAIT2 when trying to find port in connect() process
ipv4: Mask upper DSCP bits and ECN bits in NETLINK_FIB_LOOKUP family
ipv4: Check !in_dev earlier for ioctl(SIOCSIFADDR).
net: mvpp2: Increase size of queue_name buffer
tipc: guard against string buffer overrun
ACPICA: check null return of ACPI_ALLOCATE_ZEROED() in acpi_db_convert_to_package()
ACPI: EC: Do not release locks during operation region accesses
wifi: rtw88: select WANT_DEV_COREDUMP
net: sched: consistently use rcu_replace_pointer() in taprio_change()
ACPICA: Fix memory leak if acpi_ps_get_next_field() fails
ACPICA: Fix memory leak if acpi_ps_get_next_namepath() fails
net: hisilicon: hns_mdio: fix OF node leak in probe()
net: hisilicon: hns_dsaf_mac: fix OF node leak in hns_mac_get_info()
net: hisilicon: hip04: fix OF node leak in probe()
ice: Adjust over allocation of memory in ice_sched_add_root_node() and ice_sched_add_node()
wifi: ath9k_htc: Use __skb_set_length() for resetting urb before resubmit
wifi: ath9k: fix possible integer overflow in ath9k_get_et_stats()
f2fs: Require FMODE_WRITE for atomic write ioctls
ALSA: hda/conexant: Fix conflicting quirk for System76 Pangolin
ALSA: hda/generic: Unconditionally prefer preferred_dacs pairs
ALSA: hda/realtek: Fix the push button function for the ALC257
sctp: set sk_state back to CLOSED if autobind fails in sctp_listen_start
ipv4: ip_gre: Fix drops of small packets in ipgre_xmit
net: add more sanity checks to qdisc_pkt_len_init()
net: avoid potential underflow in qdisc_pkt_len_init() with UFO
net: ethernet: lantiq_etop: fix memory disclosure
Bluetooth: btmrvl: Use IRQF_NO_AUTOEN flag in request_irq()
Bluetooth: btmrvl_sdio: Refactor irq wakeup
netfilter: nf_tables: prevent nf_skb_duplicated corruption
net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq()
netfilter: uapi: NFTA_FLOWTABLE_HOOK is NLA_NESTED
net/mlx5: Added cond_resched() to crdump collection
ieee802154: Fix build error
drivers: net: Fix Kconfig indentation, continued
Minor fixes to the CAIF Transport drivers Kconfig file
ceph: remove the incorrect Fw reference check when dirtying pages
mailbox: bcm2835: Fix timeout during suspend mode
mailbox: rockchip: fix a typo in module autoloading
usb: yurex: Fix inconsistent locking bug in yurex_read()
i2c: isch: Add missed 'else'
i2c: aspeed: Update the stop sw state when the bus recovery occurs
mm: only enforce minimum stack gap size if it's sensible
pps: add an error check in parport_attach
pps: remove usage of the deprecated ida_simple_xx() API
USB: misc: yurex: fix race between read and write
usb: yurex: Replace snprintf() with the safer scnprintf() variant
soc: versatile: realview: fix soc_dev leak during device remove
soc: versatile: realview: fix memory leak during device remove
PCI: xilinx-nwl: Fix off-by-one in INTx IRQ handler
PCI: xilinx-nwl: Use irq_data_get_irq_chip_data()
ASoC: meson: axg-card: fix 'use-after-free'
ASoC: meson: axg: extract sound card utils
nfs: fix memory leak in error path of nfs4_do_reclaim
fs: Fix file_set_fowner LSM hook inconsistencies
vfs: fix race between evice_inodes() and find_inode()&iput()
hwrng: mtk - Use devm_pm_runtime_enable
f2fs: avoid potential int overflow in sanity_check_area_boundary()
f2fs: prevent possible int overflow in dir_block_index()
debugobjects: Fix conditions in fill_pool()
wifi: rtw88: 8822c: Fix reported RX band width
ACPI: resource: Add another DMI match for the TongFang GMxXGxx
ACPI: sysfs: validate return type of _STR method
drbd: Add NULL check for net_conf to prevent dereference in state validation
drbd: Fix atomicity violation in drbd_uuid_set_bm()
tty: rp2: Fix reset with non forgiving PCIe host bridges
firmware_loader: Block path traversal
USB: class: CDC-ACM: fix race between get_serial and set_serial
USB: misc: cypress_cy7c63: check for short transfer
USB: appledisplay: close race between probe and completion handler
drm/amd/display: Round calculated vtotal
soc: versatile: integrator: fix OF node leak in probe() error path
Remove *.orig pattern from .gitignore
crypto: aead,cipher - zeroize key buffer after use
netfilter: ctnetlink: compile ctnetlink_label_size with CONFIG_NF_CONNTRACK_EVENTS
net: qrtr: Update packets cloning when broadcasting
tcp: check skb is non-NULL in tcp_rto_delta_us()
net: seeq: Fix use after free vulnerability in ether3 Driver Due to Race Condition
netfilter: nf_reject_ipv6: fix nf_reject_ip6_tcphdr_put()
coresight: tmc: sg: Do not leak sg_table
iio: adc: ad7606: fix standby gpio state to match the documentation
iio: adc: ad7606: fix oversampling gpio array
f2fs: reduce expensive checkpoint trigger frequency
f2fs: remove unneeded check condition in __f2fs_setxattr()
f2fs: fix to update i_ctime in __f2fs_setxattr()
f2fs: fix typo
f2fs: enhance to update i_mode and acl atomically in f2fs_setattr()
nfsd: return -EINVAL when namelen is 0
nfsd: call cache_put if xdr_reserve_space returns NULL
ntb: intel: Fix the NULL vs IS_ERR() bug for debugfs_create_dir()
RDMA/cxgb4: Added NULL check for lookup_atid
riscv: Fix fp alignment bug in perf_callchain_user()
RDMA/hns: Optimize hem allocation performance
watchdog: imx_sc_wdt: Don't disable WDT in suspend
pinctrl: mvebu: Fix devinit_dove_pinctrl_probe function
clk: ti: dra7-atl: Fix leak of of_nodes
pinctrl: single: fix missing error code in pcs_probe()
RDMA/iwcm: Fix WARNING:at_kernel/workqueue.c:#check_flush_dependency
PCI: xilinx-nwl: Fix register misspelling
PCI: keystone: Fix if-statement expression in ks_pcie_quirk()
drivers: media: dvb-frontends/rtl2830: fix an out-of-bounds write error
drivers: media: dvb-frontends/rtl2832: fix an out-of-bounds write error
clk: rockchip: Set parent rate for DCLK_VOP clock on RK3228
perf time-utils: Fix 32-bit nsec parsing
perf sched timehist: Fixed timestamp error when unable to confirm event sched_in time
perf sched timehist: Fix missing free of session in perf_sched__timehist()
bpf: Fix bpf_strtol and bpf_strtoul helpers for 32bit
nilfs2: fix potential oob read in nilfs_btree_check_delete()
nilfs2: determine empty node blocks as corrupted
nilfs2: fix potential null-ptr-deref in nilfs_btree_insert()
ext4: avoid OOB when system.data xattr changes underneath the filesystem
ext4: return error on ext4_find_inline_entry
ext4: avoid negative min_clusters in find_group_orlov()
smackfs: Use rcu_assign_pointer() to ensure safe assignment in smk_set_cipso
ext4: clear EXT4_GROUP_INFO_WAS_TRIMMED_BIT even mount with discard
jbd2: introduce/export functions jbd2_journal_submit|finish_inode_data_buffers()
kthread: fix task state in kthread worker if being frozen
kthread: add kthread_work tracepoints
xz: cleanup CRC32 edits from 2018
selftests/bpf: Fix error compiling test_lru_map.c
selftests/bpf: Fix compiling tcp_rtt.c with musl-libc
selftests/bpf: Fix compiling flow_dissector.c with musl-libc
selftests/bpf: Fix compile error from rlim_t in sk_storage_map.c
tpm: Clean up TPM space after command failure
xen/swiotlb: add alignment check for dma buffers
xen: use correct end address of kernel for conflict checking
drivers:drm:exynos_drm_gsc:Fix wrong assignment in gsc_bind()
drm/msm: fix %s null argument error
ipmi: docs: don't advertise deprecated sysfs entries
drm/msm/a5xx: fix races in preemption evaluation stage
drm/msm/a5xx: properly clear preemption records on resume
drm/msm/a5xx: disable preemption in submits by default
drm/msm: Fix incorrect file name output in adreno_request_fw()
jfs: fix out-of-bounds in dbNextAG() and diAlloc()
drm/radeon/evergreen_cs: fix int overflow errors in cs track offsets
drm/rockchip: dw_hdmi: Fix reading EDID when using a forced mode
drm/rockchip: vop: Allow 4096px width scaling
drm/radeon: properly handle vbios fake edid sizing
drm/radeon: Replace one-element array with flexible-array member
drm/amdgpu: properly handle vbios fake edid sizing
drm/amdgpu: Replace one-element array with flexible-array member
drm/stm: Fix an error handling path in stm_drm_platform_probe()
mtd: powernv: Add check devm_kasprintf() returned value
fbdev: hpfb: Fix an error handling path in hpfb_dio_probe()
power: supply: max17042_battery: Fix SOC threshold calc w/ no current sense
power: supply: axp20x_battery: Remove design from min and max voltage
power: supply: axp20x_battery: allow disabling battery charging
hwmon: (ntc_thermistor) fix module autoloading
mtd: slram: insert break after errors in parsing the map
hwmon: (max16065) Fix overflows seen when writing limits
clocksource/drivers/qcom: Add missing iounmap() on errors in msm_dt_timer_init()
reset: berlin: fix OF node leak in probe() error path
ARM: versatile: fix OF node leak in CPUs prepare
ARM: dts: imx7d-zii-rmu2: fix Ethernet PHY pinctrl property
spi: ppc4xx: Avoid returning 0 when failed to parse and map IRQ
spi: ppc4xx: handle irq_of_parse_and_map() errors
block, bfq: don't break merge chain in bfq_split_bfqq()
block, bfq: choose the last bfqq from merge chain in bfq_setup_cooperator()
block, bfq: fix possible UAF for bfqq->bic with merge chain
net: tipc: avoid possible garbage value
Bluetooth: btusb: Fix not handling ZPL/short-transfer
can: bcm: Clear bo->bcm_proc_read after remove_proc_entry().
sock_map: Add a cond_resched() in sock_hash_free()
wifi: wilc1000: fix potential RCU dereference issue in wilc_parse_join_bss_param
wifi: mac80211: use two-phase skb reclamation in ieee80211_do_stop()
mac80211: parse radiotap header when selecting Tx queue
wifi: cfg80211: fix two more possible UBSAN-detected off-by-one errors
wifi: cfg80211: fix UBSAN noise in cfg80211_wext_siwscan()
netfilter: nf_tables: reject expiration higher than timeout
netfilter: nf_tables: reject element expiration with no timeout
netfilter: nf_tables: elements with timeout below CONFIG_HZ never expire
can: j1939: use correct function name in comment
mount: handle OOM on mnt_warn_timestamp_expiry
fs/namespace: fnic: Switch to use %ptTd
mount: warn only once about timestamp range expiration
fs: explicitly unregister per-superblock BDIs
wifi: ath9k: Remove error checks when creating debugfs entries
wifi: ath9k: fix parameter check in ath9k_init_debug()
ACPI: PMIC: Remove unneeded check in tps68470_pmic_opregion_probe()
USB: usbtmc: prevent kernel-usb-infoleak
USB: serial: pl2303: add device id for Macrosilicon MS3020
bpf: Fix DEVMAP_HASH overflow check on 32-bit arches
inet: inet_defrag: prevent sk release while still in use
gpio: prevent potential speculation leaks in gpio_device_get_desc()
ocfs2: strict bound check before memcmp in ocfs2_xattr_find_entry()
ocfs2: add bounds checking to ocfs2_xattr_find_entry()
x86/hyperv: Set X86_FEATURE_TSC_KNOWN_FREQ when Hyper-V provides frequency
spi: bcm63xx: Enable module autoloading
drm: komeda: Fix an issue related to normalized zpos
ASoC: tda7419: fix module autoloading
wifi: iwlwifi: mvm: don't wait for tx queues if firmware is dead
wifi: iwlwifi: mvm: fix iwl_mvm_max_scan_ie_fw_cmd_room()
net: ftgmac100: Ensure tx descriptor updates are visible
microblaze: don't treat zero reserved memory regions as error
pinctrl: at91: make it work with current gpiolib
ALSA: hda/realtek - FIxed ALC285 headphone no sound
ALSA: hda/realtek - Fixed ALC256 headphone no sound
ASoC: allow module autoloading for table db1200_pids
selftests: breakpoints: Fix a typo of function name
soundwire: stream: Revert "soundwire: stream: fix programming slave ports for non-continous port maps"
spi: nxp-fspi: fix the KASAN report out-of-bounds bug
net: dpaa: Pad packets to ETH_ZLEN
net: ftgmac100: Enable TX interrupt to avoid TX timeout
net/mlx5e: Add missing link modes to ptys2ethtool_map
ice: fix accounting for filters shared by multiple VSIs
arm64: dts: rockchip: override BIOS_DISABLE signal via GPIO hog on RK3399 Puma
scripts: kconfig: merge_config: config files: add a trailing newline
net: phy: vitesse: repair vsc73xx autonegotiation
net: ethernet: use ip_hdrlen() instead of bit shift
usbnet: ipheth: fix carrier detection in modes 1 and 4
UPSTREAM: unicode: Don't special case ignorable code points
ANDROID: 16K: Fixup padding vm_flags bits on VMA splits
ANDROID: 16K: Introduce pgsize_migration_inline.h
Revert "clocksource/drivers/timer-of: Remove percpu irq related code"
Linux 5.4.284
Revert "parisc: Use irq_enter_rcu() to fix warning at kernel/context_tracking.c:367"
cx82310_eth: fix error return code in cx82310_bind()
net, sunrpc: Remap EPERM in case of connection failure in xs_tcp_setup_socket
rtmutex: Drop rt_mutex::wait_lock before scheduling
drm/i915/fence: Mark debug_fence_free() with __maybe_unused
drm/i915/fence: Mark debug_fence_init_onstack() with __maybe_unused
nvmet-tcp: fix kernel crash if commands allocation fails
arm64: acpi: Harden get_cpu_for_acpi_id() against missing CPU entry
arm64: acpi: Move get_cpu_for_acpi_id() to a header
ACPI: processor: Fix memory leaks in error paths of processor_add()
ACPI: processor: Return an error if acpi_processor_get_info() fails in processor_add()
nilfs2: protect references to superblock parameters exposed in sysfs
nilfs2: replace snprintf in show functions with sysfs_emit
tracing: Avoid possible softlockup in tracing_iter_reset()
ring-buffer: Rename ring_buffer_read() to read_buffer_iter_advance()
uprobes: Use kzalloc to allocate xol area
clocksource/drivers/timer-of: Remove percpu irq related code
clocksource/drivers/imx-tpm: Fix next event not taking effect sometime
clocksource/drivers/imx-tpm: Fix return -ETIME when delta exceeds INT_MAX
VMCI: Fix use-after-free when removing resource in vmci_resource_remove()
Drivers: hv: vmbus: Fix rescind handling in uio_hv_generic
uio_hv_generic: Fix kernel NULL pointer dereference in hv_uio_rescind
nvmem: Fix return type of devm_nvmem_device_get() in kerneldoc
binder: fix UAF caused by offsets overwrite
iio: fix scale application in iio_convert_raw_to_processed_unlocked
iio: buffer-dmaengine: fix releasing dma channel on error
staging: iio: frequency: ad9834: Validate frequency parameter value
NFSv4: Add missing rescheduling points in nfs_client_return_marked_delegations
ata: pata_macio: Use WARN instead of BUG
lib/generic-radix-tree.c: Fix rare race in __genradix_ptr_alloc()
of/irq: Prevent device address out-of-bounds read in interrupt map walk
Squashfs: sanity check symbolic link size
usbnet: ipheth: race between ipheth_close and error handling
Input: uinput - reject requests with unreasonable number of slots
HID: cougar: fix slab-out-of-bounds Read in cougar_report_fixup
btrfs: initialize location to fix -Wmaybe-uninitialized in btrfs_lookup_dentry()
PCI: Add missing bridge lock to pci_bus_lock()
btrfs: clean up our handling of refs == 0 in snapshot delete
btrfs: replace BUG_ON with ASSERT in walk_down_proc()
smp: Add missing destroy_work_on_stack() call in smp_call_on_cpu()
wifi: mwifiex: Do not return unused priv in mwifiex_get_priv_by_id()
libbpf: Add NULL checks to bpf_object__{prev_map,next_map}
hwmon: (w83627ehf) Fix underflows seen when writing limit attributes
hwmon: (nct6775-core) Fix underflows seen when writing limit attributes
hwmon: (lm95234) Fix underflows seen when writing limit attributes
hwmon: (adc128d818) Fix underflows seen when writing limit attributes
pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv
devres: Initialize an uninitialized struct member
um: line: always fill *error_out in setup_one_line()
cgroup: Protect css->cgroup write under css_set_lock
iommu/vt-d: Handle volatile descriptor status read
dm init: Handle minors larger than 255
ASoC: topology: Properly initialize soc_enum values
net: dsa: vsc73xx: fix possible subblocks range of CAPT block
net: bridge: br_fdb_external_learn_add(): always set EXT_LEARN
net: bridge: fdb: convert added_by_external_learn to use bitops
net: bridge: fdb: convert added_by_user to bitops
net: bridge: fdb: convert is_sticky to bitops
net: bridge: fdb: convert is_static to bitops
net: bridge: fdb: convert is_local to bitops
usbnet: modern method to get random MAC
net: usb: don't write directly to netdev->dev_addr
drivers/net/usb: Remove all strcpy() uses
cx82310_eth: re-enable ethernet mode after router reboot
tcp_bpf: fix return value of tcp_bpf_sendmsg()
platform/x86: dell-smbios: Fix error path in dell_smbios_init()
igb: Fix not clearing TimeSync interrupts for 82580
can: bcm: Remove proc entry when dev is unregistered.
pcmcia: Use resource_size function on resource object
media: qcom: camss: Add check for v4l2_fwnode_endpoint_parse
PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0)
usb: uas: set host status byte on data completion error
wifi: brcmsmac: advertise MFP_CAPABLE to enable WPA3
udf: Avoid excessive partition lengths
netfilter: nf_conncount: fix wrong variable type
af_unix: Remove put_pid()/put_cred() in copy_peercred().
irqchip/armada-370-xp: Do not allow mapping IRQ 0 and 1
smack: unix sockets: fix accept()ed socket label
ALSA: hda: Add input value sanity checks to HDMI channel map controls
nilfs2: fix state management in error path of log writing function
nilfs2: fix missing cleanup on rollforward recovery error
sched: sch_cake: fix bulk flow accounting logic for host fairness
ila: call nf_unregister_net_hooks() sooner
clk: qcom: clk-alpha-pll: Fix the trion pll postdiv set rate API
clk: qcom: clk-alpha-pll: Fix the pll post div mask
clk: hi6220: use CLK_OF_DECLARE_DRIVER
reset: hi6220: Add support for AO reset controller
fuse: use unsigned type for getxattr/listxattr size truncation
fuse: update stats for pages in dropped aux writeback list
mmc: sdhci-of-aspeed: fix module autoloading
mmc: dw_mmc: Fix IDMAC operation with pages bigger than 4K
irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init()
ata: libata: Fix memory leak for error path in ata_host_alloc()
ALSA: hda/conexant: Add pincfg quirk to enable top speakers on Sirius devices
ASoC: dapm: Fix UAF for snd_soc_pcm_runtime object
sch/netem: fix use after free in netem_dequeue
i2c: Use IS_REACHABLE() for substituting empty ACPI functions
udf: Limit file size to 4TB
virtio_net: Fix napi_skb_cache_put warning
net: set SOCK_RCU_FREE before inserting socket into hashtable
block: initialize integrity buffer to zero before writing it to media
media: uvcvideo: Enforce alignment of frame and interval
drm/amd/display: Skip wbscl_set_scaler_filter if filter is null
wifi: cfg80211: make hash table duplicates more survivable
smack: tcp: ipv4, fix incorrect labeling
usb: typec: ucsi: Fix null pointer dereference in trace
usbip: Don't submit special requests twice
ionic: fix potential irq name truncation
apparmor: fix possible NULL pointer dereference
drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device
drm/amdgpu: fix mc_data out-of-bounds read warning
drm/amdgpu: fix ucode out-of-bounds read warning
drm/amd/display: Fix Coverity INTEGER_OVERFLOW within dal_gpio_service_create
drm/amd/display: Check num_valid_sets before accessing reader_wm_sets[]
drm/amd/display: Stop amdgpu_dm initialize when stream nums greater than 6
drm/amd/display: Check gpio_id before used as array index
drm/amdgpu: fix overflowed array index read warning
drm/amdgpu: Fix uninitialized variable warning in amdgpu_afmt_acr
net: usb: qmi_wwan: add MeiG Smart SRM825L
i2c: Fix conditional for substituting empty ACPI functions
drm: panel-orientation-quirks: Add quirk for OrangePi Neo
Linux 5.4.283
scsi: aacraid: Fix double-free on probe failure
net: dsa: mv8e6xxx: Fix stub function parameters
usb: core: sysfs: Unmerge @usb3_hardware_lpm_attr_group in remove_power_attributes()
usb: dwc3: st: add missing depopulate in probe error path
usb: dwc3: st: fix probed platform device ref count on probe error path
usb: dwc3: core: Prevent USB core invalid event buffer address access
usb: dwc3: omap: add missing depopulate in probe error path
USB: serial: option: add MeiG Smart SRM825L
cdc-acm: Add DISABLE_ECHO quirk for GE HealthCare UI Controller
soc: qcom: cmd-db: Map shared memory as WC, not WB
nfc: pn533: Add poll mod list filling check
nfc: pn533: Add autopoll capability
nfc: pn533: Add dev_up/dev_down hooks to phy_ops
net: busy-poll: use ktime_get_ns() instead of local_clock()
gtp: fix a potential NULL pointer dereference
ethtool: check device is present when getting link settings
r8152: Factor out OOB link list waits
soundwire: stream: fix programming slave ports for non-continous port maps
net:rds: Fix possible deadlock in rds_message_put
cgroup/cpuset: Prevent UAF in proc_cpuset_show()
ata: libata-core: Fix null pointer dereference on error
media: uvcvideo: Fix integer overflow calculating timestamp
filelock: Correct the filelock owner in fcntl_setlk/fcntl_setlk64
drm/amdkfd: don't allow mapping the MMIO HDP page with large pages
ipc: replace costly bailout check in sysvipc_find_ipc()
wifi: mwifiex: duplicate static structs used in driver instances
pinctrl: single: fix potential NULL dereference in pcs_get_function()
drm/amdgpu: Using uninitialized value *size when calling amdgpu_vce_cs_reloc
tools: move alignment-related macros to new <linux/align.h>
Input: MT - limit max slots
Bluetooth: hci_ldisc: check HCI_UART_PROTO_READY flag in HCIUARTGETPROTO
ALSA: timer: Relax start tick time check for slave timer elements
mmc: dw_mmc: allow biu and ciu clocks to defer
cxgb4: add forgotten u64 ivlan cast before shift
HID: microsoft: Add rumble support to latest xbox controllers
HID: wacom: Defer calculation of resolution until resolution_code is known
Bluetooth: MGMT: Add error handling to pair_device()
mmc: mmc_test: Fix NULL dereference on allocation failure
drm/msm/dpu: don't play tricks with debug macros
drm/msm: use drm_debug_enabled() to check for debug categories
net: xilinx: axienet: Fix dangling multicast addresses
net: xilinx: axienet: Always disable promiscuous mode
ipv6: prevent UAF in ip6_send_skb()
netem: fix return value if duplicate enqueue fails
net: dsa: mv88e6xxx: Fix out-of-bound access
net: dsa: mv88e6xxx: replace ATU violation prints with trace points
net: dsa: mv88e6xxx: read FID when handling ATU violations
net: dsa: mv88e6xxx: global1_atu: Add helper for get next
net: dsa: mv88e6xxx: global2: Expose ATU stats register
netfilter: nft_counter: Synchronize nft_counter_reset() against reader.
kcm: Serialise kcm_sendmsg() for the same socket.
tc-testing: don't access non-existent variable on exception
Bluetooth: hci_core: Fix LE quote calculation
Bluetooth: hci_core: Fix not handling link timeouts propertly
Bluetooth: Make use of __check_timeout on hci_sched_le
dm suspend: return -ERESTARTSYS instead of -EINTR
dm: do not use waitqueue for request-based DM
dm mpath: pass IO start time to path selector
media: solo6x10: replace max(a, min(b, c)) by clamp(b, a, c)
block: use "unsigned long" for blk_validate_block_size().
gtp: pull network headers in gtp_dev_xmit()
hrtimer: Prevent queuing of hrtimer without a function callback
nvmet-rdma: fix possible bad dereference when freeing rsps
ext4: set the type of max_zeroout to unsigned int to avoid overflow
irqchip/gic-v3-its: Remove BUG_ON in its_vpe_irq_domain_alloc
usb: dwc3: core: Skip setting event buffers for host only controllers
s390/iucv: fix receive buffer virtual vs physical address confusion
openrisc: Call setup_memory() earlier in the init sequence
NFS: avoid infinite loop in pnfs_update_layout.
nvmet-tcp: do not continue for invalid icreq
Bluetooth: bnep: Fix out-of-bound access
nvme: clear caller pointer on identify failure
usb: gadget: fsl: Increase size of name buffer for endpoints
f2fs: fix to do sanity check in update_sit_entry
btrfs: delete pointless BUG_ON check on quota root in btrfs_qgroup_account_extent()
btrfs: send: handle unexpected data in header buffer in begin_cmd()
btrfs: handle invalid root reference found in may_destroy_subvol()
btrfs: change BUG_ON to assertion when checking for delayed_node root
powerpc/boot: Only free if realloc() succeeds
powerpc/boot: Handle allocation failure in simple_realloc()
parisc: Use irq_enter_rcu() to fix warning at kernel/context_tracking.c:367
x86: Increase brk randomness entropy for 64-bit systems
md: clean up invalid BUG_ON in md_ioctl
virtiofs: forbid newlines in tags
drm/lima: set gp bus_stop bit before hard reset
net/sun3_82586: Avoid reading past buffer in debug output
scsi: lpfc: Initialize status local variable in lpfc_sli4_repost_sgl_list()
fs: binfmt_elf_efpic: don't use missing interpreter's properties
media: pci: cx23885: check cx23885_vdev_init() return
quota: Remove BUG_ON from dqget()
ext4: do not trim the group with corrupted block bitmap
nvmet-trace: avoid dereferencing pointer too early
powerpc/xics: Check return value of kasprintf in icp_native_map_one_cpu
IB/hfi1: Fix potential deadlock on &irq_src_lock and &dd->uctxt_lock
wifi: iwlwifi: abort scan when rfkill on but device enabled
gfs2: setattr_chown: Add missing initialization
scsi: spi: Fix sshdr use
binfmt_misc: cleanup on filesystem umount
staging: ks7010: disable bh on tx_dev_lock
media: radio-isa: use dev_name to fill in bus_info
i2c: riic: avoid potential division by zero
wifi: cw1200: Avoid processing an invalid TIM IE
ssb: Fix division by zero issue in ssb_calc_clock_rate
ALSA: hda/realtek: Fix noise from speakers on Lenovo IdeaPad 3 15IAU7
net: hns3: fix a deadlock problem when config TC during resetting
net: dsa: vsc73xx: pass value in phy_write operation
net: axienet: Fix register defines comment description
net: axienet: Autodetect 64-bit DMA capability
net: axienet: Upgrade descriptors to hold 64-bit addresses
net: axienet: Wrap DMA pointer writes to prepare for 64 bit
net: axienet: Drop MDIO interrupt registers from ethtools dump
net: axienet: Check for DMA mapping errors
net: axienet: Factor out TX descriptor chain cleanup
net: axienet: Improve DMA error handling
net: axienet: Fix DMA descriptor cleanup path
atm: idt77252: prevent use after free in dequeue_rx()
net/mlx5e: Correctly report errors for ethtool rx flows
s390/uv: Panic for set and remove shared access UVC errors
btrfs: rename bitmap_set_bits() -> btrfs_bitmap_set_bits()
s390/cio: rename bitmap_size() -> idset_bitmap_size()
overflow: Implement size_t saturating arithmetic helpers
overflow.h: Add flex_array_size() helper
memcg_write_event_control(): fix a user-triggerable oops
drm/amdgpu: Actually check flags for all context ops.
selinux: fix potential counting error in avc_add_xperms_decision()
fix bitmap corruption on close_range() with CLOSE_RANGE_UNSHARE
bitmap: introduce generic optimized bitmap_size()
vfs: Don't evict inode under the inode lru traversing context
dm persistent data: fix memory allocation failure
dm resume: don't return EINVAL when signalled
arm64: ACPI: NUMA: initialize all values of acpi_early_node_map to NUMA_NO_NODE
s390/dasd: fix error recovery leading to data corruption on ESE devices
xhci: Fix Panther point NULL pointer deref at full-speed re-enumeration
ALSA: usb-audio: Support Yamaha P-125 quirk entry
fuse: Initialize beyond-EOF page contents before setting uptodate
Revert "genirq: Allow the PM device to originate from irq domain"
Revert "genirq: Allow irq_chip registration functions to take a const irq_chip"
Revert "irqchip/imx-irqsteer: Constify irq_chip struct"
Revert "irqchip/imx-irqsteer: Add runtime PM support"
Revert "irqchip/imx-irqsteer: Handle runtime power management correctly"
Linux 5.4.282
media: Revert "media: dvb-usb: Fix unexpected infinite loop in dvb_usb_read_remote_control()"
ARM: dts: imx6qdl-kontron-samx6i: fix phy-mode
nvme/pci: Add APST quirk for Lenovo N60z laptop
exec: Fix ToCToU between perm check and set-uid/gid usage
media: uvcvideo: Use entity get_cur in uvc_ctrl_set
arm64: cpufeature: Fix the visibility of compat hwcaps
drm/i915/gem: Fix Virtual Memory mapping boundaries calculation
netfilter: nf_tables: prefer nft_chain_validate
netfilter: nf_tables: use timestamp to check for set element timeout
netfilter: nf_tables: set element extended ACK reporting support
kbuild: Fix '-S -c' in x86 stack protector scripts
Fix gcc 4.9 build issue in 5.4.y
drm/mgag200: Set DDC timeout in milliseconds
drm/bridge: analogix_dp: properly handle zero sized AUX transactions
x86/mtrr: Check if fixed MTRRs exist before saving them
tracing: Fix overflow in get_free_elt()
power: supply: axp288_charger: Round constant_charge_voltage writes down
power: supply: axp288_charger: Fix constant_charge_voltage writes
genirq/irqdesc: Honor caller provided affinity in alloc_desc()
serial: core: check uartclk for zero to avoid divide by zero
scsi: mpt3sas: Avoid IOMMU page faults on REPORT ZONES
scsi: mpt3sas: Remove scsi_dma_map() error messages
ntp: Safeguard against time_constant overflow
driver core: Fix uevent_show() vs driver detach race
ntp: Clamp maxerror and esterror to operating range
tick/broadcast: Move per CPU pointer access into the atomic section
scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic
usb: gadget: core: Check for unset descriptor
USB: serial: debug: do not echo input by default
usb: vhci-hcd: Do not drop references before new references are gained
ALSA: hda/hdmi: Yet more pin fix for HP EliteDesk 800 G4
ALSA: hda: Add HP MP9 G4 Retail System AMS to force connect list
ALSA: line6: Fix racy access to midibuf
drm/client: fix null pointer dereference in drm_client_modeset_probe
spi: spi-fsl-lpspi: Fix scldiv calculation
spi: fsl-lpspi: remove unneeded array
bpf: kprobe: remove unused declaring of bpf_kprobe_override
i2c: smbus: Send alert notifications to all devices if source not found
i2c: smbus: Improve handling of stuck alerts
i2c: smbus: Don't filter out duplicate alerts
arm64: errata: Expand speculative SSBS workaround (again)
arm64: cputype: Add Cortex-A725 definitions
arm64: cputype: Add Cortex-X1C definitions
arm64: errata: Expand speculative SSBS workaround
arm64: errata: Unify speculative SSBS errata logic
arm64: cputype: Add Cortex-X925 definitions
arm64: cputype: Add Cortex-A720 definitions
arm64: cputype: Add Cortex-X3 definitions
arm64: errata: Add workaround for Arm errata 3194386 and 3312417
arm64: cputype: Add Neoverse-V3 definitions
arm64: cputype: Add Cortex-X4 definitions
arm64: Add Neoverse-V2 part
arm64: cpufeature: Force HWCAP to be based on the sysreg visible to user-space
ext4: fix wrong unit use in ext4_mb_find_by_goal
SUNRPC: Fix a race to wake a sync task
s390/sclp: Prevent release of buffer in I/O
jbd2: avoid memleak in jbd2_journal_write_metadata_buffer
media: uvcvideo: Fix the bandwdith quirk on USB 3.x
media: uvcvideo: Ignore empty TS packets
drm/amdgpu: Fix the null pointer dereference to ras_manager
btrfs: fix bitmap leak when loading free space cache on duplicate entry
wifi: nl80211: don't give key data to userspace
udf: prevent integer overflow in udf_bitmap_free_blocks()
PCI: Add Edimax Vendor ID to pci_ids.h
selftests/bpf: Fix send_signal test with nested CONFIG_PARAVIRT
ACPI: SBS: manage alarm sysfs attribute through psy core
ACPI: battery: create alarm sysfs attribute atomically
clocksource/drivers/sh_cmt: Address race condition for clock events
md/raid5: avoid BUG_ON() while continue reshape after reassembling
net: fec: Stop PPS on driver remove
Bluetooth: l2cap: always unlock channel in l2cap_conless_channel()
net: linkwatch: use system_unbound_wq
net: usb: qmi_wwan: fix memory leak for not ip packets
sctp: Fix null-ptr-deref in reuseport_add_sock().
sctp: move hlist_node and hashent out of sctp_ep_common
x86/mm: Fix pti_clone_pgtable() alignment assumption
irqchip/mbigen: Fix mbigen node address layout
genirq: Allow irq_chip registration functions to take a const irq_chip
netfilter: ipset: Add list flush to cancel_gc
net: usb: sr9700: fix uninitialized variable use in sr_mdio_read
ALSA: usb-audio: Correct surround channels in UAC1 channel map
protect the fetch of ->fd[fd] in do_dup2() from mispredictions
HID: wacom: Modify pen IDs
ipv6: fix ndisc_is_useropt() handling for PIO
net/mlx5e: Add a check for the return value from mlx5_port_set_eth_ptys
net/iucv: fix use after free in iucv_sock_close()
drm/vmwgfx: Fix overlay when using Screen Targets
drm/nouveau: prime: fix refcount underflow
remoteproc: imx_rproc: Skip over memory region when node value is NULL
remoteproc: imx_rproc: Fix ignoring mapping vdev regions
remoteproc: imx_rproc: ignore mapping vdev regions
irqchip/imx-irqsteer: Handle runtime power management correctly
irqchip/imx-irqsteer: Add runtime PM support
irqchip/imx-irqsteer: Constify irq_chip struct
genirq: Allow the PM device to originate from irq domain
devres: Fix memory leakage caused by driver API devm_free_percpu()
driver core: Cast to (void *) with __force for __percpu pointer
dev/parport: fix the array out-of-bounds risk
parport: Standardize use of printmode
parport: Convert printk(KERN_<LEVEL> to pr_<level>(
PCI: rockchip: Use GPIOD_OUT_LOW flag while requesting ep_gpio
PCI: rockchip: Make 'ep-gpios' DT property optional
mm: avoid overflows in dirty throttling logic
nvme-pci: add missing condition check for existence of mapped data
ASoC: Intel: use soc_intel_is_byt_cr() only when IOSF_MBI is reachable
ASoC: Intel: Move soc_intel_is_foo() helpers to a generic header
ASoC: Intel: Convert to new X86 CPU match macros
powerpc: fix a file leak in kvm_vcpu_ioctl_enable_cap()
apparmor: Fix null pointer deref when receiving skb during sock creation
mISDN: Fix a use after free in hfcmulti_tx()
bpf: Fix a segment issue when downgrading gso_size
net: nexthop: Initialize all fields in dumped nexthops
tipc: Return non-zero value from tipc_udp_addr2str() on error
net: bonding: correctly annotate RCU in bond_should_notify_peers()
ipv4: Fix incorrect source address in Record Route option
MIPS: SMP-CPS: Fix address for GCR_ACCESS register for CM3 and later
dma: fix call order in dmam_free_coherent
libbpf: Fix no-args func prototype BTF dumping syntax
um: time-travel: fix time-travel-start option
jfs: Fix array-index-out-of-bounds in diFree
kdb: Use the passed prompt in kdb_position_cursor()
kdb: address -Wformat-security warnings
nilfs2: handle inconsistent state in nilfs_btnode_create_block()
Bluetooth: btusb: Add Realtek RTL8852BE support ID 0x13d3:0x3591
Bluetooth: btusb: Add RTL8852BE device 0489:e125 to device tables
rbd: don't assume RBD_LOCK_STATE_LOCKED for exclusive mappings
rbd: rename RBD_LOCK_STATE_RELEASING and releasing_wait
drm/panfrost: Mark simple_ondemand governor as softdep
rbd: don't assume rbd_is_lock_owner() for exclusive mappings
selftests/sigaltstack: Fix ppc64 GCC build
RDMA/iwcm: Fix a use-after-free related to destroying CM IDs
platform: mips: cpu_hwmon: Disable driver on unsupported hardware
watchdog/perf: properly initialize the turbo mode timestamp and rearm counter
rtc: isl1208: Fix return value of nvmem callbacks
perf/x86/intel/pt: Fix a topa_entry base address calculation
perf/x86/intel/pt: Fix topa_entry base length
scsi: qla2xxx: validate nvme_local_port correctly
scsi: qla2xxx: Complete command early within lock
scsi: qla2xxx: Fix for possible memory corruption
scsi: qla2xxx: During vport delete send async logout explicitly
rtc: cmos: Fix return value of nvmem callbacks
kobject_uevent: Fix OOB access within zap_modalias_env()
decompress_bunzip2: fix rare decompression failure
ubi: eba: properly rollback inside self_check_eba
clk: davinci: da8xx-cfgchip: Initialize clk_init_data before use
f2fs: fix to don't dirty inode for readonly filesystem
scsi: qla2xxx: Return ENOBUFS if sg_cnt is more than one for ELS cmds
binder: fix hang of unregistered readers
PCI: hv: Return zero, not garbage, when reading PCI_INTERRUPT_PIN
hwrng: amd - Convert PCIBIOS_* return codes to errnos
tools/memory-model: Fix bug in lock.cat
leds: ss4200: Convert PCIBIOS_* return codes to errnos
wifi: mwifiex: Fix interface type change
ext4: make sure the first directory block is not a hole
ext4: check dot and dotdot of dx_root before making dir indexed
m68k: amiga: Turn off Warp1260 interrupts during boot
udf: Avoid using corrupted block bitmap buffer
drm/amd/display: Check for NULL pointer
drm/gma500: fix null pointer dereference in psb_intel_lvds_get_modes
drm/gma500: fix null pointer dereference in cdv_intel_lvds_get_modes
hfs: fix to initialize fields of hfs_inode_info after hfs_alloc_inode()
media: venus: fix use after free in vdec_close
char: tpm: Fix possible memory leak in tpm_bios_measurements_open()
ipv6: take care of scope when choosing the src addr
af_packet: Handle outgoing VLAN packets without hardware offloading
net: netconsole: Disable target before netpoll cleanup
tick/broadcast: Make takeover of broadcast hrtimer reliable
rtc: interface: Add RTC offset to alarm after fix-up
nilfs2: avoid undefined behavior in nilfs_cnt32_ge macro
fs/nilfs2: remove some unused macros to tame gcc
pinctrl: freescale: mxs: Fix refcount of child
pinctrl: ti: ti-iodelay: fix possible memory leak when pinctrl_enable() fails
pinctrl: ti: ti-iodelay: Drop if block with always false condition
pinctrl: single: fix possible memory leak when pinctrl_enable() fails
pinctrl: core: fix possible memory leak when pinctrl_enable() fails
netfilter: ctnetlink: use helper function to calculate expect ID
bnxt_re: Fix imm_data endianness
macintosh/therm_windtunnel: fix module unload.
powerpc/xmon: Fix disassembly CPU feature checks
MIPS: Octeron: remove source file executable bit
Input: elan_i2c - do not leave interrupt disabled on suspend failure
RDMA/device: Return error earlier if port in not valid
mtd: make mtd_test.c a separate module
ASoC: max98088: Check for clk_prepare_enable() error
RDMA/rxe: Don't set BTH_ACK_MASK for UC or UD QPs
RDMA/mlx4: Fix truncated output warning in alias_GUID.c
RDMA/mlx4: Fix truncated output warning in mad.c
Input: qt1050 - handle CHIP_ID reading error
PCI: Fix resource double counting on remove & rescan
SUNRPC: Fixup gss_status tracepoint error output
sparc64: Fix incorrect function signature and add prototype for prom_cif_init
ext4: avoid writing unitialized memory to disk in EA inodes
SUNRPC: avoid soft lockup when transmitting UDP to reachable server.
mfd: omap-usb-tll: Use struct_size to allocate tll
drm/qxl: Add check for drm_cvt_mode
drm/etnaviv: fix DMA direction handling for cached RW buffers
perf report: Fix condition in sort__sym_cmp()
leds: trigger: Unregister sysfs attributes before calling deactivate()
media: renesas: vsp1: Store RPF partition configuration per RPF instance
media: renesas: vsp1: Fix _irqsave and _irq mix
media: uvcvideo: Override default flags
media: uvcvideo: Allow entity-defined get_info and get_cur
saa7134: Unchecked i2c_transfer function result fixed
media: imon: Fix race getting ictx->lock
media: dvb-usb: Fix unexpected infinite loop in dvb_usb_read_remote_control()
USB: move snd_usb_pipe_sanity_check into the USB core
selftests: forwarding: devlink_lib: Wait for udev events after reloading
bna: adjust 'name' buf size of bna_tcb and bna_ccb structures
wifi: virt_wifi: don't use strlen() in const context
gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey
wifi: virt_wifi: avoid reporting connection success with wrong SSID
qed: Improve the stack space of filter_config()
perf: Prevent passing zero nr_pages to rb_alloc_aux()
perf: Fix perf_aux_size() for greater-than 32-bit size
perf/x86/intel/pt: Fix pt_topa_entry_for_page() address calculation
netfilter: nf_tables: rise cap on SELinux secmark context
ipvs: Avoid unnecessary calls to skb_is_gso_sctp
net: fec: Fix FEC_ECR_EN1588 being cleared on link-down
net: fec: Refactor: #define magic constants
wifi: cfg80211: handle 2x996 RU allocation in cfg80211_calculate_bitrate_he()
wifi: cfg80211: fix typo in cfg80211_calculate_bitrate_he()
mlxsw: spectrum_acl_erp: Fix object nesting warning
lib: objagg: Fix general protection fault
selftests/bpf: Check length of recv in test_sockmap
net/smc: set rmb's SG_MAX_SINGLE_ALLOC limitation only when CONFIG_ARCH_NO_SG_CHAIN is defined
net/smc: Allow SMC-D 1MB DMB allocations
wifi: brcmsmac: LCN PHY code is used for BCM4313 2G-only device
firmware: turris-mox-rwtm: Initialize completion before mailbox
firmware: turris-mox-rwtm: Fix checking return value of wait_for_completion_timeout()
m68k: cmpxchg: Fix return value for default case in __arch_xchg()
x86/xen: Convert comma to semicolon
m68k: atari: Fix TT bootup freeze / unexpected (SCU) interrupt messages
arm64: dts: amlogic: gx: correct hdmi clocks
arm64: dts: mediatek: mt7622: fix "emmc" pinctrl mux
ARM: dts: imx6qdl-kontron-samx6i: fix PCIe reset polarity
ARM: dts: imx6qdl-kontron-samx6i: fix board reset
ARM: dts: imx6qdl-kontron-samx6i: fix PHY reset
ARM: dts: imx6qdl-kontron-samx6i: move phy reset into phy-node
arm64: dts: rockchip: Increase VOP clk rate on RK3328
arm64: dts: qcom: msm8996: specify UFS core_clk frequencies
arm64: dts: qcom: sdm845: add power-domain to UFS PHY
hwmon: (max6697) Fix swapped temp{1,8} critical alarms
hwmon: (max6697) Fix underflow when writing limit attributes
pwm: stm32: Always do lazy disabling
hwmon: (adt7475) Fix default duty on fan is disabled
x86/platform/iosf_mbi: Convert PCIBIOS_* return codes to errnos
x86/pci/xen: Fix PCIBIOS_* return code handling
x86/pci/intel_mid_pci: Fix PCIBIOS_* return code handling
x86/of: Return consistent error type from x86_of_pci_irq_enable()
hfsplus: fix to avoid false alarm of circular locking
platform/chrome: cros_ec_debugfs: fix wrong EC message version
EDAC, i10nm: make skx_common.o a separate module
EDAC/skx_common: Add new ADXL components for 2-level memory
EDAC, skx: Retrieve and print retry_rd_err_log registers
EDAC, skx_common: Refactor so that we initialize "dev" in result of adxl decode.
Conflicts:
Documentation/devicetree/bindings
Documentation/devicetree/bindings/vendor-prefixes.yaml
drivers/clk/qcom/clk-rpmh.c
drivers/rpmsg/qcom_glink_native.c
drivers/soc/qcom/socinfo.c
drivers/usb/dwc3/core.c
fs/userfaultfd.c
mm/madvise.c
net/qrtr/qrtr.c
Change-Id: I5064cb8c11d2c104b445035a948867f10c88da1b
Signed-off-by: kamasali Satyanarayan <quic_kamasali@quicinc.com>
4626 lines
118 KiB
C
4626 lines
118 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* linux/kernel/signal.c
|
|
*
|
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
|
*
|
|
* 1997-11-02 Modified for POSIX.1b signals by Richard Henderson
|
|
*
|
|
* 2003-06-02 Jim Houston - Concurrent Computer Corp.
|
|
* Changes to use preallocated sigqueue structures
|
|
* to allow signals to be sent reliably.
|
|
*/
|
|
|
|
#include <linux/slab.h>
|
|
#include <linux/export.h>
|
|
#include <linux/init.h>
|
|
#include <linux/sched/mm.h>
|
|
#include <linux/sched/user.h>
|
|
#include <linux/sched/debug.h>
|
|
#include <linux/sched/task.h>
|
|
#include <linux/sched/task_stack.h>
|
|
#include <linux/sched/cputime.h>
|
|
#include <linux/file.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/tty.h>
|
|
#include <linux/binfmts.h>
|
|
#include <linux/coredump.h>
|
|
#include <linux/security.h>
|
|
#include <linux/syscalls.h>
|
|
#include <linux/ptrace.h>
|
|
#include <linux/signal.h>
|
|
#include <linux/signalfd.h>
|
|
#include <linux/ratelimit.h>
|
|
#include <linux/tracehook.h>
|
|
#include <linux/capability.h>
|
|
#include <linux/freezer.h>
|
|
#include <linux/pid_namespace.h>
|
|
#include <linux/nsproxy.h>
|
|
#include <linux/user_namespace.h>
|
|
#include <linux/uprobes.h>
|
|
#include <linux/compat.h>
|
|
#include <linux/cn_proc.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/posix-timers.h>
|
|
#include <linux/livepatch.h>
|
|
#include <linux/cgroup.h>
|
|
#include <linux/audit.h>
|
|
#include <linux/oom.h>
|
|
|
|
#define CREATE_TRACE_POINTS
|
|
#include <trace/events/signal.h>
|
|
|
|
#include <asm/param.h>
|
|
#include <linux/uaccess.h>
|
|
#include <asm/unistd.h>
|
|
#include <asm/siginfo.h>
|
|
#include <asm/cacheflush.h>
|
|
|
|
/*
|
|
* SLAB caches for signal bits.
|
|
*/
|
|
|
|
static struct kmem_cache *sigqueue_cachep;
|
|
|
|
int print_fatal_signals __read_mostly;
|
|
|
|
static void __user *sig_handler(struct task_struct *t, int sig)
|
|
{
|
|
return t->sighand->action[sig - 1].sa.sa_handler;
|
|
}
|
|
|
|
static inline bool sig_handler_ignored(void __user *handler, int sig)
|
|
{
|
|
/* Is it explicitly or implicitly ignored? */
|
|
return handler == SIG_IGN ||
|
|
(handler == SIG_DFL && sig_kernel_ignore(sig));
|
|
}
|
|
|
|
static bool sig_task_ignored(struct task_struct *t, int sig, bool force)
|
|
{
|
|
void __user *handler;
|
|
|
|
handler = sig_handler(t, sig);
|
|
|
|
/* SIGKILL and SIGSTOP may not be sent to the global init */
|
|
if (unlikely(is_global_init(t) && sig_kernel_only(sig)))
|
|
return true;
|
|
|
|
if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) &&
|
|
handler == SIG_DFL && !(force && sig_kernel_only(sig)))
|
|
return true;
|
|
|
|
/* Only allow kernel generated signals to this kthread */
|
|
if (unlikely((t->flags & PF_KTHREAD) &&
|
|
(handler == SIG_KTHREAD_KERNEL) && !force))
|
|
return true;
|
|
|
|
return sig_handler_ignored(handler, sig);
|
|
}
|
|
|
|
static bool sig_ignored(struct task_struct *t, int sig, bool force)
|
|
{
|
|
/*
|
|
* Blocked signals are never ignored, since the
|
|
* signal handler may change by the time it is
|
|
* unblocked.
|
|
*/
|
|
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
|
|
return false;
|
|
|
|
/*
|
|
* Tracers may want to know about even ignored signal unless it
|
|
* is SIGKILL which can't be reported anyway but can be ignored
|
|
* by SIGNAL_UNKILLABLE task.
|
|
*/
|
|
if (t->ptrace && sig != SIGKILL)
|
|
return false;
|
|
|
|
return sig_task_ignored(t, sig, force);
|
|
}
|
|
|
|
/*
|
|
* Re-calculate pending state from the set of locally pending
|
|
* signals, globally pending signals, and blocked signals.
|
|
*/
|
|
static inline bool has_pending_signals(sigset_t *signal, sigset_t *blocked)
|
|
{
|
|
unsigned long ready;
|
|
long i;
|
|
|
|
switch (_NSIG_WORDS) {
|
|
default:
|
|
for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;)
|
|
ready |= signal->sig[i] &~ blocked->sig[i];
|
|
break;
|
|
|
|
case 4: ready = signal->sig[3] &~ blocked->sig[3];
|
|
ready |= signal->sig[2] &~ blocked->sig[2];
|
|
ready |= signal->sig[1] &~ blocked->sig[1];
|
|
ready |= signal->sig[0] &~ blocked->sig[0];
|
|
break;
|
|
|
|
case 2: ready = signal->sig[1] &~ blocked->sig[1];
|
|
ready |= signal->sig[0] &~ blocked->sig[0];
|
|
break;
|
|
|
|
case 1: ready = signal->sig[0] &~ blocked->sig[0];
|
|
}
|
|
return ready != 0;
|
|
}
|
|
|
|
#define PENDING(p,b) has_pending_signals(&(p)->signal, (b))
|
|
|
|
static bool recalc_sigpending_tsk(struct task_struct *t)
|
|
{
|
|
if ((t->jobctl & (JOBCTL_PENDING_MASK | JOBCTL_TRAP_FREEZE)) ||
|
|
PENDING(&t->pending, &t->blocked) ||
|
|
PENDING(&t->signal->shared_pending, &t->blocked) ||
|
|
cgroup_task_frozen(t)) {
|
|
set_tsk_thread_flag(t, TIF_SIGPENDING);
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* We must never clear the flag in another thread, or in current
|
|
* when it's possible the current syscall is returning -ERESTART*.
|
|
* So we don't clear it here, and only callers who know they should do.
|
|
*/
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* After recalculating TIF_SIGPENDING, we need to make sure the task wakes up.
|
|
* This is superfluous when called on current, the wakeup is a harmless no-op.
|
|
*/
|
|
void recalc_sigpending_and_wake(struct task_struct *t)
|
|
{
|
|
if (recalc_sigpending_tsk(t))
|
|
signal_wake_up(t, 0);
|
|
}
|
|
|
|
void recalc_sigpending(void)
|
|
{
|
|
if (!recalc_sigpending_tsk(current) && !freezing(current) &&
|
|
!klp_patch_pending(current))
|
|
clear_thread_flag(TIF_SIGPENDING);
|
|
|
|
}
|
|
EXPORT_SYMBOL(recalc_sigpending);
|
|
|
|
void calculate_sigpending(void)
|
|
{
|
|
/* Have any signals or users of TIF_SIGPENDING been delayed
|
|
* until after fork?
|
|
*/
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
set_tsk_thread_flag(current, TIF_SIGPENDING);
|
|
recalc_sigpending();
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
}
|
|
|
|
/* Given the mask, find the first available signal that should be serviced. */
|
|
|
|
#define SYNCHRONOUS_MASK \
|
|
(sigmask(SIGSEGV) | sigmask(SIGBUS) | sigmask(SIGILL) | \
|
|
sigmask(SIGTRAP) | sigmask(SIGFPE) | sigmask(SIGSYS))
|
|
|
|
int next_signal(struct sigpending *pending, sigset_t *mask)
|
|
{
|
|
unsigned long i, *s, *m, x;
|
|
int sig = 0;
|
|
|
|
s = pending->signal.sig;
|
|
m = mask->sig;
|
|
|
|
/*
|
|
* Handle the first word specially: it contains the
|
|
* synchronous signals that need to be dequeued first.
|
|
*/
|
|
x = *s &~ *m;
|
|
if (x) {
|
|
if (x & SYNCHRONOUS_MASK)
|
|
x &= SYNCHRONOUS_MASK;
|
|
sig = ffz(~x) + 1;
|
|
return sig;
|
|
}
|
|
|
|
switch (_NSIG_WORDS) {
|
|
default:
|
|
for (i = 1; i < _NSIG_WORDS; ++i) {
|
|
x = *++s &~ *++m;
|
|
if (!x)
|
|
continue;
|
|
sig = ffz(~x) + i*_NSIG_BPW + 1;
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case 2:
|
|
x = s[1] &~ m[1];
|
|
if (!x)
|
|
break;
|
|
sig = ffz(~x) + _NSIG_BPW + 1;
|
|
break;
|
|
|
|
case 1:
|
|
/* Nothing to do */
|
|
break;
|
|
}
|
|
|
|
return sig;
|
|
}
|
|
|
|
static inline void print_dropped_signal(int sig)
|
|
{
|
|
static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 10);
|
|
|
|
if (!print_fatal_signals)
|
|
return;
|
|
|
|
if (!__ratelimit(&ratelimit_state))
|
|
return;
|
|
|
|
pr_info("%s/%d: reached RLIMIT_SIGPENDING, dropped signal %d\n",
|
|
current->comm, current->pid, sig);
|
|
}
|
|
|
|
/**
|
|
* task_set_jobctl_pending - set jobctl pending bits
|
|
* @task: target task
|
|
* @mask: pending bits to set
|
|
*
|
|
* Clear @mask from @task->jobctl. @mask must be subset of
|
|
* %JOBCTL_PENDING_MASK | %JOBCTL_STOP_CONSUME | %JOBCTL_STOP_SIGMASK |
|
|
* %JOBCTL_TRAPPING. If stop signo is being set, the existing signo is
|
|
* cleared. If @task is already being killed or exiting, this function
|
|
* becomes noop.
|
|
*
|
|
* CONTEXT:
|
|
* Must be called with @task->sighand->siglock held.
|
|
*
|
|
* RETURNS:
|
|
* %true if @mask is set, %false if made noop because @task was dying.
|
|
*/
|
|
bool task_set_jobctl_pending(struct task_struct *task, unsigned long mask)
|
|
{
|
|
BUG_ON(mask & ~(JOBCTL_PENDING_MASK | JOBCTL_STOP_CONSUME |
|
|
JOBCTL_STOP_SIGMASK | JOBCTL_TRAPPING));
|
|
BUG_ON((mask & JOBCTL_TRAPPING) && !(mask & JOBCTL_PENDING_MASK));
|
|
|
|
if (unlikely(fatal_signal_pending(task) || (task->flags & PF_EXITING)))
|
|
return false;
|
|
|
|
if (mask & JOBCTL_STOP_SIGMASK)
|
|
task->jobctl &= ~JOBCTL_STOP_SIGMASK;
|
|
|
|
task->jobctl |= mask;
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* task_clear_jobctl_trapping - clear jobctl trapping bit
|
|
* @task: target task
|
|
*
|
|
* If JOBCTL_TRAPPING is set, a ptracer is waiting for us to enter TRACED.
|
|
* Clear it and wake up the ptracer. Note that we don't need any further
|
|
* locking. @task->siglock guarantees that @task->parent points to the
|
|
* ptracer.
|
|
*
|
|
* CONTEXT:
|
|
* Must be called with @task->sighand->siglock held.
|
|
*/
|
|
void task_clear_jobctl_trapping(struct task_struct *task)
|
|
{
|
|
if (unlikely(task->jobctl & JOBCTL_TRAPPING)) {
|
|
task->jobctl &= ~JOBCTL_TRAPPING;
|
|
smp_mb(); /* advised by wake_up_bit() */
|
|
wake_up_bit(&task->jobctl, JOBCTL_TRAPPING_BIT);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* task_clear_jobctl_pending - clear jobctl pending bits
|
|
* @task: target task
|
|
* @mask: pending bits to clear
|
|
*
|
|
* Clear @mask from @task->jobctl. @mask must be subset of
|
|
* %JOBCTL_PENDING_MASK. If %JOBCTL_STOP_PENDING is being cleared, other
|
|
* STOP bits are cleared together.
|
|
*
|
|
* If clearing of @mask leaves no stop or trap pending, this function calls
|
|
* task_clear_jobctl_trapping().
|
|
*
|
|
* CONTEXT:
|
|
* Must be called with @task->sighand->siglock held.
|
|
*/
|
|
void task_clear_jobctl_pending(struct task_struct *task, unsigned long mask)
|
|
{
|
|
BUG_ON(mask & ~JOBCTL_PENDING_MASK);
|
|
|
|
if (mask & JOBCTL_STOP_PENDING)
|
|
mask |= JOBCTL_STOP_CONSUME | JOBCTL_STOP_DEQUEUED;
|
|
|
|
task->jobctl &= ~mask;
|
|
|
|
if (!(task->jobctl & JOBCTL_PENDING_MASK))
|
|
task_clear_jobctl_trapping(task);
|
|
}
|
|
|
|
/**
|
|
* task_participate_group_stop - participate in a group stop
|
|
* @task: task participating in a group stop
|
|
*
|
|
* @task has %JOBCTL_STOP_PENDING set and is participating in a group stop.
|
|
* Group stop states are cleared and the group stop count is consumed if
|
|
* %JOBCTL_STOP_CONSUME was set. If the consumption completes the group
|
|
* stop, the appropriate `SIGNAL_*` flags are set.
|
|
*
|
|
* CONTEXT:
|
|
* Must be called with @task->sighand->siglock held.
|
|
*
|
|
* RETURNS:
|
|
* %true if group stop completion should be notified to the parent, %false
|
|
* otherwise.
|
|
*/
|
|
static bool task_participate_group_stop(struct task_struct *task)
|
|
{
|
|
struct signal_struct *sig = task->signal;
|
|
bool consume = task->jobctl & JOBCTL_STOP_CONSUME;
|
|
|
|
WARN_ON_ONCE(!(task->jobctl & JOBCTL_STOP_PENDING));
|
|
|
|
task_clear_jobctl_pending(task, JOBCTL_STOP_PENDING);
|
|
|
|
if (!consume)
|
|
return false;
|
|
|
|
if (!WARN_ON_ONCE(sig->group_stop_count == 0))
|
|
sig->group_stop_count--;
|
|
|
|
/*
|
|
* Tell the caller to notify completion iff we are entering into a
|
|
* fresh group stop. Read comment in do_signal_stop() for details.
|
|
*/
|
|
if (!sig->group_stop_count && !(sig->flags & SIGNAL_STOP_STOPPED)) {
|
|
signal_set_stop_flags(sig, SIGNAL_STOP_STOPPED);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void task_join_group_stop(struct task_struct *task)
|
|
{
|
|
unsigned long mask = current->jobctl & JOBCTL_STOP_SIGMASK;
|
|
struct signal_struct *sig = current->signal;
|
|
|
|
if (sig->group_stop_count) {
|
|
sig->group_stop_count++;
|
|
mask |= JOBCTL_STOP_CONSUME;
|
|
} else if (!(sig->flags & SIGNAL_STOP_STOPPED))
|
|
return;
|
|
|
|
/* Have the new thread join an on-going signal group stop */
|
|
task_set_jobctl_pending(task, mask | JOBCTL_STOP_PENDING);
|
|
}
|
|
|
|
/*
|
|
* allocate a new signal queue record
|
|
* - this may be called without locks if and only if t == current, otherwise an
|
|
* appropriate lock must be held to stop the target task from exiting
|
|
*/
|
|
static struct sigqueue *
|
|
__sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimit)
|
|
{
|
|
struct sigqueue *q = NULL;
|
|
struct user_struct *user;
|
|
int sigpending;
|
|
|
|
/*
|
|
* Protect access to @t credentials. This can go away when all
|
|
* callers hold rcu read lock.
|
|
*
|
|
* NOTE! A pending signal will hold on to the user refcount,
|
|
* and we get/put the refcount only when the sigpending count
|
|
* changes from/to zero.
|
|
*/
|
|
rcu_read_lock();
|
|
user = __task_cred(t)->user;
|
|
sigpending = atomic_inc_return(&user->sigpending);
|
|
if (sigpending == 1)
|
|
get_uid(user);
|
|
rcu_read_unlock();
|
|
|
|
if (override_rlimit || likely(sigpending <= task_rlimit(t, RLIMIT_SIGPENDING))) {
|
|
q = kmem_cache_alloc(sigqueue_cachep, flags);
|
|
} else {
|
|
print_dropped_signal(sig);
|
|
}
|
|
|
|
if (unlikely(q == NULL)) {
|
|
if (atomic_dec_and_test(&user->sigpending))
|
|
free_uid(user);
|
|
} else {
|
|
INIT_LIST_HEAD(&q->list);
|
|
q->flags = 0;
|
|
q->user = user;
|
|
}
|
|
|
|
return q;
|
|
}
|
|
|
|
static void __sigqueue_free(struct sigqueue *q)
|
|
{
|
|
if (q->flags & SIGQUEUE_PREALLOC)
|
|
return;
|
|
if (atomic_dec_and_test(&q->user->sigpending))
|
|
free_uid(q->user);
|
|
kmem_cache_free(sigqueue_cachep, q);
|
|
}
|
|
|
|
void flush_sigqueue(struct sigpending *queue)
|
|
{
|
|
struct sigqueue *q;
|
|
|
|
sigemptyset(&queue->signal);
|
|
while (!list_empty(&queue->list)) {
|
|
q = list_entry(queue->list.next, struct sigqueue , list);
|
|
list_del_init(&q->list);
|
|
__sigqueue_free(q);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Flush all pending signals for this kthread.
|
|
*/
|
|
void flush_signals(struct task_struct *t)
|
|
{
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&t->sighand->siglock, flags);
|
|
clear_tsk_thread_flag(t, TIF_SIGPENDING);
|
|
flush_sigqueue(&t->pending);
|
|
flush_sigqueue(&t->signal->shared_pending);
|
|
spin_unlock_irqrestore(&t->sighand->siglock, flags);
|
|
}
|
|
EXPORT_SYMBOL(flush_signals);
|
|
|
|
#ifdef CONFIG_POSIX_TIMERS
|
|
static void __flush_itimer_signals(struct sigpending *pending)
|
|
{
|
|
sigset_t signal, retain;
|
|
struct sigqueue *q, *n;
|
|
|
|
signal = pending->signal;
|
|
sigemptyset(&retain);
|
|
|
|
list_for_each_entry_safe(q, n, &pending->list, list) {
|
|
int sig = q->info.si_signo;
|
|
|
|
if (likely(q->info.si_code != SI_TIMER)) {
|
|
sigaddset(&retain, sig);
|
|
} else {
|
|
sigdelset(&signal, sig);
|
|
list_del_init(&q->list);
|
|
__sigqueue_free(q);
|
|
}
|
|
}
|
|
|
|
sigorsets(&pending->signal, &signal, &retain);
|
|
}
|
|
|
|
void flush_itimer_signals(void)
|
|
{
|
|
struct task_struct *tsk = current;
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&tsk->sighand->siglock, flags);
|
|
__flush_itimer_signals(&tsk->pending);
|
|
__flush_itimer_signals(&tsk->signal->shared_pending);
|
|
spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
|
|
}
|
|
#endif
|
|
|
|
void ignore_signals(struct task_struct *t)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < _NSIG; ++i)
|
|
t->sighand->action[i].sa.sa_handler = SIG_IGN;
|
|
|
|
flush_signals(t);
|
|
}
|
|
|
|
/*
|
|
* Flush all handlers for a task.
|
|
*/
|
|
|
|
void
|
|
flush_signal_handlers(struct task_struct *t, int force_default)
|
|
{
|
|
int i;
|
|
struct k_sigaction *ka = &t->sighand->action[0];
|
|
for (i = _NSIG ; i != 0 ; i--) {
|
|
if (force_default || ka->sa.sa_handler != SIG_IGN)
|
|
ka->sa.sa_handler = SIG_DFL;
|
|
ka->sa.sa_flags = 0;
|
|
#ifdef __ARCH_HAS_SA_RESTORER
|
|
ka->sa.sa_restorer = NULL;
|
|
#endif
|
|
sigemptyset(&ka->sa.sa_mask);
|
|
ka++;
|
|
}
|
|
}
|
|
|
|
bool unhandled_signal(struct task_struct *tsk, int sig)
|
|
{
|
|
void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
|
|
if (is_global_init(tsk))
|
|
return true;
|
|
|
|
if (handler != SIG_IGN && handler != SIG_DFL)
|
|
return false;
|
|
|
|
/* if ptraced, let the tracer determine */
|
|
return !tsk->ptrace;
|
|
}
|
|
|
|
static void collect_signal(int sig, struct sigpending *list, kernel_siginfo_t *info,
|
|
bool *resched_timer)
|
|
{
|
|
struct sigqueue *q, *first = NULL;
|
|
|
|
/*
|
|
* Collect the siginfo appropriate to this signal. Check if
|
|
* there is another siginfo for the same signal.
|
|
*/
|
|
list_for_each_entry(q, &list->list, list) {
|
|
if (q->info.si_signo == sig) {
|
|
if (first)
|
|
goto still_pending;
|
|
first = q;
|
|
}
|
|
}
|
|
|
|
sigdelset(&list->signal, sig);
|
|
|
|
if (first) {
|
|
still_pending:
|
|
list_del_init(&first->list);
|
|
copy_siginfo(info, &first->info);
|
|
|
|
*resched_timer =
|
|
(first->flags & SIGQUEUE_PREALLOC) &&
|
|
(info->si_code == SI_TIMER) &&
|
|
(info->si_sys_private);
|
|
|
|
__sigqueue_free(first);
|
|
} else {
|
|
/*
|
|
* Ok, it wasn't in the queue. This must be
|
|
* a fast-pathed signal or we must have been
|
|
* out of queue space. So zero out the info.
|
|
*/
|
|
clear_siginfo(info);
|
|
info->si_signo = sig;
|
|
info->si_errno = 0;
|
|
info->si_code = SI_USER;
|
|
info->si_pid = 0;
|
|
info->si_uid = 0;
|
|
}
|
|
}
|
|
|
|
static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
|
|
kernel_siginfo_t *info, bool *resched_timer)
|
|
{
|
|
int sig = next_signal(pending, mask);
|
|
|
|
if (sig)
|
|
collect_signal(sig, pending, info, resched_timer);
|
|
return sig;
|
|
}
|
|
|
|
/*
|
|
* Dequeue a signal and return the element to the caller, which is
|
|
* expected to free it.
|
|
*
|
|
* All callers have to hold the siglock.
|
|
*/
|
|
int dequeue_signal(struct task_struct *tsk, sigset_t *mask, kernel_siginfo_t *info)
|
|
{
|
|
bool resched_timer = false;
|
|
int signr;
|
|
|
|
/* We only dequeue private signals from ourselves, we don't let
|
|
* signalfd steal them
|
|
*/
|
|
signr = __dequeue_signal(&tsk->pending, mask, info, &resched_timer);
|
|
if (!signr) {
|
|
signr = __dequeue_signal(&tsk->signal->shared_pending,
|
|
mask, info, &resched_timer);
|
|
#ifdef CONFIG_POSIX_TIMERS
|
|
/*
|
|
* itimer signal ?
|
|
*
|
|
* itimers are process shared and we restart periodic
|
|
* itimers in the signal delivery path to prevent DoS
|
|
* attacks in the high resolution timer case. This is
|
|
* compliant with the old way of self-restarting
|
|
* itimers, as the SIGALRM is a legacy signal and only
|
|
* queued once. Changing the restart behaviour to
|
|
* restart the timer in the signal dequeue path is
|
|
* reducing the timer noise on heavy loaded !highres
|
|
* systems too.
|
|
*/
|
|
if (unlikely(signr == SIGALRM)) {
|
|
struct hrtimer *tmr = &tsk->signal->real_timer;
|
|
|
|
if (!hrtimer_is_queued(tmr) &&
|
|
tsk->signal->it_real_incr != 0) {
|
|
hrtimer_forward(tmr, tmr->base->get_time(),
|
|
tsk->signal->it_real_incr);
|
|
hrtimer_restart(tmr);
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
recalc_sigpending();
|
|
if (!signr)
|
|
return 0;
|
|
|
|
if (unlikely(sig_kernel_stop(signr))) {
|
|
/*
|
|
* Set a marker that we have dequeued a stop signal. Our
|
|
* caller might release the siglock and then the pending
|
|
* stop signal it is about to process is no longer in the
|
|
* pending bitmasks, but must still be cleared by a SIGCONT
|
|
* (and overruled by a SIGKILL). So those cases clear this
|
|
* shared flag after we've set it. Note that this flag may
|
|
* remain set after the signal we return is ignored or
|
|
* handled. That doesn't matter because its only purpose
|
|
* is to alert stop-signal processing code when another
|
|
* processor has come along and cleared the flag.
|
|
*/
|
|
current->jobctl |= JOBCTL_STOP_DEQUEUED;
|
|
}
|
|
#ifdef CONFIG_POSIX_TIMERS
|
|
if (resched_timer) {
|
|
/*
|
|
* Release the siglock to ensure proper locking order
|
|
* of timer locks outside of siglocks. Note, we leave
|
|
* irqs disabled here, since the posix-timers code is
|
|
* about to disable them again anyway.
|
|
*/
|
|
spin_unlock(&tsk->sighand->siglock);
|
|
posixtimer_rearm(info);
|
|
spin_lock(&tsk->sighand->siglock);
|
|
|
|
/* Don't expose the si_sys_private value to userspace */
|
|
info->si_sys_private = 0;
|
|
}
|
|
#endif
|
|
return signr;
|
|
}
|
|
EXPORT_SYMBOL_GPL(dequeue_signal);
|
|
|
|
static int dequeue_synchronous_signal(kernel_siginfo_t *info)
|
|
{
|
|
struct task_struct *tsk = current;
|
|
struct sigpending *pending = &tsk->pending;
|
|
struct sigqueue *q, *sync = NULL;
|
|
|
|
/*
|
|
* Might a synchronous signal be in the queue?
|
|
*/
|
|
if (!((pending->signal.sig[0] & ~tsk->blocked.sig[0]) & SYNCHRONOUS_MASK))
|
|
return 0;
|
|
|
|
/*
|
|
* Return the first synchronous signal in the queue.
|
|
*/
|
|
list_for_each_entry(q, &pending->list, list) {
|
|
/* Synchronous signals have a postive si_code */
|
|
if ((q->info.si_code > SI_USER) &&
|
|
(sigmask(q->info.si_signo) & SYNCHRONOUS_MASK)) {
|
|
sync = q;
|
|
goto next;
|
|
}
|
|
}
|
|
return 0;
|
|
next:
|
|
/*
|
|
* Check if there is another siginfo for the same signal.
|
|
*/
|
|
list_for_each_entry_continue(q, &pending->list, list) {
|
|
if (q->info.si_signo == sync->info.si_signo)
|
|
goto still_pending;
|
|
}
|
|
|
|
sigdelset(&pending->signal, sync->info.si_signo);
|
|
recalc_sigpending();
|
|
still_pending:
|
|
list_del_init(&sync->list);
|
|
copy_siginfo(info, &sync->info);
|
|
__sigqueue_free(sync);
|
|
return info->si_signo;
|
|
}
|
|
|
|
/*
|
|
* Tell a process that it has a new active signal..
|
|
*
|
|
* NOTE! we rely on the previous spin_lock to
|
|
* lock interrupts for us! We can only be called with
|
|
* "siglock" held, and the local interrupt must
|
|
* have been disabled when that got acquired!
|
|
*
|
|
* No need to set need_resched since signal event passing
|
|
* goes through ->blocked
|
|
*/
|
|
void signal_wake_up_state(struct task_struct *t, unsigned int state)
|
|
{
|
|
set_tsk_thread_flag(t, TIF_SIGPENDING);
|
|
/*
|
|
* TASK_WAKEKILL also means wake it up in the stopped/traced/killable
|
|
* case. We don't check t->state here because there is a race with it
|
|
* executing another processor and just now entering stopped state.
|
|
* By using wake_up_state, we ensure the process will wake up and
|
|
* handle its death signal.
|
|
*/
|
|
if (!wake_up_state(t, state | TASK_INTERRUPTIBLE))
|
|
kick_process(t);
|
|
}
|
|
|
|
/*
|
|
* Remove signals in mask from the pending set and queue.
|
|
* Returns 1 if any signals were found.
|
|
*
|
|
* All callers must be holding the siglock.
|
|
*/
|
|
static void flush_sigqueue_mask(sigset_t *mask, struct sigpending *s)
|
|
{
|
|
struct sigqueue *q, *n;
|
|
sigset_t m;
|
|
|
|
sigandsets(&m, mask, &s->signal);
|
|
if (sigisemptyset(&m))
|
|
return;
|
|
|
|
sigandnsets(&s->signal, &s->signal, mask);
|
|
list_for_each_entry_safe(q, n, &s->list, list) {
|
|
if (sigismember(mask, q->info.si_signo)) {
|
|
list_del_init(&q->list);
|
|
__sigqueue_free(q);
|
|
}
|
|
}
|
|
}
|
|
|
|
static inline int is_si_special(const struct kernel_siginfo *info)
|
|
{
|
|
return info <= SEND_SIG_PRIV;
|
|
}
|
|
|
|
static inline bool si_fromuser(const struct kernel_siginfo *info)
|
|
{
|
|
return info == SEND_SIG_NOINFO ||
|
|
(!is_si_special(info) && SI_FROMUSER(info));
|
|
}
|
|
|
|
/*
|
|
* called with RCU read lock from check_kill_permission()
|
|
*/
|
|
static bool kill_ok_by_cred(struct task_struct *t)
|
|
{
|
|
const struct cred *cred = current_cred();
|
|
const struct cred *tcred = __task_cred(t);
|
|
|
|
return uid_eq(cred->euid, tcred->suid) ||
|
|
uid_eq(cred->euid, tcred->uid) ||
|
|
uid_eq(cred->uid, tcred->suid) ||
|
|
uid_eq(cred->uid, tcred->uid) ||
|
|
ns_capable(tcred->user_ns, CAP_KILL);
|
|
}
|
|
|
|
/*
|
|
* Bad permissions for sending the signal
|
|
* - the caller must hold the RCU read lock
|
|
*/
|
|
static int check_kill_permission(int sig, struct kernel_siginfo *info,
|
|
struct task_struct *t)
|
|
{
|
|
struct pid *sid;
|
|
int error;
|
|
|
|
if (!valid_signal(sig))
|
|
return -EINVAL;
|
|
|
|
if (!si_fromuser(info))
|
|
return 0;
|
|
|
|
error = audit_signal_info(sig, t); /* Let audit system see the signal */
|
|
if (error)
|
|
return error;
|
|
|
|
if (!same_thread_group(current, t) &&
|
|
!kill_ok_by_cred(t)) {
|
|
switch (sig) {
|
|
case SIGCONT:
|
|
sid = task_session(t);
|
|
/*
|
|
* We don't return the error if sid == NULL. The
|
|
* task was unhashed, the caller must notice this.
|
|
*/
|
|
if (!sid || sid == task_session(current))
|
|
break;
|
|
/* fall through */
|
|
default:
|
|
return -EPERM;
|
|
}
|
|
}
|
|
|
|
return security_task_kill(t, info, sig, NULL);
|
|
}
|
|
|
|
/**
|
|
* ptrace_trap_notify - schedule trap to notify ptracer
|
|
* @t: tracee wanting to notify tracer
|
|
*
|
|
* This function schedules sticky ptrace trap which is cleared on the next
|
|
* TRAP_STOP to notify ptracer of an event. @t must have been seized by
|
|
* ptracer.
|
|
*
|
|
* If @t is running, STOP trap will be taken. If trapped for STOP and
|
|
* ptracer is listening for events, tracee is woken up so that it can
|
|
* re-trap for the new event. If trapped otherwise, STOP trap will be
|
|
* eventually taken without returning to userland after the existing traps
|
|
* are finished by PTRACE_CONT.
|
|
*
|
|
* CONTEXT:
|
|
* Must be called with @task->sighand->siglock held.
|
|
*/
|
|
static void ptrace_trap_notify(struct task_struct *t)
|
|
{
|
|
WARN_ON_ONCE(!(t->ptrace & PT_SEIZED));
|
|
assert_spin_locked(&t->sighand->siglock);
|
|
|
|
task_set_jobctl_pending(t, JOBCTL_TRAP_NOTIFY);
|
|
ptrace_signal_wake_up(t, t->jobctl & JOBCTL_LISTENING);
|
|
}
|
|
|
|
/*
|
|
* Handle magic process-wide effects of stop/continue signals. Unlike
|
|
* the signal actions, these happen immediately at signal-generation
|
|
* time regardless of blocking, ignoring, or handling. This does the
|
|
* actual continuing for SIGCONT, but not the actual stopping for stop
|
|
* signals. The process stop is done as a signal action for SIG_DFL.
|
|
*
|
|
* Returns true if the signal should be actually delivered, otherwise
|
|
* it should be dropped.
|
|
*/
|
|
static bool prepare_signal(int sig, struct task_struct *p, bool force)
|
|
{
|
|
struct signal_struct *signal = p->signal;
|
|
struct task_struct *t;
|
|
sigset_t flush;
|
|
|
|
if (signal->flags & (SIGNAL_GROUP_EXIT | SIGNAL_GROUP_COREDUMP)) {
|
|
if (!(signal->flags & SIGNAL_GROUP_EXIT))
|
|
return sig == SIGKILL;
|
|
/*
|
|
* The process is in the middle of dying, nothing to do.
|
|
*/
|
|
} else if (sig_kernel_stop(sig)) {
|
|
/*
|
|
* This is a stop signal. Remove SIGCONT from all queues.
|
|
*/
|
|
siginitset(&flush, sigmask(SIGCONT));
|
|
flush_sigqueue_mask(&flush, &signal->shared_pending);
|
|
for_each_thread(p, t)
|
|
flush_sigqueue_mask(&flush, &t->pending);
|
|
} else if (sig == SIGCONT) {
|
|
unsigned int why;
|
|
/*
|
|
* Remove all stop signals from all queues, wake all threads.
|
|
*/
|
|
siginitset(&flush, SIG_KERNEL_STOP_MASK);
|
|
flush_sigqueue_mask(&flush, &signal->shared_pending);
|
|
for_each_thread(p, t) {
|
|
flush_sigqueue_mask(&flush, &t->pending);
|
|
task_clear_jobctl_pending(t, JOBCTL_STOP_PENDING);
|
|
if (likely(!(t->ptrace & PT_SEIZED)))
|
|
wake_up_state(t, __TASK_STOPPED);
|
|
else
|
|
ptrace_trap_notify(t);
|
|
}
|
|
|
|
/*
|
|
* Notify the parent with CLD_CONTINUED if we were stopped.
|
|
*
|
|
* If we were in the middle of a group stop, we pretend it
|
|
* was already finished, and then continued. Since SIGCHLD
|
|
* doesn't queue we report only CLD_STOPPED, as if the next
|
|
* CLD_CONTINUED was dropped.
|
|
*/
|
|
why = 0;
|
|
if (signal->flags & SIGNAL_STOP_STOPPED)
|
|
why |= SIGNAL_CLD_CONTINUED;
|
|
else if (signal->group_stop_count)
|
|
why |= SIGNAL_CLD_STOPPED;
|
|
|
|
if (why) {
|
|
/*
|
|
* The first thread which returns from do_signal_stop()
|
|
* will take ->siglock, notice SIGNAL_CLD_MASK, and
|
|
* notify its parent. See get_signal().
|
|
*/
|
|
signal_set_stop_flags(signal, why | SIGNAL_STOP_CONTINUED);
|
|
signal->group_stop_count = 0;
|
|
signal->group_exit_code = 0;
|
|
}
|
|
}
|
|
|
|
return !sig_ignored(p, sig, force);
|
|
}
|
|
|
|
/*
|
|
* Test if P wants to take SIG. After we've checked all threads with this,
|
|
* it's equivalent to finding no threads not blocking SIG. Any threads not
|
|
* blocking SIG were ruled out because they are not running and already
|
|
* have pending signals. Such threads will dequeue from the shared queue
|
|
* as soon as they're available, so putting the signal on the shared queue
|
|
* will be equivalent to sending it to one such thread.
|
|
*/
|
|
static inline bool wants_signal(int sig, struct task_struct *p)
|
|
{
|
|
if (sigismember(&p->blocked, sig))
|
|
return false;
|
|
|
|
if (p->flags & PF_EXITING)
|
|
return false;
|
|
|
|
if (sig == SIGKILL)
|
|
return true;
|
|
|
|
if (task_is_stopped_or_traced(p))
|
|
return false;
|
|
|
|
return task_curr(p) || !signal_pending(p);
|
|
}
|
|
|
|
static void complete_signal(int sig, struct task_struct *p, enum pid_type type)
|
|
{
|
|
struct signal_struct *signal = p->signal;
|
|
struct task_struct *t;
|
|
|
|
/*
|
|
* Now find a thread we can wake up to take the signal off the queue.
|
|
*
|
|
* If the main thread wants the signal, it gets first crack.
|
|
* Probably the least surprising to the average bear.
|
|
*/
|
|
if (wants_signal(sig, p))
|
|
t = p;
|
|
else if ((type == PIDTYPE_PID) || thread_group_empty(p))
|
|
/*
|
|
* There is just one thread and it does not need to be woken.
|
|
* It will dequeue unblocked signals before it runs again.
|
|
*/
|
|
return;
|
|
else {
|
|
/*
|
|
* Otherwise try to find a suitable thread.
|
|
*/
|
|
t = signal->curr_target;
|
|
while (!wants_signal(sig, t)) {
|
|
t = next_thread(t);
|
|
if (t == signal->curr_target)
|
|
/*
|
|
* No thread needs to be woken.
|
|
* Any eligible threads will see
|
|
* the signal in the queue soon.
|
|
*/
|
|
return;
|
|
}
|
|
signal->curr_target = t;
|
|
}
|
|
|
|
/*
|
|
* Found a killable thread. If the signal will be fatal,
|
|
* then start taking the whole group down immediately.
|
|
*/
|
|
if (sig_fatal(p, sig) &&
|
|
!(signal->flags & SIGNAL_GROUP_EXIT) &&
|
|
!sigismember(&t->real_blocked, sig) &&
|
|
(sig == SIGKILL || !p->ptrace)) {
|
|
/*
|
|
* This signal will be fatal to the whole group.
|
|
*/
|
|
if (!sig_kernel_coredump(sig)) {
|
|
/*
|
|
* Start a group exit and wake everybody up.
|
|
* This way we don't have other threads
|
|
* running and doing things after a slower
|
|
* thread has the fatal signal pending.
|
|
*/
|
|
signal->flags = SIGNAL_GROUP_EXIT;
|
|
signal->group_exit_code = sig;
|
|
signal->group_stop_count = 0;
|
|
t = p;
|
|
do {
|
|
task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
|
|
sigaddset(&t->pending.signal, SIGKILL);
|
|
signal_wake_up(t, 1);
|
|
} while_each_thread(p, t);
|
|
return;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* The signal is already in the shared-pending queue.
|
|
* Tell the chosen thread to wake up and dequeue it.
|
|
*/
|
|
signal_wake_up(t, sig == SIGKILL);
|
|
return;
|
|
}
|
|
|
|
static inline bool legacy_queue(struct sigpending *signals, int sig)
|
|
{
|
|
return (sig < SIGRTMIN) && sigismember(&signals->signal, sig);
|
|
}
|
|
|
|
static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struct *t,
|
|
enum pid_type type, bool force)
|
|
{
|
|
struct sigpending *pending;
|
|
struct sigqueue *q;
|
|
int override_rlimit;
|
|
int ret = 0, result;
|
|
|
|
assert_spin_locked(&t->sighand->siglock);
|
|
|
|
result = TRACE_SIGNAL_IGNORED;
|
|
if (!prepare_signal(sig, t, force))
|
|
goto ret;
|
|
|
|
pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending;
|
|
/*
|
|
* Short-circuit ignored signals and support queuing
|
|
* exactly one non-rt signal, so that we can get more
|
|
* detailed information about the cause of the signal.
|
|
*/
|
|
result = TRACE_SIGNAL_ALREADY_PENDING;
|
|
if (legacy_queue(pending, sig))
|
|
goto ret;
|
|
|
|
result = TRACE_SIGNAL_DELIVERED;
|
|
/*
|
|
* Skip useless siginfo allocation for SIGKILL and kernel threads.
|
|
*/
|
|
if ((sig == SIGKILL) || (t->flags & PF_KTHREAD))
|
|
goto out_set;
|
|
|
|
/*
|
|
* Real-time signals must be queued if sent by sigqueue, or
|
|
* some other real-time mechanism. It is implementation
|
|
* defined whether kill() does so. We attempt to do so, on
|
|
* the principle of least surprise, but since kill is not
|
|
* allowed to fail with EAGAIN when low on memory we just
|
|
* make sure at least one signal gets delivered and don't
|
|
* pass on the info struct.
|
|
*/
|
|
if (sig < SIGRTMIN)
|
|
override_rlimit = (is_si_special(info) || info->si_code >= 0);
|
|
else
|
|
override_rlimit = 0;
|
|
|
|
q = __sigqueue_alloc(sig, t, GFP_ATOMIC, override_rlimit);
|
|
if (q) {
|
|
list_add_tail(&q->list, &pending->list);
|
|
switch ((unsigned long) info) {
|
|
case (unsigned long) SEND_SIG_NOINFO:
|
|
clear_siginfo(&q->info);
|
|
q->info.si_signo = sig;
|
|
q->info.si_errno = 0;
|
|
q->info.si_code = SI_USER;
|
|
q->info.si_pid = task_tgid_nr_ns(current,
|
|
task_active_pid_ns(t));
|
|
rcu_read_lock();
|
|
q->info.si_uid =
|
|
from_kuid_munged(task_cred_xxx(t, user_ns),
|
|
current_uid());
|
|
rcu_read_unlock();
|
|
break;
|
|
case (unsigned long) SEND_SIG_PRIV:
|
|
clear_siginfo(&q->info);
|
|
q->info.si_signo = sig;
|
|
q->info.si_errno = 0;
|
|
q->info.si_code = SI_KERNEL;
|
|
q->info.si_pid = 0;
|
|
q->info.si_uid = 0;
|
|
break;
|
|
default:
|
|
copy_siginfo(&q->info, info);
|
|
break;
|
|
}
|
|
} else if (!is_si_special(info) &&
|
|
sig >= SIGRTMIN && info->si_code != SI_USER) {
|
|
/*
|
|
* Queue overflow, abort. We may abort if the
|
|
* signal was rt and sent by user using something
|
|
* other than kill().
|
|
*/
|
|
result = TRACE_SIGNAL_OVERFLOW_FAIL;
|
|
ret = -EAGAIN;
|
|
goto ret;
|
|
} else {
|
|
/*
|
|
* This is a silent loss of information. We still
|
|
* send the signal, but the *info bits are lost.
|
|
*/
|
|
result = TRACE_SIGNAL_LOSE_INFO;
|
|
}
|
|
|
|
out_set:
|
|
signalfd_notify(t, sig);
|
|
sigaddset(&pending->signal, sig);
|
|
|
|
/* Let multiprocess signals appear after on-going forks */
|
|
if (type > PIDTYPE_TGID) {
|
|
struct multiprocess_signals *delayed;
|
|
hlist_for_each_entry(delayed, &t->signal->multiprocess, node) {
|
|
sigset_t *signal = &delayed->signal;
|
|
/* Can't queue both a stop and a continue signal */
|
|
if (sig == SIGCONT)
|
|
sigdelsetmask(signal, SIG_KERNEL_STOP_MASK);
|
|
else if (sig_kernel_stop(sig))
|
|
sigdelset(signal, SIGCONT);
|
|
sigaddset(signal, sig);
|
|
}
|
|
}
|
|
|
|
complete_signal(sig, t, type);
|
|
ret:
|
|
trace_signal_generate(sig, info, t, type != PIDTYPE_PID, result);
|
|
return ret;
|
|
}
|
|
|
|
static inline bool has_si_pid_and_uid(struct kernel_siginfo *info)
|
|
{
|
|
bool ret = false;
|
|
switch (siginfo_layout(info->si_signo, info->si_code)) {
|
|
case SIL_KILL:
|
|
case SIL_CHLD:
|
|
case SIL_RT:
|
|
ret = true;
|
|
break;
|
|
case SIL_TIMER:
|
|
case SIL_POLL:
|
|
case SIL_FAULT:
|
|
case SIL_FAULT_MCEERR:
|
|
case SIL_FAULT_BNDERR:
|
|
case SIL_FAULT_PKUERR:
|
|
case SIL_SYS:
|
|
ret = false;
|
|
break;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static int send_signal(int sig, struct kernel_siginfo *info, struct task_struct *t,
|
|
enum pid_type type)
|
|
{
|
|
/* Should SIGKILL or SIGSTOP be received by a pid namespace init? */
|
|
bool force = false;
|
|
|
|
if (info == SEND_SIG_NOINFO) {
|
|
/* Force if sent from an ancestor pid namespace */
|
|
force = !task_pid_nr_ns(current, task_active_pid_ns(t));
|
|
} else if (info == SEND_SIG_PRIV) {
|
|
/* Don't ignore kernel generated signals */
|
|
force = true;
|
|
} else if (has_si_pid_and_uid(info)) {
|
|
/* SIGKILL and SIGSTOP is special or has ids */
|
|
struct user_namespace *t_user_ns;
|
|
|
|
rcu_read_lock();
|
|
t_user_ns = task_cred_xxx(t, user_ns);
|
|
if (current_user_ns() != t_user_ns) {
|
|
kuid_t uid = make_kuid(current_user_ns(), info->si_uid);
|
|
info->si_uid = from_kuid_munged(t_user_ns, uid);
|
|
}
|
|
rcu_read_unlock();
|
|
|
|
/* A kernel generated signal? */
|
|
force = (info->si_code == SI_KERNEL);
|
|
|
|
/* From an ancestor pid namespace? */
|
|
if (!task_pid_nr_ns(current, task_active_pid_ns(t))) {
|
|
info->si_pid = 0;
|
|
force = true;
|
|
}
|
|
}
|
|
return __send_signal(sig, info, t, type, force);
|
|
}
|
|
|
|
static void print_fatal_signal(int signr)
|
|
{
|
|
struct pt_regs *regs = signal_pt_regs();
|
|
pr_info("potentially unexpected fatal signal %d.\n", signr);
|
|
|
|
#if defined(__i386__) && !defined(__arch_um__)
|
|
pr_info("code at %08lx: ", regs->ip);
|
|
{
|
|
int i;
|
|
for (i = 0; i < 16; i++) {
|
|
unsigned char insn;
|
|
|
|
if (get_user(insn, (unsigned char *)(regs->ip + i)))
|
|
break;
|
|
pr_cont("%02x ", insn);
|
|
}
|
|
}
|
|
pr_cont("\n");
|
|
#endif
|
|
preempt_disable();
|
|
show_regs(regs);
|
|
preempt_enable();
|
|
}
|
|
|
|
static int __init setup_print_fatal_signals(char *str)
|
|
{
|
|
get_option (&str, &print_fatal_signals);
|
|
|
|
return 1;
|
|
}
|
|
|
|
__setup("print-fatal-signals=", setup_print_fatal_signals);
|
|
|
|
int
|
|
__group_send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p)
|
|
{
|
|
return send_signal(sig, info, p, PIDTYPE_TGID);
|
|
}
|
|
|
|
int do_send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p,
|
|
enum pid_type type)
|
|
{
|
|
unsigned long flags;
|
|
int ret = -ESRCH;
|
|
|
|
if (lock_task_sighand(p, &flags)) {
|
|
ret = send_signal(sig, info, p, type);
|
|
unlock_task_sighand(p, &flags);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Force a signal that the process can't ignore: if necessary
|
|
* we unblock the signal and change any SIG_IGN to SIG_DFL.
|
|
*
|
|
* Note: If we unblock the signal, we always reset it to SIG_DFL,
|
|
* since we do not want to have a signal handler that was blocked
|
|
* be invoked when user space had explicitly blocked it.
|
|
*
|
|
* We don't want to have recursive SIGSEGV's etc, for example,
|
|
* that is why we also clear SIGNAL_UNKILLABLE.
|
|
*/
|
|
static int
|
|
force_sig_info_to_task(struct kernel_siginfo *info, struct task_struct *t)
|
|
{
|
|
unsigned long int flags;
|
|
int ret, blocked, ignored;
|
|
struct k_sigaction *action;
|
|
int sig = info->si_signo;
|
|
|
|
spin_lock_irqsave(&t->sighand->siglock, flags);
|
|
action = &t->sighand->action[sig-1];
|
|
ignored = action->sa.sa_handler == SIG_IGN;
|
|
blocked = sigismember(&t->blocked, sig);
|
|
if (blocked || ignored) {
|
|
action->sa.sa_handler = SIG_DFL;
|
|
if (blocked) {
|
|
sigdelset(&t->blocked, sig);
|
|
recalc_sigpending_and_wake(t);
|
|
}
|
|
}
|
|
/*
|
|
* Don't clear SIGNAL_UNKILLABLE for traced tasks, users won't expect
|
|
* debugging to leave init killable.
|
|
*/
|
|
if (action->sa.sa_handler == SIG_DFL && !t->ptrace)
|
|
t->signal->flags &= ~SIGNAL_UNKILLABLE;
|
|
ret = send_signal(sig, info, t, PIDTYPE_PID);
|
|
spin_unlock_irqrestore(&t->sighand->siglock, flags);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int force_sig_info(struct kernel_siginfo *info)
|
|
{
|
|
return force_sig_info_to_task(info, current);
|
|
}
|
|
|
|
/*
|
|
* Nuke all other threads in the group.
|
|
*/
|
|
int zap_other_threads(struct task_struct *p)
|
|
{
|
|
struct task_struct *t = p;
|
|
int count = 0;
|
|
|
|
p->signal->group_stop_count = 0;
|
|
|
|
while_each_thread(p, t) {
|
|
task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
|
|
count++;
|
|
|
|
/* Don't bother with already dead threads */
|
|
if (t->exit_state)
|
|
continue;
|
|
sigaddset(&t->pending.signal, SIGKILL);
|
|
signal_wake_up(t, 1);
|
|
}
|
|
|
|
return count;
|
|
}
|
|
|
|
struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
|
|
unsigned long *flags)
|
|
{
|
|
struct sighand_struct *sighand;
|
|
|
|
rcu_read_lock();
|
|
for (;;) {
|
|
sighand = rcu_dereference(tsk->sighand);
|
|
if (unlikely(sighand == NULL))
|
|
break;
|
|
|
|
/*
|
|
* This sighand can be already freed and even reused, but
|
|
* we rely on SLAB_TYPESAFE_BY_RCU and sighand_ctor() which
|
|
* initializes ->siglock: this slab can't go away, it has
|
|
* the same object type, ->siglock can't be reinitialized.
|
|
*
|
|
* We need to ensure that tsk->sighand is still the same
|
|
* after we take the lock, we can race with de_thread() or
|
|
* __exit_signal(). In the latter case the next iteration
|
|
* must see ->sighand == NULL.
|
|
*/
|
|
spin_lock_irqsave(&sighand->siglock, *flags);
|
|
if (likely(sighand == tsk->sighand))
|
|
break;
|
|
spin_unlock_irqrestore(&sighand->siglock, *flags);
|
|
}
|
|
rcu_read_unlock();
|
|
|
|
return sighand;
|
|
}
|
|
EXPORT_SYMBOL_GPL(__lock_task_sighand);
|
|
|
|
/*
|
|
* send signal info to all the members of a group
|
|
*/
|
|
int group_send_sig_info(int sig, struct kernel_siginfo *info,
|
|
struct task_struct *p, enum pid_type type)
|
|
{
|
|
int ret;
|
|
|
|
rcu_read_lock();
|
|
ret = check_kill_permission(sig, info, p);
|
|
rcu_read_unlock();
|
|
|
|
if (!ret && sig) {
|
|
check_panic_on_foreground_kill(p);
|
|
ret = do_send_sig_info(sig, info, p, type);
|
|
if (capable(CAP_KILL) && sig == SIGKILL)
|
|
if (!strcmp(current->comm, ULMK_MAGIC) ||
|
|
!strcmp(current->comm, PRE_KILL))
|
|
add_to_oom_reaper(p);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* __kill_pgrp_info() sends a signal to a process group: this is what the tty
|
|
* control characters do (^C, ^Z etc)
|
|
* - the caller must hold at least a readlock on tasklist_lock
|
|
*/
|
|
int __kill_pgrp_info(int sig, struct kernel_siginfo *info, struct pid *pgrp)
|
|
{
|
|
struct task_struct *p = NULL;
|
|
int retval, success;
|
|
|
|
success = 0;
|
|
retval = -ESRCH;
|
|
do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
|
|
int err = group_send_sig_info(sig, info, p, PIDTYPE_PGID);
|
|
success |= !err;
|
|
retval = err;
|
|
} while_each_pid_task(pgrp, PIDTYPE_PGID, p);
|
|
return success ? 0 : retval;
|
|
}
|
|
|
|
int kill_pid_info(int sig, struct kernel_siginfo *info, struct pid *pid)
|
|
{
|
|
int error = -ESRCH;
|
|
struct task_struct *p;
|
|
|
|
for (;;) {
|
|
rcu_read_lock();
|
|
p = pid_task(pid, PIDTYPE_PID);
|
|
if (p)
|
|
error = group_send_sig_info(sig, info, p, PIDTYPE_TGID);
|
|
rcu_read_unlock();
|
|
if (likely(!p || error != -ESRCH))
|
|
return error;
|
|
|
|
/*
|
|
* The task was unhashed in between, try again. If it
|
|
* is dead, pid_task() will return NULL, if we race with
|
|
* de_thread() it will find the new leader.
|
|
*/
|
|
}
|
|
}
|
|
|
|
static int kill_proc_info(int sig, struct kernel_siginfo *info, pid_t pid)
|
|
{
|
|
int error;
|
|
rcu_read_lock();
|
|
error = kill_pid_info(sig, info, find_vpid(pid));
|
|
rcu_read_unlock();
|
|
return error;
|
|
}
|
|
|
|
static inline bool kill_as_cred_perm(const struct cred *cred,
|
|
struct task_struct *target)
|
|
{
|
|
const struct cred *pcred = __task_cred(target);
|
|
|
|
return uid_eq(cred->euid, pcred->suid) ||
|
|
uid_eq(cred->euid, pcred->uid) ||
|
|
uid_eq(cred->uid, pcred->suid) ||
|
|
uid_eq(cred->uid, pcred->uid);
|
|
}
|
|
|
|
/*
|
|
* The usb asyncio usage of siginfo is wrong. The glibc support
|
|
* for asyncio which uses SI_ASYNCIO assumes the layout is SIL_RT.
|
|
* AKA after the generic fields:
|
|
* kernel_pid_t si_pid;
|
|
* kernel_uid32_t si_uid;
|
|
* sigval_t si_value;
|
|
*
|
|
* Unfortunately when usb generates SI_ASYNCIO it assumes the layout
|
|
* after the generic fields is:
|
|
* void __user *si_addr;
|
|
*
|
|
* This is a practical problem when there is a 64bit big endian kernel
|
|
* and a 32bit userspace. As the 32bit address will encoded in the low
|
|
* 32bits of the pointer. Those low 32bits will be stored at higher
|
|
* address than appear in a 32 bit pointer. So userspace will not
|
|
* see the address it was expecting for it's completions.
|
|
*
|
|
* There is nothing in the encoding that can allow
|
|
* copy_siginfo_to_user32 to detect this confusion of formats, so
|
|
* handle this by requiring the caller of kill_pid_usb_asyncio to
|
|
* notice when this situration takes place and to store the 32bit
|
|
* pointer in sival_int, instead of sival_addr of the sigval_t addr
|
|
* parameter.
|
|
*/
|
|
int kill_pid_usb_asyncio(int sig, int errno, sigval_t addr,
|
|
struct pid *pid, const struct cred *cred)
|
|
{
|
|
struct kernel_siginfo info;
|
|
struct task_struct *p;
|
|
unsigned long flags;
|
|
int ret = -EINVAL;
|
|
|
|
if (!valid_signal(sig))
|
|
return ret;
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = sig;
|
|
info.si_errno = errno;
|
|
info.si_code = SI_ASYNCIO;
|
|
*((sigval_t *)&info.si_pid) = addr;
|
|
|
|
rcu_read_lock();
|
|
p = pid_task(pid, PIDTYPE_PID);
|
|
if (!p) {
|
|
ret = -ESRCH;
|
|
goto out_unlock;
|
|
}
|
|
if (!kill_as_cred_perm(cred, p)) {
|
|
ret = -EPERM;
|
|
goto out_unlock;
|
|
}
|
|
ret = security_task_kill(p, &info, sig, cred);
|
|
if (ret)
|
|
goto out_unlock;
|
|
|
|
if (sig) {
|
|
if (lock_task_sighand(p, &flags)) {
|
|
ret = __send_signal(sig, &info, p, PIDTYPE_TGID, false);
|
|
unlock_task_sighand(p, &flags);
|
|
} else
|
|
ret = -ESRCH;
|
|
}
|
|
out_unlock:
|
|
rcu_read_unlock();
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(kill_pid_usb_asyncio);
|
|
|
|
/*
|
|
* kill_something_info() interprets pid in interesting ways just like kill(2).
|
|
*
|
|
* POSIX specifies that kill(-1,sig) is unspecified, but what we have
|
|
* is probably wrong. Should make it like BSD or SYSV.
|
|
*/
|
|
|
|
static int kill_something_info(int sig, struct kernel_siginfo *info, pid_t pid)
|
|
{
|
|
int ret;
|
|
|
|
if (pid > 0) {
|
|
rcu_read_lock();
|
|
ret = kill_pid_info(sig, info, find_vpid(pid));
|
|
rcu_read_unlock();
|
|
return ret;
|
|
}
|
|
|
|
/* -INT_MIN is undefined. Exclude this case to avoid a UBSAN warning */
|
|
if (pid == INT_MIN)
|
|
return -ESRCH;
|
|
|
|
read_lock(&tasklist_lock);
|
|
if (pid != -1) {
|
|
ret = __kill_pgrp_info(sig, info,
|
|
pid ? find_vpid(-pid) : task_pgrp(current));
|
|
} else {
|
|
int retval = 0, count = 0;
|
|
struct task_struct * p;
|
|
|
|
for_each_process(p) {
|
|
if (task_pid_vnr(p) > 1 &&
|
|
!same_thread_group(p, current)) {
|
|
int err = group_send_sig_info(sig, info, p,
|
|
PIDTYPE_MAX);
|
|
++count;
|
|
if (err != -EPERM)
|
|
retval = err;
|
|
}
|
|
}
|
|
ret = count ? retval : -ESRCH;
|
|
}
|
|
read_unlock(&tasklist_lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* These are for backward compatibility with the rest of the kernel source.
|
|
*/
|
|
|
|
int send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p)
|
|
{
|
|
/*
|
|
* Make sure legacy kernel users don't send in bad values
|
|
* (normal paths check this in check_kill_permission).
|
|
*/
|
|
if (!valid_signal(sig))
|
|
return -EINVAL;
|
|
|
|
return do_send_sig_info(sig, info, p, PIDTYPE_PID);
|
|
}
|
|
EXPORT_SYMBOL(send_sig_info);
|
|
|
|
#define __si_special(priv) \
|
|
((priv) ? SEND_SIG_PRIV : SEND_SIG_NOINFO)
|
|
|
|
int
|
|
send_sig(int sig, struct task_struct *p, int priv)
|
|
{
|
|
return send_sig_info(sig, __si_special(priv), p);
|
|
}
|
|
EXPORT_SYMBOL(send_sig);
|
|
|
|
void force_sig(int sig)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = sig;
|
|
info.si_errno = 0;
|
|
info.si_code = SI_KERNEL;
|
|
info.si_pid = 0;
|
|
info.si_uid = 0;
|
|
force_sig_info(&info);
|
|
}
|
|
EXPORT_SYMBOL(force_sig);
|
|
|
|
/*
|
|
* When things go south during signal handling, we
|
|
* will force a SIGSEGV. And if the signal that caused
|
|
* the problem was already a SIGSEGV, we'll want to
|
|
* make sure we don't even try to deliver the signal..
|
|
*/
|
|
void force_sigsegv(int sig)
|
|
{
|
|
struct task_struct *p = current;
|
|
|
|
if (sig == SIGSEGV) {
|
|
unsigned long flags;
|
|
spin_lock_irqsave(&p->sighand->siglock, flags);
|
|
p->sighand->action[sig - 1].sa.sa_handler = SIG_DFL;
|
|
spin_unlock_irqrestore(&p->sighand->siglock, flags);
|
|
}
|
|
force_sig(SIGSEGV);
|
|
}
|
|
|
|
int force_sig_fault_to_task(int sig, int code, void __user *addr
|
|
___ARCH_SI_TRAPNO(int trapno)
|
|
___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
|
|
, struct task_struct *t)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = sig;
|
|
info.si_errno = 0;
|
|
info.si_code = code;
|
|
info.si_addr = addr;
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
info.si_trapno = trapno;
|
|
#endif
|
|
#ifdef __ia64__
|
|
info.si_imm = imm;
|
|
info.si_flags = flags;
|
|
info.si_isr = isr;
|
|
#endif
|
|
return force_sig_info_to_task(&info, t);
|
|
}
|
|
|
|
int force_sig_fault(int sig, int code, void __user *addr
|
|
___ARCH_SI_TRAPNO(int trapno)
|
|
___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr))
|
|
{
|
|
return force_sig_fault_to_task(sig, code, addr
|
|
___ARCH_SI_TRAPNO(trapno)
|
|
___ARCH_SI_IA64(imm, flags, isr), current);
|
|
}
|
|
|
|
int send_sig_fault(int sig, int code, void __user *addr
|
|
___ARCH_SI_TRAPNO(int trapno)
|
|
___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
|
|
, struct task_struct *t)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = sig;
|
|
info.si_errno = 0;
|
|
info.si_code = code;
|
|
info.si_addr = addr;
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
info.si_trapno = trapno;
|
|
#endif
|
|
#ifdef __ia64__
|
|
info.si_imm = imm;
|
|
info.si_flags = flags;
|
|
info.si_isr = isr;
|
|
#endif
|
|
return send_sig_info(info.si_signo, &info, t);
|
|
}
|
|
|
|
int force_sig_mceerr(int code, void __user *addr, short lsb)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
|
|
clear_siginfo(&info);
|
|
info.si_signo = SIGBUS;
|
|
info.si_errno = 0;
|
|
info.si_code = code;
|
|
info.si_addr = addr;
|
|
info.si_addr_lsb = lsb;
|
|
return force_sig_info(&info);
|
|
}
|
|
|
|
int send_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct *t)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
|
|
clear_siginfo(&info);
|
|
info.si_signo = SIGBUS;
|
|
info.si_errno = 0;
|
|
info.si_code = code;
|
|
info.si_addr = addr;
|
|
info.si_addr_lsb = lsb;
|
|
return send_sig_info(info.si_signo, &info, t);
|
|
}
|
|
EXPORT_SYMBOL(send_sig_mceerr);
|
|
|
|
int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = SIGSEGV;
|
|
info.si_errno = 0;
|
|
info.si_code = SEGV_BNDERR;
|
|
info.si_addr = addr;
|
|
info.si_lower = lower;
|
|
info.si_upper = upper;
|
|
return force_sig_info(&info);
|
|
}
|
|
|
|
#ifdef SEGV_PKUERR
|
|
int force_sig_pkuerr(void __user *addr, u32 pkey)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = SIGSEGV;
|
|
info.si_errno = 0;
|
|
info.si_code = SEGV_PKUERR;
|
|
info.si_addr = addr;
|
|
info.si_pkey = pkey;
|
|
return force_sig_info(&info);
|
|
}
|
|
#endif
|
|
|
|
/* For the crazy architectures that include trap information in
|
|
* the errno field, instead of an actual errno value.
|
|
*/
|
|
int force_sig_ptrace_errno_trap(int errno, void __user *addr)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = SIGTRAP;
|
|
info.si_errno = errno;
|
|
info.si_code = TRAP_HWBKPT;
|
|
info.si_addr = addr;
|
|
return force_sig_info(&info);
|
|
}
|
|
|
|
int kill_pgrp(struct pid *pid, int sig, int priv)
|
|
{
|
|
int ret;
|
|
|
|
read_lock(&tasklist_lock);
|
|
ret = __kill_pgrp_info(sig, __si_special(priv), pid);
|
|
read_unlock(&tasklist_lock);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(kill_pgrp);
|
|
|
|
int kill_pid(struct pid *pid, int sig, int priv)
|
|
{
|
|
return kill_pid_info(sig, __si_special(priv), pid);
|
|
}
|
|
EXPORT_SYMBOL(kill_pid);
|
|
|
|
/*
|
|
* These functions support sending signals using preallocated sigqueue
|
|
* structures. This is needed "because realtime applications cannot
|
|
* afford to lose notifications of asynchronous events, like timer
|
|
* expirations or I/O completions". In the case of POSIX Timers
|
|
* we allocate the sigqueue structure from the timer_create. If this
|
|
* allocation fails we are able to report the failure to the application
|
|
* with an EAGAIN error.
|
|
*/
|
|
struct sigqueue *sigqueue_alloc(void)
|
|
{
|
|
struct sigqueue *q = __sigqueue_alloc(-1, current, GFP_KERNEL, 0);
|
|
|
|
if (q)
|
|
q->flags |= SIGQUEUE_PREALLOC;
|
|
|
|
return q;
|
|
}
|
|
|
|
void sigqueue_free(struct sigqueue *q)
|
|
{
|
|
spinlock_t *lock = ¤t->sighand->siglock;
|
|
unsigned long flags;
|
|
|
|
if (WARN_ON_ONCE(!(q->flags & SIGQUEUE_PREALLOC)))
|
|
return;
|
|
/*
|
|
* We must hold ->siglock while testing q->list
|
|
* to serialize with collect_signal() or with
|
|
* __exit_signal()->flush_sigqueue().
|
|
*/
|
|
spin_lock_irqsave(lock, flags);
|
|
q->flags &= ~SIGQUEUE_PREALLOC;
|
|
/*
|
|
* If it is queued it will be freed when dequeued,
|
|
* like the "regular" sigqueue.
|
|
*/
|
|
if (!list_empty(&q->list))
|
|
q = NULL;
|
|
spin_unlock_irqrestore(lock, flags);
|
|
|
|
if (q)
|
|
__sigqueue_free(q);
|
|
}
|
|
|
|
int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
|
|
{
|
|
int sig = q->info.si_signo;
|
|
struct sigpending *pending;
|
|
struct task_struct *t;
|
|
unsigned long flags;
|
|
int ret, result;
|
|
|
|
if (WARN_ON_ONCE(!(q->flags & SIGQUEUE_PREALLOC)))
|
|
return 0;
|
|
if (WARN_ON_ONCE(q->info.si_code != SI_TIMER))
|
|
return 0;
|
|
|
|
ret = -1;
|
|
rcu_read_lock();
|
|
t = pid_task(pid, type);
|
|
if (!t || !likely(lock_task_sighand(t, &flags)))
|
|
goto ret;
|
|
|
|
ret = 1; /* the signal is ignored */
|
|
result = TRACE_SIGNAL_IGNORED;
|
|
if (!prepare_signal(sig, t, false))
|
|
goto out;
|
|
|
|
ret = 0;
|
|
if (unlikely(!list_empty(&q->list))) {
|
|
/*
|
|
* If an SI_TIMER entry is already queue just increment
|
|
* the overrun count.
|
|
*/
|
|
q->info.si_overrun++;
|
|
result = TRACE_SIGNAL_ALREADY_PENDING;
|
|
goto out;
|
|
}
|
|
q->info.si_overrun = 0;
|
|
|
|
signalfd_notify(t, sig);
|
|
pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending;
|
|
list_add_tail(&q->list, &pending->list);
|
|
sigaddset(&pending->signal, sig);
|
|
complete_signal(sig, t, type);
|
|
result = TRACE_SIGNAL_DELIVERED;
|
|
out:
|
|
trace_signal_generate(sig, &q->info, t, type != PIDTYPE_PID, result);
|
|
unlock_task_sighand(t, &flags);
|
|
ret:
|
|
rcu_read_unlock();
|
|
return ret;
|
|
}
|
|
|
|
static void do_notify_pidfd(struct task_struct *task)
|
|
{
|
|
struct pid *pid;
|
|
|
|
WARN_ON(task->exit_state == 0);
|
|
pid = task_pid(task);
|
|
wake_up_all(&pid->wait_pidfd);
|
|
}
|
|
|
|
/*
|
|
* Let a parent know about the death of a child.
|
|
* For a stopped/continued status change, use do_notify_parent_cldstop instead.
|
|
*
|
|
* Returns true if our parent ignored us and so we've switched to
|
|
* self-reaping.
|
|
*/
|
|
bool do_notify_parent(struct task_struct *tsk, int sig)
|
|
{
|
|
struct kernel_siginfo info;
|
|
unsigned long flags;
|
|
struct sighand_struct *psig;
|
|
bool autoreap = false;
|
|
u64 utime, stime;
|
|
|
|
WARN_ON_ONCE(sig == -1);
|
|
|
|
/* do_notify_parent_cldstop should have been called instead. */
|
|
WARN_ON_ONCE(task_is_stopped_or_traced(tsk));
|
|
|
|
WARN_ON_ONCE(!tsk->ptrace &&
|
|
(tsk->group_leader != tsk || !thread_group_empty(tsk)));
|
|
|
|
/* Wake up all pidfd waiters */
|
|
do_notify_pidfd(tsk);
|
|
|
|
if (sig != SIGCHLD) {
|
|
/*
|
|
* This is only possible if parent == real_parent.
|
|
* Check if it has changed security domain.
|
|
*/
|
|
if (tsk->parent_exec_id != READ_ONCE(tsk->parent->self_exec_id))
|
|
sig = SIGCHLD;
|
|
}
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = sig;
|
|
info.si_errno = 0;
|
|
/*
|
|
* We are under tasklist_lock here so our parent is tied to
|
|
* us and cannot change.
|
|
*
|
|
* task_active_pid_ns will always return the same pid namespace
|
|
* until a task passes through release_task.
|
|
*
|
|
* write_lock() currently calls preempt_disable() which is the
|
|
* same as rcu_read_lock(), but according to Oleg, this is not
|
|
* correct to rely on this
|
|
*/
|
|
rcu_read_lock();
|
|
info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(tsk->parent));
|
|
info.si_uid = from_kuid_munged(task_cred_xxx(tsk->parent, user_ns),
|
|
task_uid(tsk));
|
|
rcu_read_unlock();
|
|
|
|
task_cputime(tsk, &utime, &stime);
|
|
info.si_utime = nsec_to_clock_t(utime + tsk->signal->utime);
|
|
info.si_stime = nsec_to_clock_t(stime + tsk->signal->stime);
|
|
|
|
info.si_status = tsk->exit_code & 0x7f;
|
|
if (tsk->exit_code & 0x80)
|
|
info.si_code = CLD_DUMPED;
|
|
else if (tsk->exit_code & 0x7f)
|
|
info.si_code = CLD_KILLED;
|
|
else {
|
|
info.si_code = CLD_EXITED;
|
|
info.si_status = tsk->exit_code >> 8;
|
|
}
|
|
|
|
psig = tsk->parent->sighand;
|
|
spin_lock_irqsave(&psig->siglock, flags);
|
|
if (!tsk->ptrace && sig == SIGCHLD &&
|
|
(psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN ||
|
|
(psig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT))) {
|
|
/*
|
|
* We are exiting and our parent doesn't care. POSIX.1
|
|
* defines special semantics for setting SIGCHLD to SIG_IGN
|
|
* or setting the SA_NOCLDWAIT flag: we should be reaped
|
|
* automatically and not left for our parent's wait4 call.
|
|
* Rather than having the parent do it as a magic kind of
|
|
* signal handler, we just set this to tell do_exit that we
|
|
* can be cleaned up without becoming a zombie. Note that
|
|
* we still call __wake_up_parent in this case, because a
|
|
* blocked sys_wait4 might now return -ECHILD.
|
|
*
|
|
* Whether we send SIGCHLD or not for SA_NOCLDWAIT
|
|
* is implementation-defined: we do (if you don't want
|
|
* it, just use SIG_IGN instead).
|
|
*/
|
|
autoreap = true;
|
|
if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN)
|
|
sig = 0;
|
|
}
|
|
/*
|
|
* Send with __send_signal as si_pid and si_uid are in the
|
|
* parent's namespaces.
|
|
*/
|
|
if (valid_signal(sig) && sig)
|
|
__send_signal(sig, &info, tsk->parent, PIDTYPE_TGID, false);
|
|
__wake_up_parent(tsk, tsk->parent);
|
|
spin_unlock_irqrestore(&psig->siglock, flags);
|
|
|
|
return autoreap;
|
|
}
|
|
|
|
/**
|
|
* do_notify_parent_cldstop - notify parent of stopped/continued state change
|
|
* @tsk: task reporting the state change
|
|
* @for_ptracer: the notification is for ptracer
|
|
* @why: CLD_{CONTINUED|STOPPED|TRAPPED} to report
|
|
*
|
|
* Notify @tsk's parent that the stopped/continued state has changed. If
|
|
* @for_ptracer is %false, @tsk's group leader notifies to its real parent.
|
|
* If %true, @tsk reports to @tsk->parent which should be the ptracer.
|
|
*
|
|
* CONTEXT:
|
|
* Must be called with tasklist_lock at least read locked.
|
|
*/
|
|
static void do_notify_parent_cldstop(struct task_struct *tsk,
|
|
bool for_ptracer, int why)
|
|
{
|
|
struct kernel_siginfo info;
|
|
unsigned long flags;
|
|
struct task_struct *parent;
|
|
struct sighand_struct *sighand;
|
|
u64 utime, stime;
|
|
|
|
if (for_ptracer) {
|
|
parent = tsk->parent;
|
|
} else {
|
|
tsk = tsk->group_leader;
|
|
parent = tsk->real_parent;
|
|
}
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = SIGCHLD;
|
|
info.si_errno = 0;
|
|
/*
|
|
* see comment in do_notify_parent() about the following 4 lines
|
|
*/
|
|
rcu_read_lock();
|
|
info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(parent));
|
|
info.si_uid = from_kuid_munged(task_cred_xxx(parent, user_ns), task_uid(tsk));
|
|
rcu_read_unlock();
|
|
|
|
task_cputime(tsk, &utime, &stime);
|
|
info.si_utime = nsec_to_clock_t(utime);
|
|
info.si_stime = nsec_to_clock_t(stime);
|
|
|
|
info.si_code = why;
|
|
switch (why) {
|
|
case CLD_CONTINUED:
|
|
info.si_status = SIGCONT;
|
|
break;
|
|
case CLD_STOPPED:
|
|
info.si_status = tsk->signal->group_exit_code & 0x7f;
|
|
break;
|
|
case CLD_TRAPPED:
|
|
info.si_status = tsk->exit_code & 0x7f;
|
|
break;
|
|
default:
|
|
BUG();
|
|
}
|
|
|
|
sighand = parent->sighand;
|
|
spin_lock_irqsave(&sighand->siglock, flags);
|
|
if (sighand->action[SIGCHLD-1].sa.sa_handler != SIG_IGN &&
|
|
!(sighand->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
|
|
__group_send_sig_info(SIGCHLD, &info, parent);
|
|
/*
|
|
* Even if SIGCHLD is not generated, we must wake up wait4 calls.
|
|
*/
|
|
__wake_up_parent(tsk, parent);
|
|
spin_unlock_irqrestore(&sighand->siglock, flags);
|
|
}
|
|
|
|
static inline bool may_ptrace_stop(void)
|
|
{
|
|
if (!likely(current->ptrace))
|
|
return false;
|
|
/*
|
|
* Are we in the middle of do_coredump?
|
|
* If so and our tracer is also part of the coredump stopping
|
|
* is a deadlock situation, and pointless because our tracer
|
|
* is dead so don't allow us to stop.
|
|
* If SIGKILL was already sent before the caller unlocked
|
|
* ->siglock we must see ->core_state != NULL. Otherwise it
|
|
* is safe to enter schedule().
|
|
*
|
|
* This is almost outdated, a task with the pending SIGKILL can't
|
|
* block in TASK_TRACED. But PTRACE_EVENT_EXIT can be reported
|
|
* after SIGKILL was already dequeued.
|
|
*/
|
|
if (unlikely(current->mm->core_state) &&
|
|
unlikely(current->mm == current->parent->mm))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
/*
|
|
* This must be called with current->sighand->siglock held.
|
|
*
|
|
* This should be the path for all ptrace stops.
|
|
* We always set current->last_siginfo while stopped here.
|
|
* That makes it a way to test a stopped process for
|
|
* being ptrace-stopped vs being job-control-stopped.
|
|
*
|
|
* If we actually decide not to stop at all because the tracer
|
|
* is gone, we keep current->exit_code unless clear_code.
|
|
*/
|
|
static void ptrace_stop(int exit_code, int why, int clear_code, kernel_siginfo_t *info)
|
|
__releases(¤t->sighand->siglock)
|
|
__acquires(¤t->sighand->siglock)
|
|
{
|
|
bool gstop_done = false;
|
|
|
|
if (arch_ptrace_stop_needed(exit_code, info)) {
|
|
/*
|
|
* The arch code has something special to do before a
|
|
* ptrace stop. This is allowed to block, e.g. for faults
|
|
* on user stack pages. We can't keep the siglock while
|
|
* calling arch_ptrace_stop, so we must release it now.
|
|
* To preserve proper semantics, we must do this before
|
|
* any signal bookkeeping like checking group_stop_count.
|
|
*/
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
arch_ptrace_stop(exit_code, info);
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
}
|
|
|
|
/*
|
|
* schedule() will not sleep if there is a pending signal that
|
|
* can awaken the task.
|
|
*/
|
|
set_special_state(TASK_TRACED);
|
|
|
|
/*
|
|
* We're committing to trapping. TRACED should be visible before
|
|
* TRAPPING is cleared; otherwise, the tracer might fail do_wait().
|
|
* Also, transition to TRACED and updates to ->jobctl should be
|
|
* atomic with respect to siglock and should be done after the arch
|
|
* hook as siglock is released and regrabbed across it.
|
|
*
|
|
* TRACER TRACEE
|
|
*
|
|
* ptrace_attach()
|
|
* [L] wait_on_bit(JOBCTL_TRAPPING) [S] set_special_state(TRACED)
|
|
* do_wait()
|
|
* set_current_state() smp_wmb();
|
|
* ptrace_do_wait()
|
|
* wait_task_stopped()
|
|
* task_stopped_code()
|
|
* [L] task_is_traced() [S] task_clear_jobctl_trapping();
|
|
*/
|
|
smp_wmb();
|
|
|
|
current->last_siginfo = info;
|
|
current->exit_code = exit_code;
|
|
|
|
/*
|
|
* If @why is CLD_STOPPED, we're trapping to participate in a group
|
|
* stop. Do the bookkeeping. Note that if SIGCONT was delievered
|
|
* across siglock relocks since INTERRUPT was scheduled, PENDING
|
|
* could be clear now. We act as if SIGCONT is received after
|
|
* TASK_TRACED is entered - ignore it.
|
|
*/
|
|
if (why == CLD_STOPPED && (current->jobctl & JOBCTL_STOP_PENDING))
|
|
gstop_done = task_participate_group_stop(current);
|
|
|
|
/* any trap clears pending STOP trap, STOP trap clears NOTIFY */
|
|
task_clear_jobctl_pending(current, JOBCTL_TRAP_STOP);
|
|
if (info && info->si_code >> 8 == PTRACE_EVENT_STOP)
|
|
task_clear_jobctl_pending(current, JOBCTL_TRAP_NOTIFY);
|
|
|
|
/* entering a trap, clear TRAPPING */
|
|
task_clear_jobctl_trapping(current);
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
read_lock(&tasklist_lock);
|
|
if (may_ptrace_stop()) {
|
|
/*
|
|
* Notify parents of the stop.
|
|
*
|
|
* While ptraced, there are two parents - the ptracer and
|
|
* the real_parent of the group_leader. The ptracer should
|
|
* know about every stop while the real parent is only
|
|
* interested in the completion of group stop. The states
|
|
* for the two don't interact with each other. Notify
|
|
* separately unless they're gonna be duplicates.
|
|
*/
|
|
do_notify_parent_cldstop(current, true, why);
|
|
if (gstop_done && ptrace_reparented(current))
|
|
do_notify_parent_cldstop(current, false, why);
|
|
|
|
/*
|
|
* Don't want to allow preemption here, because
|
|
* sys_ptrace() needs this task to be inactive.
|
|
*
|
|
* XXX: implement read_unlock_no_resched().
|
|
*/
|
|
preempt_disable();
|
|
read_unlock(&tasklist_lock);
|
|
cgroup_enter_frozen();
|
|
preempt_enable_no_resched();
|
|
freezable_schedule();
|
|
cgroup_leave_frozen(true);
|
|
} else {
|
|
/*
|
|
* By the time we got the lock, our tracer went away.
|
|
* Don't drop the lock yet, another tracer may come.
|
|
*
|
|
* If @gstop_done, the ptracer went away between group stop
|
|
* completion and here. During detach, it would have set
|
|
* JOBCTL_STOP_PENDING on us and we'll re-enter
|
|
* TASK_STOPPED in do_signal_stop() on return, so notifying
|
|
* the real parent of the group stop completion is enough.
|
|
*/
|
|
if (gstop_done)
|
|
do_notify_parent_cldstop(current, false, why);
|
|
|
|
/* tasklist protects us from ptrace_freeze_traced() */
|
|
__set_current_state(TASK_RUNNING);
|
|
if (clear_code)
|
|
current->exit_code = 0;
|
|
read_unlock(&tasklist_lock);
|
|
}
|
|
|
|
/*
|
|
* We are back. Now reacquire the siglock before touching
|
|
* last_siginfo, so that we are sure to have synchronized with
|
|
* any signal-sending on another CPU that wants to examine it.
|
|
*/
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
current->last_siginfo = NULL;
|
|
|
|
/* LISTENING can be set only during STOP traps, clear it */
|
|
current->jobctl &= ~JOBCTL_LISTENING;
|
|
|
|
/*
|
|
* Queued signals ignored us while we were stopped for tracing.
|
|
* So check for any that we should take before resuming user mode.
|
|
* This sets TIF_SIGPENDING, but never clears it.
|
|
*/
|
|
recalc_sigpending_tsk(current);
|
|
}
|
|
|
|
static void ptrace_do_notify(int signr, int exit_code, int why)
|
|
{
|
|
kernel_siginfo_t info;
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = signr;
|
|
info.si_code = exit_code;
|
|
info.si_pid = task_pid_vnr(current);
|
|
info.si_uid = from_kuid_munged(current_user_ns(), current_uid());
|
|
|
|
/* Let the debugger run. */
|
|
ptrace_stop(exit_code, why, 1, &info);
|
|
}
|
|
|
|
void ptrace_notify(int exit_code)
|
|
{
|
|
BUG_ON((exit_code & (0x7f | ~0xffff)) != SIGTRAP);
|
|
if (unlikely(current->task_works))
|
|
task_work_run();
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
ptrace_do_notify(SIGTRAP, exit_code, CLD_TRAPPED);
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
}
|
|
|
|
/**
|
|
* do_signal_stop - handle group stop for SIGSTOP and other stop signals
|
|
* @signr: signr causing group stop if initiating
|
|
*
|
|
* If %JOBCTL_STOP_PENDING is not set yet, initiate group stop with @signr
|
|
* and participate in it. If already set, participate in the existing
|
|
* group stop. If participated in a group stop (and thus slept), %true is
|
|
* returned with siglock released.
|
|
*
|
|
* If ptraced, this function doesn't handle stop itself. Instead,
|
|
* %JOBCTL_TRAP_STOP is scheduled and %false is returned with siglock
|
|
* untouched. The caller must ensure that INTERRUPT trap handling takes
|
|
* places afterwards.
|
|
*
|
|
* CONTEXT:
|
|
* Must be called with @current->sighand->siglock held, which is released
|
|
* on %true return.
|
|
*
|
|
* RETURNS:
|
|
* %false if group stop is already cancelled or ptrace trap is scheduled.
|
|
* %true if participated in group stop.
|
|
*/
|
|
static bool do_signal_stop(int signr)
|
|
__releases(¤t->sighand->siglock)
|
|
{
|
|
struct signal_struct *sig = current->signal;
|
|
|
|
if (!(current->jobctl & JOBCTL_STOP_PENDING)) {
|
|
unsigned long gstop = JOBCTL_STOP_PENDING | JOBCTL_STOP_CONSUME;
|
|
struct task_struct *t;
|
|
|
|
/* signr will be recorded in task->jobctl for retries */
|
|
WARN_ON_ONCE(signr & ~JOBCTL_STOP_SIGMASK);
|
|
|
|
if (!likely(current->jobctl & JOBCTL_STOP_DEQUEUED) ||
|
|
unlikely(signal_group_exit(sig)))
|
|
return false;
|
|
/*
|
|
* There is no group stop already in progress. We must
|
|
* initiate one now.
|
|
*
|
|
* While ptraced, a task may be resumed while group stop is
|
|
* still in effect and then receive a stop signal and
|
|
* initiate another group stop. This deviates from the
|
|
* usual behavior as two consecutive stop signals can't
|
|
* cause two group stops when !ptraced. That is why we
|
|
* also check !task_is_stopped(t) below.
|
|
*
|
|
* The condition can be distinguished by testing whether
|
|
* SIGNAL_STOP_STOPPED is already set. Don't generate
|
|
* group_exit_code in such case.
|
|
*
|
|
* This is not necessary for SIGNAL_STOP_CONTINUED because
|
|
* an intervening stop signal is required to cause two
|
|
* continued events regardless of ptrace.
|
|
*/
|
|
if (!(sig->flags & SIGNAL_STOP_STOPPED))
|
|
sig->group_exit_code = signr;
|
|
|
|
sig->group_stop_count = 0;
|
|
|
|
if (task_set_jobctl_pending(current, signr | gstop))
|
|
sig->group_stop_count++;
|
|
|
|
t = current;
|
|
while_each_thread(current, t) {
|
|
/*
|
|
* Setting state to TASK_STOPPED for a group
|
|
* stop is always done with the siglock held,
|
|
* so this check has no races.
|
|
*/
|
|
if (!task_is_stopped(t) &&
|
|
task_set_jobctl_pending(t, signr | gstop)) {
|
|
sig->group_stop_count++;
|
|
if (likely(!(t->ptrace & PT_SEIZED)))
|
|
signal_wake_up(t, 0);
|
|
else
|
|
ptrace_trap_notify(t);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (likely(!current->ptrace)) {
|
|
int notify = 0;
|
|
|
|
/*
|
|
* If there are no other threads in the group, or if there
|
|
* is a group stop in progress and we are the last to stop,
|
|
* report to the parent.
|
|
*/
|
|
if (task_participate_group_stop(current))
|
|
notify = CLD_STOPPED;
|
|
|
|
set_special_state(TASK_STOPPED);
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
/*
|
|
* Notify the parent of the group stop completion. Because
|
|
* we're not holding either the siglock or tasklist_lock
|
|
* here, ptracer may attach inbetween; however, this is for
|
|
* group stop and should always be delivered to the real
|
|
* parent of the group leader. The new ptracer will get
|
|
* its notification when this task transitions into
|
|
* TASK_TRACED.
|
|
*/
|
|
if (notify) {
|
|
read_lock(&tasklist_lock);
|
|
do_notify_parent_cldstop(current, false, notify);
|
|
read_unlock(&tasklist_lock);
|
|
}
|
|
|
|
/* Now we don't run again until woken by SIGCONT or SIGKILL */
|
|
cgroup_enter_frozen();
|
|
freezable_schedule();
|
|
return true;
|
|
} else {
|
|
/*
|
|
* While ptraced, group stop is handled by STOP trap.
|
|
* Schedule it and let the caller deal with it.
|
|
*/
|
|
task_set_jobctl_pending(current, JOBCTL_TRAP_STOP);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* do_jobctl_trap - take care of ptrace jobctl traps
|
|
*
|
|
* When PT_SEIZED, it's used for both group stop and explicit
|
|
* SEIZE/INTERRUPT traps. Both generate PTRACE_EVENT_STOP trap with
|
|
* accompanying siginfo. If stopped, lower eight bits of exit_code contain
|
|
* the stop signal; otherwise, %SIGTRAP.
|
|
*
|
|
* When !PT_SEIZED, it's used only for group stop trap with stop signal
|
|
* number as exit_code and no siginfo.
|
|
*
|
|
* CONTEXT:
|
|
* Must be called with @current->sighand->siglock held, which may be
|
|
* released and re-acquired before returning with intervening sleep.
|
|
*/
|
|
static void do_jobctl_trap(void)
|
|
{
|
|
struct signal_struct *signal = current->signal;
|
|
int signr = current->jobctl & JOBCTL_STOP_SIGMASK;
|
|
|
|
if (current->ptrace & PT_SEIZED) {
|
|
if (!signal->group_stop_count &&
|
|
!(signal->flags & SIGNAL_STOP_STOPPED))
|
|
signr = SIGTRAP;
|
|
WARN_ON_ONCE(!signr);
|
|
ptrace_do_notify(signr, signr | (PTRACE_EVENT_STOP << 8),
|
|
CLD_STOPPED);
|
|
} else {
|
|
WARN_ON_ONCE(!signr);
|
|
ptrace_stop(signr, CLD_STOPPED, 0, NULL);
|
|
current->exit_code = 0;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* do_freezer_trap - handle the freezer jobctl trap
|
|
*
|
|
* Puts the task into frozen state, if only the task is not about to quit.
|
|
* In this case it drops JOBCTL_TRAP_FREEZE.
|
|
*
|
|
* CONTEXT:
|
|
* Must be called with @current->sighand->siglock held,
|
|
* which is always released before returning.
|
|
*/
|
|
static void do_freezer_trap(void)
|
|
__releases(¤t->sighand->siglock)
|
|
{
|
|
/*
|
|
* If there are other trap bits pending except JOBCTL_TRAP_FREEZE,
|
|
* let's make another loop to give it a chance to be handled.
|
|
* In any case, we'll return back.
|
|
*/
|
|
if ((current->jobctl & (JOBCTL_PENDING_MASK | JOBCTL_TRAP_FREEZE)) !=
|
|
JOBCTL_TRAP_FREEZE) {
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
return;
|
|
}
|
|
|
|
/*
|
|
* Now we're sure that there is no pending fatal signal and no
|
|
* pending traps. Clear TIF_SIGPENDING to not get out of schedule()
|
|
* immediately (if there is a non-fatal signal pending), and
|
|
* put the task into sleep.
|
|
*/
|
|
__set_current_state(TASK_INTERRUPTIBLE);
|
|
clear_thread_flag(TIF_SIGPENDING);
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
cgroup_enter_frozen();
|
|
freezable_schedule();
|
|
}
|
|
|
|
static int ptrace_signal(int signr, kernel_siginfo_t *info)
|
|
{
|
|
/*
|
|
* We do not check sig_kernel_stop(signr) but set this marker
|
|
* unconditionally because we do not know whether debugger will
|
|
* change signr. This flag has no meaning unless we are going
|
|
* to stop after return from ptrace_stop(). In this case it will
|
|
* be checked in do_signal_stop(), we should only stop if it was
|
|
* not cleared by SIGCONT while we were sleeping. See also the
|
|
* comment in dequeue_signal().
|
|
*/
|
|
current->jobctl |= JOBCTL_STOP_DEQUEUED;
|
|
ptrace_stop(signr, CLD_TRAPPED, 0, info);
|
|
|
|
/* We're back. Did the debugger cancel the sig? */
|
|
signr = current->exit_code;
|
|
if (signr == 0)
|
|
return signr;
|
|
|
|
current->exit_code = 0;
|
|
|
|
/*
|
|
* Update the siginfo structure if the signal has
|
|
* changed. If the debugger wanted something
|
|
* specific in the siginfo structure then it should
|
|
* have updated *info via PTRACE_SETSIGINFO.
|
|
*/
|
|
if (signr != info->si_signo) {
|
|
clear_siginfo(info);
|
|
info->si_signo = signr;
|
|
info->si_errno = 0;
|
|
info->si_code = SI_USER;
|
|
rcu_read_lock();
|
|
info->si_pid = task_pid_vnr(current->parent);
|
|
info->si_uid = from_kuid_munged(current_user_ns(),
|
|
task_uid(current->parent));
|
|
rcu_read_unlock();
|
|
}
|
|
|
|
/* If the (new) signal is now blocked, requeue it. */
|
|
if (sigismember(¤t->blocked, signr)) {
|
|
send_signal(signr, info, current, PIDTYPE_PID);
|
|
signr = 0;
|
|
}
|
|
|
|
return signr;
|
|
}
|
|
|
|
bool get_signal(struct ksignal *ksig)
|
|
{
|
|
struct sighand_struct *sighand = current->sighand;
|
|
struct signal_struct *signal = current->signal;
|
|
int signr;
|
|
|
|
if (unlikely(current->task_works))
|
|
task_work_run();
|
|
|
|
if (unlikely(uprobe_deny_signal()))
|
|
return false;
|
|
|
|
/*
|
|
* Do this once, we can't return to user-mode if freezing() == T.
|
|
* do_signal_stop() and ptrace_stop() do freezable_schedule() and
|
|
* thus do not need another check after return.
|
|
*/
|
|
try_to_freeze();
|
|
|
|
relock:
|
|
spin_lock_irq(&sighand->siglock);
|
|
/*
|
|
* Every stopped thread goes here after wakeup. Check to see if
|
|
* we should notify the parent, prepare_signal(SIGCONT) encodes
|
|
* the CLD_ si_code into SIGNAL_CLD_MASK bits.
|
|
*/
|
|
if (unlikely(signal->flags & SIGNAL_CLD_MASK)) {
|
|
int why;
|
|
|
|
if (signal->flags & SIGNAL_CLD_CONTINUED)
|
|
why = CLD_CONTINUED;
|
|
else
|
|
why = CLD_STOPPED;
|
|
|
|
signal->flags &= ~SIGNAL_CLD_MASK;
|
|
|
|
spin_unlock_irq(&sighand->siglock);
|
|
|
|
/*
|
|
* Notify the parent that we're continuing. This event is
|
|
* always per-process and doesn't make whole lot of sense
|
|
* for ptracers, who shouldn't consume the state via
|
|
* wait(2) either, but, for backward compatibility, notify
|
|
* the ptracer of the group leader too unless it's gonna be
|
|
* a duplicate.
|
|
*/
|
|
read_lock(&tasklist_lock);
|
|
do_notify_parent_cldstop(current, false, why);
|
|
|
|
if (ptrace_reparented(current->group_leader))
|
|
do_notify_parent_cldstop(current->group_leader,
|
|
true, why);
|
|
read_unlock(&tasklist_lock);
|
|
|
|
goto relock;
|
|
}
|
|
|
|
/* Has this task already been marked for death? */
|
|
if (signal_group_exit(signal)) {
|
|
ksig->info.si_signo = signr = SIGKILL;
|
|
sigdelset(¤t->pending.signal, SIGKILL);
|
|
trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO,
|
|
&sighand->action[SIGKILL - 1]);
|
|
recalc_sigpending();
|
|
goto fatal;
|
|
}
|
|
|
|
for (;;) {
|
|
struct k_sigaction *ka;
|
|
|
|
if (unlikely(current->jobctl & JOBCTL_STOP_PENDING) &&
|
|
do_signal_stop(0))
|
|
goto relock;
|
|
|
|
if (unlikely(current->jobctl &
|
|
(JOBCTL_TRAP_MASK | JOBCTL_TRAP_FREEZE))) {
|
|
if (current->jobctl & JOBCTL_TRAP_MASK) {
|
|
do_jobctl_trap();
|
|
spin_unlock_irq(&sighand->siglock);
|
|
} else if (current->jobctl & JOBCTL_TRAP_FREEZE)
|
|
do_freezer_trap();
|
|
|
|
goto relock;
|
|
}
|
|
|
|
/*
|
|
* If the task is leaving the frozen state, let's update
|
|
* cgroup counters and reset the frozen bit.
|
|
*/
|
|
if (unlikely(cgroup_task_frozen(current))) {
|
|
spin_unlock_irq(&sighand->siglock);
|
|
cgroup_leave_frozen(false);
|
|
goto relock;
|
|
}
|
|
|
|
/*
|
|
* Signals generated by the execution of an instruction
|
|
* need to be delivered before any other pending signals
|
|
* so that the instruction pointer in the signal stack
|
|
* frame points to the faulting instruction.
|
|
*/
|
|
signr = dequeue_synchronous_signal(&ksig->info);
|
|
if (!signr)
|
|
signr = dequeue_signal(current, ¤t->blocked, &ksig->info);
|
|
|
|
if (!signr)
|
|
break; /* will return 0 */
|
|
|
|
if (unlikely(current->ptrace) && signr != SIGKILL) {
|
|
signr = ptrace_signal(signr, &ksig->info);
|
|
if (!signr)
|
|
continue;
|
|
}
|
|
|
|
ka = &sighand->action[signr-1];
|
|
|
|
/* Trace actually delivered signals. */
|
|
trace_signal_deliver(signr, &ksig->info, ka);
|
|
|
|
if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */
|
|
continue;
|
|
if (ka->sa.sa_handler != SIG_DFL) {
|
|
/* Run the handler. */
|
|
ksig->ka = *ka;
|
|
|
|
if (ka->sa.sa_flags & SA_ONESHOT)
|
|
ka->sa.sa_handler = SIG_DFL;
|
|
|
|
break; /* will return non-zero "signr" value */
|
|
}
|
|
|
|
/*
|
|
* Now we are doing the default action for this signal.
|
|
*/
|
|
if (sig_kernel_ignore(signr)) /* Default is nothing. */
|
|
continue;
|
|
|
|
/*
|
|
* Global init gets no signals it doesn't want.
|
|
* Container-init gets no signals it doesn't want from same
|
|
* container.
|
|
*
|
|
* Note that if global/container-init sees a sig_kernel_only()
|
|
* signal here, the signal must have been generated internally
|
|
* or must have come from an ancestor namespace. In either
|
|
* case, the signal cannot be dropped.
|
|
*/
|
|
if (unlikely(signal->flags & SIGNAL_UNKILLABLE) &&
|
|
!sig_kernel_only(signr))
|
|
continue;
|
|
|
|
if (sig_kernel_stop(signr)) {
|
|
/*
|
|
* The default action is to stop all threads in
|
|
* the thread group. The job control signals
|
|
* do nothing in an orphaned pgrp, but SIGSTOP
|
|
* always works. Note that siglock needs to be
|
|
* dropped during the call to is_orphaned_pgrp()
|
|
* because of lock ordering with tasklist_lock.
|
|
* This allows an intervening SIGCONT to be posted.
|
|
* We need to check for that and bail out if necessary.
|
|
*/
|
|
if (signr != SIGSTOP) {
|
|
spin_unlock_irq(&sighand->siglock);
|
|
|
|
/* signals can be posted during this window */
|
|
|
|
if (is_current_pgrp_orphaned())
|
|
goto relock;
|
|
|
|
spin_lock_irq(&sighand->siglock);
|
|
}
|
|
|
|
if (likely(do_signal_stop(ksig->info.si_signo))) {
|
|
/* It released the siglock. */
|
|
goto relock;
|
|
}
|
|
|
|
/*
|
|
* We didn't actually stop, due to a race
|
|
* with SIGCONT or something like that.
|
|
*/
|
|
continue;
|
|
}
|
|
|
|
fatal:
|
|
spin_unlock_irq(&sighand->siglock);
|
|
if (unlikely(cgroup_task_frozen(current)))
|
|
cgroup_leave_frozen(true);
|
|
|
|
/*
|
|
* Anything else is fatal, maybe with a core dump.
|
|
*/
|
|
current->flags |= PF_SIGNALED;
|
|
|
|
if (sig_kernel_coredump(signr)) {
|
|
if (print_fatal_signals)
|
|
print_fatal_signal(ksig->info.si_signo);
|
|
proc_coredump_connector(current);
|
|
/*
|
|
* If it was able to dump core, this kills all
|
|
* other threads in the group and synchronizes with
|
|
* their demise. If we lost the race with another
|
|
* thread getting here, it set group_exit_code
|
|
* first and our do_group_exit call below will use
|
|
* that value and ignore the one we pass it.
|
|
*/
|
|
do_coredump(&ksig->info);
|
|
}
|
|
|
|
/*
|
|
* Death signals, no core dump.
|
|
*/
|
|
do_group_exit(ksig->info.si_signo);
|
|
/* NOTREACHED */
|
|
}
|
|
spin_unlock_irq(&sighand->siglock);
|
|
|
|
ksig->sig = signr;
|
|
return ksig->sig > 0;
|
|
}
|
|
|
|
/**
|
|
* signal_delivered -
|
|
* @ksig: kernel signal struct
|
|
* @stepping: nonzero if debugger single-step or block-step in use
|
|
*
|
|
* This function should be called when a signal has successfully been
|
|
* delivered. It updates the blocked signals accordingly (@ksig->ka.sa.sa_mask
|
|
* is always blocked, and the signal itself is blocked unless %SA_NODEFER
|
|
* is set in @ksig->ka.sa.sa_flags. Tracing is notified.
|
|
*/
|
|
static void signal_delivered(struct ksignal *ksig, int stepping)
|
|
{
|
|
sigset_t blocked;
|
|
|
|
/* A signal was successfully delivered, and the
|
|
saved sigmask was stored on the signal frame,
|
|
and will be restored by sigreturn. So we can
|
|
simply clear the restore sigmask flag. */
|
|
clear_restore_sigmask();
|
|
|
|
sigorsets(&blocked, ¤t->blocked, &ksig->ka.sa.sa_mask);
|
|
if (!(ksig->ka.sa.sa_flags & SA_NODEFER))
|
|
sigaddset(&blocked, ksig->sig);
|
|
set_current_blocked(&blocked);
|
|
tracehook_signal_handler(stepping);
|
|
}
|
|
|
|
void signal_setup_done(int failed, struct ksignal *ksig, int stepping)
|
|
{
|
|
if (failed)
|
|
force_sigsegv(ksig->sig);
|
|
else
|
|
signal_delivered(ksig, stepping);
|
|
}
|
|
|
|
/*
|
|
* It could be that complete_signal() picked us to notify about the
|
|
* group-wide signal. Other threads should be notified now to take
|
|
* the shared signals in @which since we will not.
|
|
*/
|
|
static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)
|
|
{
|
|
sigset_t retarget;
|
|
struct task_struct *t;
|
|
|
|
sigandsets(&retarget, &tsk->signal->shared_pending.signal, which);
|
|
if (sigisemptyset(&retarget))
|
|
return;
|
|
|
|
t = tsk;
|
|
while_each_thread(tsk, t) {
|
|
if (t->flags & PF_EXITING)
|
|
continue;
|
|
|
|
if (!has_pending_signals(&retarget, &t->blocked))
|
|
continue;
|
|
/* Remove the signals this thread can handle. */
|
|
sigandsets(&retarget, &retarget, &t->blocked);
|
|
|
|
if (!signal_pending(t))
|
|
signal_wake_up(t, 0);
|
|
|
|
if (sigisemptyset(&retarget))
|
|
break;
|
|
}
|
|
}
|
|
|
|
void exit_signals(struct task_struct *tsk)
|
|
{
|
|
int group_stop = 0;
|
|
sigset_t unblocked;
|
|
|
|
/*
|
|
* @tsk is about to have PF_EXITING set - lock out users which
|
|
* expect stable threadgroup.
|
|
*/
|
|
cgroup_threadgroup_change_begin(tsk);
|
|
|
|
if (thread_group_empty(tsk) || signal_group_exit(tsk->signal)) {
|
|
tsk->flags |= PF_EXITING;
|
|
cgroup_threadgroup_change_end(tsk);
|
|
return;
|
|
}
|
|
|
|
spin_lock_irq(&tsk->sighand->siglock);
|
|
/*
|
|
* From now this task is not visible for group-wide signals,
|
|
* see wants_signal(), do_signal_stop().
|
|
*/
|
|
tsk->flags |= PF_EXITING;
|
|
|
|
cgroup_threadgroup_change_end(tsk);
|
|
|
|
if (!signal_pending(tsk))
|
|
goto out;
|
|
|
|
unblocked = tsk->blocked;
|
|
signotset(&unblocked);
|
|
retarget_shared_pending(tsk, &unblocked);
|
|
|
|
if (unlikely(tsk->jobctl & JOBCTL_STOP_PENDING) &&
|
|
task_participate_group_stop(tsk))
|
|
group_stop = CLD_STOPPED;
|
|
out:
|
|
spin_unlock_irq(&tsk->sighand->siglock);
|
|
|
|
/*
|
|
* If group stop has completed, deliver the notification. This
|
|
* should always go to the real parent of the group leader.
|
|
*/
|
|
if (unlikely(group_stop)) {
|
|
read_lock(&tasklist_lock);
|
|
do_notify_parent_cldstop(tsk, false, group_stop);
|
|
read_unlock(&tasklist_lock);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* System call entry points.
|
|
*/
|
|
|
|
/**
|
|
* sys_restart_syscall - restart a system call
|
|
*/
|
|
SYSCALL_DEFINE0(restart_syscall)
|
|
{
|
|
struct restart_block *restart = ¤t->restart_block;
|
|
return restart->fn(restart);
|
|
}
|
|
|
|
long do_no_restart_syscall(struct restart_block *param)
|
|
{
|
|
return -EINTR;
|
|
}
|
|
|
|
static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset)
|
|
{
|
|
if (signal_pending(tsk) && !thread_group_empty(tsk)) {
|
|
sigset_t newblocked;
|
|
/* A set of now blocked but previously unblocked signals. */
|
|
sigandnsets(&newblocked, newset, ¤t->blocked);
|
|
retarget_shared_pending(tsk, &newblocked);
|
|
}
|
|
tsk->blocked = *newset;
|
|
recalc_sigpending();
|
|
}
|
|
|
|
/**
|
|
* set_current_blocked - change current->blocked mask
|
|
* @newset: new mask
|
|
*
|
|
* It is wrong to change ->blocked directly, this helper should be used
|
|
* to ensure the process can't miss a shared signal we are going to block.
|
|
*/
|
|
void set_current_blocked(sigset_t *newset)
|
|
{
|
|
sigdelsetmask(newset, sigmask(SIGKILL) | sigmask(SIGSTOP));
|
|
__set_current_blocked(newset);
|
|
}
|
|
|
|
void __set_current_blocked(const sigset_t *newset)
|
|
{
|
|
struct task_struct *tsk = current;
|
|
|
|
/*
|
|
* In case the signal mask hasn't changed, there is nothing we need
|
|
* to do. The current->blocked shouldn't be modified by other task.
|
|
*/
|
|
if (sigequalsets(&tsk->blocked, newset))
|
|
return;
|
|
|
|
spin_lock_irq(&tsk->sighand->siglock);
|
|
__set_task_blocked(tsk, newset);
|
|
spin_unlock_irq(&tsk->sighand->siglock);
|
|
}
|
|
|
|
/*
|
|
* This is also useful for kernel threads that want to temporarily
|
|
* (or permanently) block certain signals.
|
|
*
|
|
* NOTE! Unlike the user-mode sys_sigprocmask(), the kernel
|
|
* interface happily blocks "unblockable" signals like SIGKILL
|
|
* and friends.
|
|
*/
|
|
int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
|
|
{
|
|
struct task_struct *tsk = current;
|
|
sigset_t newset;
|
|
|
|
/* Lockless, only current can change ->blocked, never from irq */
|
|
if (oldset)
|
|
*oldset = tsk->blocked;
|
|
|
|
switch (how) {
|
|
case SIG_BLOCK:
|
|
sigorsets(&newset, &tsk->blocked, set);
|
|
break;
|
|
case SIG_UNBLOCK:
|
|
sigandnsets(&newset, &tsk->blocked, set);
|
|
break;
|
|
case SIG_SETMASK:
|
|
newset = *set;
|
|
break;
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
|
|
__set_current_blocked(&newset);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(sigprocmask);
|
|
|
|
/*
|
|
* The api helps set app-provided sigmasks.
|
|
*
|
|
* This is useful for syscalls such as ppoll, pselect, io_pgetevents and
|
|
* epoll_pwait where a new sigmask is passed from userland for the syscalls.
|
|
*
|
|
* Note that it does set_restore_sigmask() in advance, so it must be always
|
|
* paired with restore_saved_sigmask_unless() before return from syscall.
|
|
*/
|
|
int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize)
|
|
{
|
|
sigset_t kmask;
|
|
|
|
if (!umask)
|
|
return 0;
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
if (copy_from_user(&kmask, umask, sizeof(sigset_t)))
|
|
return -EFAULT;
|
|
|
|
set_restore_sigmask();
|
|
current->saved_sigmask = current->blocked;
|
|
set_current_blocked(&kmask);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
int set_compat_user_sigmask(const compat_sigset_t __user *umask,
|
|
size_t sigsetsize)
|
|
{
|
|
sigset_t kmask;
|
|
|
|
if (!umask)
|
|
return 0;
|
|
if (sigsetsize != sizeof(compat_sigset_t))
|
|
return -EINVAL;
|
|
if (get_compat_sigset(&kmask, umask))
|
|
return -EFAULT;
|
|
|
|
set_restore_sigmask();
|
|
current->saved_sigmask = current->blocked;
|
|
set_current_blocked(&kmask);
|
|
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
/**
|
|
* sys_rt_sigprocmask - change the list of currently blocked signals
|
|
* @how: whether to add, remove, or set signals
|
|
* @nset: stores pending signals
|
|
* @oset: previous value of signal mask if non-null
|
|
* @sigsetsize: size of sigset_t type
|
|
*/
|
|
SYSCALL_DEFINE4(rt_sigprocmask, int, how, sigset_t __user *, nset,
|
|
sigset_t __user *, oset, size_t, sigsetsize)
|
|
{
|
|
sigset_t old_set, new_set;
|
|
int error;
|
|
|
|
/* XXX: Don't preclude handling different sized sigset_t's. */
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
|
|
old_set = current->blocked;
|
|
|
|
if (nset) {
|
|
if (copy_from_user(&new_set, nset, sizeof(sigset_t)))
|
|
return -EFAULT;
|
|
sigdelsetmask(&new_set, sigmask(SIGKILL)|sigmask(SIGSTOP));
|
|
|
|
error = sigprocmask(how, &new_set, NULL);
|
|
if (error)
|
|
return error;
|
|
}
|
|
|
|
if (oset) {
|
|
if (copy_to_user(oset, &old_set, sizeof(sigset_t)))
|
|
return -EFAULT;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, nset,
|
|
compat_sigset_t __user *, oset, compat_size_t, sigsetsize)
|
|
{
|
|
sigset_t old_set = current->blocked;
|
|
|
|
/* XXX: Don't preclude handling different sized sigset_t's. */
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
|
|
if (nset) {
|
|
sigset_t new_set;
|
|
int error;
|
|
if (get_compat_sigset(&new_set, nset))
|
|
return -EFAULT;
|
|
sigdelsetmask(&new_set, sigmask(SIGKILL)|sigmask(SIGSTOP));
|
|
|
|
error = sigprocmask(how, &new_set, NULL);
|
|
if (error)
|
|
return error;
|
|
}
|
|
return oset ? put_compat_sigset(oset, &old_set, sizeof(*oset)) : 0;
|
|
}
|
|
#endif
|
|
|
|
static void do_sigpending(sigset_t *set)
|
|
{
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
sigorsets(set, ¤t->pending.signal,
|
|
¤t->signal->shared_pending.signal);
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
/* Outside the lock because only this thread touches it. */
|
|
sigandsets(set, ¤t->blocked, set);
|
|
}
|
|
|
|
/**
|
|
* sys_rt_sigpending - examine a pending signal that has been raised
|
|
* while blocked
|
|
* @uset: stores pending signals
|
|
* @sigsetsize: size of sigset_t type or larger
|
|
*/
|
|
SYSCALL_DEFINE2(rt_sigpending, sigset_t __user *, uset, size_t, sigsetsize)
|
|
{
|
|
sigset_t set;
|
|
|
|
if (sigsetsize > sizeof(*uset))
|
|
return -EINVAL;
|
|
|
|
do_sigpending(&set);
|
|
|
|
if (copy_to_user(uset, &set, sigsetsize))
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
COMPAT_SYSCALL_DEFINE2(rt_sigpending, compat_sigset_t __user *, uset,
|
|
compat_size_t, sigsetsize)
|
|
{
|
|
sigset_t set;
|
|
|
|
if (sigsetsize > sizeof(*uset))
|
|
return -EINVAL;
|
|
|
|
do_sigpending(&set);
|
|
|
|
return put_compat_sigset(uset, &set, sigsetsize);
|
|
}
|
|
#endif
|
|
|
|
static const struct {
|
|
unsigned char limit, layout;
|
|
} sig_sicodes[] = {
|
|
[SIGILL] = { NSIGILL, SIL_FAULT },
|
|
[SIGFPE] = { NSIGFPE, SIL_FAULT },
|
|
[SIGSEGV] = { NSIGSEGV, SIL_FAULT },
|
|
[SIGBUS] = { NSIGBUS, SIL_FAULT },
|
|
[SIGTRAP] = { NSIGTRAP, SIL_FAULT },
|
|
#if defined(SIGEMT)
|
|
[SIGEMT] = { NSIGEMT, SIL_FAULT },
|
|
#endif
|
|
[SIGCHLD] = { NSIGCHLD, SIL_CHLD },
|
|
[SIGPOLL] = { NSIGPOLL, SIL_POLL },
|
|
[SIGSYS] = { NSIGSYS, SIL_SYS },
|
|
};
|
|
|
|
static bool known_siginfo_layout(unsigned sig, int si_code)
|
|
{
|
|
if (si_code == SI_KERNEL)
|
|
return true;
|
|
else if ((si_code > SI_USER)) {
|
|
if (sig_specific_sicodes(sig)) {
|
|
if (si_code <= sig_sicodes[sig].limit)
|
|
return true;
|
|
}
|
|
else if (si_code <= NSIGPOLL)
|
|
return true;
|
|
}
|
|
else if (si_code >= SI_DETHREAD)
|
|
return true;
|
|
else if (si_code == SI_ASYNCNL)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
enum siginfo_layout siginfo_layout(unsigned sig, int si_code)
|
|
{
|
|
enum siginfo_layout layout = SIL_KILL;
|
|
if ((si_code > SI_USER) && (si_code < SI_KERNEL)) {
|
|
if ((sig < ARRAY_SIZE(sig_sicodes)) &&
|
|
(si_code <= sig_sicodes[sig].limit)) {
|
|
layout = sig_sicodes[sig].layout;
|
|
/* Handle the exceptions */
|
|
if ((sig == SIGBUS) &&
|
|
(si_code >= BUS_MCEERR_AR) && (si_code <= BUS_MCEERR_AO))
|
|
layout = SIL_FAULT_MCEERR;
|
|
else if ((sig == SIGSEGV) && (si_code == SEGV_BNDERR))
|
|
layout = SIL_FAULT_BNDERR;
|
|
#ifdef SEGV_PKUERR
|
|
else if ((sig == SIGSEGV) && (si_code == SEGV_PKUERR))
|
|
layout = SIL_FAULT_PKUERR;
|
|
#endif
|
|
}
|
|
else if (si_code <= NSIGPOLL)
|
|
layout = SIL_POLL;
|
|
} else {
|
|
if (si_code == SI_TIMER)
|
|
layout = SIL_TIMER;
|
|
else if (si_code == SI_SIGIO)
|
|
layout = SIL_POLL;
|
|
else if (si_code < 0)
|
|
layout = SIL_RT;
|
|
}
|
|
return layout;
|
|
}
|
|
|
|
static inline char __user *si_expansion(const siginfo_t __user *info)
|
|
{
|
|
return ((char __user *)info) + sizeof(struct kernel_siginfo);
|
|
}
|
|
|
|
int copy_siginfo_to_user(siginfo_t __user *to, const kernel_siginfo_t *from)
|
|
{
|
|
char __user *expansion = si_expansion(to);
|
|
if (copy_to_user(to, from , sizeof(struct kernel_siginfo)))
|
|
return -EFAULT;
|
|
if (clear_user(expansion, SI_EXPANSION_SIZE))
|
|
return -EFAULT;
|
|
return 0;
|
|
}
|
|
|
|
static int post_copy_siginfo_from_user(kernel_siginfo_t *info,
|
|
const siginfo_t __user *from)
|
|
{
|
|
if (unlikely(!known_siginfo_layout(info->si_signo, info->si_code))) {
|
|
char __user *expansion = si_expansion(from);
|
|
char buf[SI_EXPANSION_SIZE];
|
|
int i;
|
|
/*
|
|
* An unknown si_code might need more than
|
|
* sizeof(struct kernel_siginfo) bytes. Verify all of the
|
|
* extra bytes are 0. This guarantees copy_siginfo_to_user
|
|
* will return this data to userspace exactly.
|
|
*/
|
|
if (copy_from_user(&buf, expansion, SI_EXPANSION_SIZE))
|
|
return -EFAULT;
|
|
for (i = 0; i < SI_EXPANSION_SIZE; i++) {
|
|
if (buf[i] != 0)
|
|
return -E2BIG;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int __copy_siginfo_from_user(int signo, kernel_siginfo_t *to,
|
|
const siginfo_t __user *from)
|
|
{
|
|
if (copy_from_user(to, from, sizeof(struct kernel_siginfo)))
|
|
return -EFAULT;
|
|
to->si_signo = signo;
|
|
return post_copy_siginfo_from_user(to, from);
|
|
}
|
|
|
|
int copy_siginfo_from_user(kernel_siginfo_t *to, const siginfo_t __user *from)
|
|
{
|
|
if (copy_from_user(to, from, sizeof(struct kernel_siginfo)))
|
|
return -EFAULT;
|
|
return post_copy_siginfo_from_user(to, from);
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
int copy_siginfo_to_user32(struct compat_siginfo __user *to,
|
|
const struct kernel_siginfo *from)
|
|
#if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION)
|
|
{
|
|
return __copy_siginfo_to_user32(to, from, in_x32_syscall());
|
|
}
|
|
int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
|
|
const struct kernel_siginfo *from, bool x32_ABI)
|
|
#endif
|
|
{
|
|
struct compat_siginfo new;
|
|
memset(&new, 0, sizeof(new));
|
|
|
|
new.si_signo = from->si_signo;
|
|
new.si_errno = from->si_errno;
|
|
new.si_code = from->si_code;
|
|
switch(siginfo_layout(from->si_signo, from->si_code)) {
|
|
case SIL_KILL:
|
|
new.si_pid = from->si_pid;
|
|
new.si_uid = from->si_uid;
|
|
break;
|
|
case SIL_TIMER:
|
|
new.si_tid = from->si_tid;
|
|
new.si_overrun = from->si_overrun;
|
|
new.si_int = from->si_int;
|
|
break;
|
|
case SIL_POLL:
|
|
new.si_band = from->si_band;
|
|
new.si_fd = from->si_fd;
|
|
break;
|
|
case SIL_FAULT:
|
|
new.si_addr = ptr_to_compat(from->si_addr);
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
new.si_trapno = from->si_trapno;
|
|
#endif
|
|
break;
|
|
case SIL_FAULT_MCEERR:
|
|
new.si_addr = ptr_to_compat(from->si_addr);
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
new.si_trapno = from->si_trapno;
|
|
#endif
|
|
new.si_addr_lsb = from->si_addr_lsb;
|
|
break;
|
|
case SIL_FAULT_BNDERR:
|
|
new.si_addr = ptr_to_compat(from->si_addr);
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
new.si_trapno = from->si_trapno;
|
|
#endif
|
|
new.si_lower = ptr_to_compat(from->si_lower);
|
|
new.si_upper = ptr_to_compat(from->si_upper);
|
|
break;
|
|
case SIL_FAULT_PKUERR:
|
|
new.si_addr = ptr_to_compat(from->si_addr);
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
new.si_trapno = from->si_trapno;
|
|
#endif
|
|
new.si_pkey = from->si_pkey;
|
|
break;
|
|
case SIL_CHLD:
|
|
new.si_pid = from->si_pid;
|
|
new.si_uid = from->si_uid;
|
|
new.si_status = from->si_status;
|
|
#ifdef CONFIG_X86_X32_ABI
|
|
if (x32_ABI) {
|
|
new._sifields._sigchld_x32._utime = from->si_utime;
|
|
new._sifields._sigchld_x32._stime = from->si_stime;
|
|
} else
|
|
#endif
|
|
{
|
|
new.si_utime = from->si_utime;
|
|
new.si_stime = from->si_stime;
|
|
}
|
|
break;
|
|
case SIL_RT:
|
|
new.si_pid = from->si_pid;
|
|
new.si_uid = from->si_uid;
|
|
new.si_int = from->si_int;
|
|
break;
|
|
case SIL_SYS:
|
|
new.si_call_addr = ptr_to_compat(from->si_call_addr);
|
|
new.si_syscall = from->si_syscall;
|
|
new.si_arch = from->si_arch;
|
|
break;
|
|
}
|
|
|
|
if (copy_to_user(to, &new, sizeof(struct compat_siginfo)))
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int post_copy_siginfo_from_user32(kernel_siginfo_t *to,
|
|
const struct compat_siginfo *from)
|
|
{
|
|
clear_siginfo(to);
|
|
to->si_signo = from->si_signo;
|
|
to->si_errno = from->si_errno;
|
|
to->si_code = from->si_code;
|
|
switch(siginfo_layout(from->si_signo, from->si_code)) {
|
|
case SIL_KILL:
|
|
to->si_pid = from->si_pid;
|
|
to->si_uid = from->si_uid;
|
|
break;
|
|
case SIL_TIMER:
|
|
to->si_tid = from->si_tid;
|
|
to->si_overrun = from->si_overrun;
|
|
to->si_int = from->si_int;
|
|
break;
|
|
case SIL_POLL:
|
|
to->si_band = from->si_band;
|
|
to->si_fd = from->si_fd;
|
|
break;
|
|
case SIL_FAULT:
|
|
to->si_addr = compat_ptr(from->si_addr);
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
to->si_trapno = from->si_trapno;
|
|
#endif
|
|
break;
|
|
case SIL_FAULT_MCEERR:
|
|
to->si_addr = compat_ptr(from->si_addr);
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
to->si_trapno = from->si_trapno;
|
|
#endif
|
|
to->si_addr_lsb = from->si_addr_lsb;
|
|
break;
|
|
case SIL_FAULT_BNDERR:
|
|
to->si_addr = compat_ptr(from->si_addr);
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
to->si_trapno = from->si_trapno;
|
|
#endif
|
|
to->si_lower = compat_ptr(from->si_lower);
|
|
to->si_upper = compat_ptr(from->si_upper);
|
|
break;
|
|
case SIL_FAULT_PKUERR:
|
|
to->si_addr = compat_ptr(from->si_addr);
|
|
#ifdef __ARCH_SI_TRAPNO
|
|
to->si_trapno = from->si_trapno;
|
|
#endif
|
|
to->si_pkey = from->si_pkey;
|
|
break;
|
|
case SIL_CHLD:
|
|
to->si_pid = from->si_pid;
|
|
to->si_uid = from->si_uid;
|
|
to->si_status = from->si_status;
|
|
#ifdef CONFIG_X86_X32_ABI
|
|
if (in_x32_syscall()) {
|
|
to->si_utime = from->_sifields._sigchld_x32._utime;
|
|
to->si_stime = from->_sifields._sigchld_x32._stime;
|
|
} else
|
|
#endif
|
|
{
|
|
to->si_utime = from->si_utime;
|
|
to->si_stime = from->si_stime;
|
|
}
|
|
break;
|
|
case SIL_RT:
|
|
to->si_pid = from->si_pid;
|
|
to->si_uid = from->si_uid;
|
|
to->si_int = from->si_int;
|
|
break;
|
|
case SIL_SYS:
|
|
to->si_call_addr = compat_ptr(from->si_call_addr);
|
|
to->si_syscall = from->si_syscall;
|
|
to->si_arch = from->si_arch;
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int __copy_siginfo_from_user32(int signo, struct kernel_siginfo *to,
|
|
const struct compat_siginfo __user *ufrom)
|
|
{
|
|
struct compat_siginfo from;
|
|
|
|
if (copy_from_user(&from, ufrom, sizeof(struct compat_siginfo)))
|
|
return -EFAULT;
|
|
|
|
from.si_signo = signo;
|
|
return post_copy_siginfo_from_user32(to, &from);
|
|
}
|
|
|
|
int copy_siginfo_from_user32(struct kernel_siginfo *to,
|
|
const struct compat_siginfo __user *ufrom)
|
|
{
|
|
struct compat_siginfo from;
|
|
|
|
if (copy_from_user(&from, ufrom, sizeof(struct compat_siginfo)))
|
|
return -EFAULT;
|
|
|
|
return post_copy_siginfo_from_user32(to, &from);
|
|
}
|
|
#endif /* CONFIG_COMPAT */
|
|
|
|
/**
|
|
* do_sigtimedwait - wait for queued signals specified in @which
|
|
* @which: queued signals to wait for
|
|
* @info: if non-null, the signal's siginfo is returned here
|
|
* @ts: upper bound on process time suspension
|
|
*/
|
|
static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,
|
|
const struct timespec64 *ts)
|
|
{
|
|
ktime_t *to = NULL, timeout = KTIME_MAX;
|
|
struct task_struct *tsk = current;
|
|
sigset_t mask = *which;
|
|
int sig, ret = 0;
|
|
|
|
if (ts) {
|
|
if (!timespec64_valid(ts))
|
|
return -EINVAL;
|
|
timeout = timespec64_to_ktime(*ts);
|
|
to = &timeout;
|
|
}
|
|
|
|
/*
|
|
* Invert the set of allowed signals to get those we want to block.
|
|
*/
|
|
sigdelsetmask(&mask, sigmask(SIGKILL) | sigmask(SIGSTOP));
|
|
signotset(&mask);
|
|
|
|
spin_lock_irq(&tsk->sighand->siglock);
|
|
sig = dequeue_signal(tsk, &mask, info);
|
|
if (!sig && timeout) {
|
|
/*
|
|
* None ready, temporarily unblock those we're interested
|
|
* while we are sleeping in so that we'll be awakened when
|
|
* they arrive. Unblocking is always fine, we can avoid
|
|
* set_current_blocked().
|
|
*/
|
|
tsk->real_blocked = tsk->blocked;
|
|
sigandsets(&tsk->blocked, &tsk->blocked, &mask);
|
|
recalc_sigpending();
|
|
spin_unlock_irq(&tsk->sighand->siglock);
|
|
|
|
__set_current_state(TASK_INTERRUPTIBLE);
|
|
ret = freezable_schedule_hrtimeout_range(to, tsk->timer_slack_ns,
|
|
HRTIMER_MODE_REL);
|
|
spin_lock_irq(&tsk->sighand->siglock);
|
|
__set_task_blocked(tsk, &tsk->real_blocked);
|
|
sigemptyset(&tsk->real_blocked);
|
|
sig = dequeue_signal(tsk, &mask, info);
|
|
}
|
|
spin_unlock_irq(&tsk->sighand->siglock);
|
|
|
|
if (sig)
|
|
return sig;
|
|
return ret ? -EINTR : -EAGAIN;
|
|
}
|
|
|
|
/**
|
|
* sys_rt_sigtimedwait - synchronously wait for queued signals specified
|
|
* in @uthese
|
|
* @uthese: queued signals to wait for
|
|
* @uinfo: if non-null, the signal's siginfo is returned here
|
|
* @uts: upper bound on process time suspension
|
|
* @sigsetsize: size of sigset_t type
|
|
*/
|
|
SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese,
|
|
siginfo_t __user *, uinfo,
|
|
const struct __kernel_timespec __user *, uts,
|
|
size_t, sigsetsize)
|
|
{
|
|
sigset_t these;
|
|
struct timespec64 ts;
|
|
kernel_siginfo_t info;
|
|
int ret;
|
|
|
|
/* XXX: Don't preclude handling different sized sigset_t's. */
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
|
|
if (copy_from_user(&these, uthese, sizeof(these)))
|
|
return -EFAULT;
|
|
|
|
if (uts) {
|
|
if (get_timespec64(&ts, uts))
|
|
return -EFAULT;
|
|
}
|
|
|
|
ret = do_sigtimedwait(&these, &info, uts ? &ts : NULL);
|
|
|
|
if (ret > 0 && uinfo) {
|
|
if (copy_siginfo_to_user(uinfo, &info))
|
|
ret = -EFAULT;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT_32BIT_TIME
|
|
SYSCALL_DEFINE4(rt_sigtimedwait_time32, const sigset_t __user *, uthese,
|
|
siginfo_t __user *, uinfo,
|
|
const struct old_timespec32 __user *, uts,
|
|
size_t, sigsetsize)
|
|
{
|
|
sigset_t these;
|
|
struct timespec64 ts;
|
|
kernel_siginfo_t info;
|
|
int ret;
|
|
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
|
|
if (copy_from_user(&these, uthese, sizeof(these)))
|
|
return -EFAULT;
|
|
|
|
if (uts) {
|
|
if (get_old_timespec32(&ts, uts))
|
|
return -EFAULT;
|
|
}
|
|
|
|
ret = do_sigtimedwait(&these, &info, uts ? &ts : NULL);
|
|
|
|
if (ret > 0 && uinfo) {
|
|
if (copy_siginfo_to_user(uinfo, &info))
|
|
ret = -EFAULT;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait_time64, compat_sigset_t __user *, uthese,
|
|
struct compat_siginfo __user *, uinfo,
|
|
struct __kernel_timespec __user *, uts, compat_size_t, sigsetsize)
|
|
{
|
|
sigset_t s;
|
|
struct timespec64 t;
|
|
kernel_siginfo_t info;
|
|
long ret;
|
|
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
|
|
if (get_compat_sigset(&s, uthese))
|
|
return -EFAULT;
|
|
|
|
if (uts) {
|
|
if (get_timespec64(&t, uts))
|
|
return -EFAULT;
|
|
}
|
|
|
|
ret = do_sigtimedwait(&s, &info, uts ? &t : NULL);
|
|
|
|
if (ret > 0 && uinfo) {
|
|
if (copy_siginfo_to_user32(uinfo, &info))
|
|
ret = -EFAULT;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT_32BIT_TIME
|
|
COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait_time32, compat_sigset_t __user *, uthese,
|
|
struct compat_siginfo __user *, uinfo,
|
|
struct old_timespec32 __user *, uts, compat_size_t, sigsetsize)
|
|
{
|
|
sigset_t s;
|
|
struct timespec64 t;
|
|
kernel_siginfo_t info;
|
|
long ret;
|
|
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
|
|
if (get_compat_sigset(&s, uthese))
|
|
return -EFAULT;
|
|
|
|
if (uts) {
|
|
if (get_old_timespec32(&t, uts))
|
|
return -EFAULT;
|
|
}
|
|
|
|
ret = do_sigtimedwait(&s, &info, uts ? &t : NULL);
|
|
|
|
if (ret > 0 && uinfo) {
|
|
if (copy_siginfo_to_user32(uinfo, &info))
|
|
ret = -EFAULT;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
static inline void prepare_kill_siginfo(int sig, struct kernel_siginfo *info)
|
|
{
|
|
clear_siginfo(info);
|
|
info->si_signo = sig;
|
|
info->si_errno = 0;
|
|
info->si_code = SI_USER;
|
|
info->si_pid = task_tgid_vnr(current);
|
|
info->si_uid = from_kuid_munged(current_user_ns(), current_uid());
|
|
}
|
|
|
|
/**
|
|
* sys_kill - send a signal to a process
|
|
* @pid: the PID of the process
|
|
* @sig: signal to be sent
|
|
*/
|
|
SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
prepare_kill_siginfo(sig, &info);
|
|
|
|
return kill_something_info(sig, &info, pid);
|
|
}
|
|
|
|
/*
|
|
* Verify that the signaler and signalee either are in the same pid namespace
|
|
* or that the signaler's pid namespace is an ancestor of the signalee's pid
|
|
* namespace.
|
|
*/
|
|
static bool access_pidfd_pidns(struct pid *pid)
|
|
{
|
|
struct pid_namespace *active = task_active_pid_ns(current);
|
|
struct pid_namespace *p = ns_of_pid(pid);
|
|
|
|
for (;;) {
|
|
if (!p)
|
|
return false;
|
|
if (p == active)
|
|
break;
|
|
p = p->parent;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
static int copy_siginfo_from_user_any(kernel_siginfo_t *kinfo, siginfo_t *info)
|
|
{
|
|
#ifdef CONFIG_COMPAT
|
|
/*
|
|
* Avoid hooking up compat syscalls and instead handle necessary
|
|
* conversions here. Note, this is a stop-gap measure and should not be
|
|
* considered a generic solution.
|
|
*/
|
|
if (in_compat_syscall())
|
|
return copy_siginfo_from_user32(
|
|
kinfo, (struct compat_siginfo __user *)info);
|
|
#endif
|
|
return copy_siginfo_from_user(kinfo, info);
|
|
}
|
|
|
|
static struct pid *pidfd_to_pid(const struct file *file)
|
|
{
|
|
struct pid *pid;
|
|
|
|
pid = pidfd_pid(file);
|
|
if (!IS_ERR(pid))
|
|
return pid;
|
|
|
|
return tgid_pidfd_to_pid(file);
|
|
}
|
|
|
|
/**
|
|
* sys_pidfd_send_signal - Signal a process through a pidfd
|
|
* @pidfd: file descriptor of the process
|
|
* @sig: signal to send
|
|
* @info: signal info
|
|
* @flags: future flags
|
|
*
|
|
* The syscall currently only signals via PIDTYPE_PID which covers
|
|
* kill(<positive-pid>, <signal>. It does not signal threads or process
|
|
* groups.
|
|
* In order to extend the syscall to threads and process groups the @flags
|
|
* argument should be used. In essence, the @flags argument will determine
|
|
* what is signaled and not the file descriptor itself. Put in other words,
|
|
* grouping is a property of the flags argument not a property of the file
|
|
* descriptor.
|
|
*
|
|
* Return: 0 on success, negative errno on failure
|
|
*/
|
|
SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig,
|
|
siginfo_t __user *, info, unsigned int, flags)
|
|
{
|
|
int ret;
|
|
struct fd f;
|
|
struct pid *pid;
|
|
kernel_siginfo_t kinfo;
|
|
|
|
/* Enforce flags be set to 0 until we add an extension. */
|
|
if (flags)
|
|
return -EINVAL;
|
|
|
|
f = fdget(pidfd);
|
|
if (!f.file)
|
|
return -EBADF;
|
|
|
|
/* Is this a pidfd? */
|
|
pid = pidfd_to_pid(f.file);
|
|
if (IS_ERR(pid)) {
|
|
ret = PTR_ERR(pid);
|
|
goto err;
|
|
}
|
|
|
|
ret = -EINVAL;
|
|
if (!access_pidfd_pidns(pid))
|
|
goto err;
|
|
|
|
if (info) {
|
|
ret = copy_siginfo_from_user_any(&kinfo, info);
|
|
if (unlikely(ret))
|
|
goto err;
|
|
|
|
ret = -EINVAL;
|
|
if (unlikely(sig != kinfo.si_signo))
|
|
goto err;
|
|
|
|
/* Only allow sending arbitrary signals to yourself. */
|
|
ret = -EPERM;
|
|
if ((task_pid(current) != pid) &&
|
|
(kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL))
|
|
goto err;
|
|
} else {
|
|
prepare_kill_siginfo(sig, &kinfo);
|
|
}
|
|
|
|
ret = kill_pid_info(sig, &kinfo, pid);
|
|
|
|
err:
|
|
fdput(f);
|
|
return ret;
|
|
}
|
|
|
|
static int
|
|
do_send_specific(pid_t tgid, pid_t pid, int sig, struct kernel_siginfo *info)
|
|
{
|
|
struct task_struct *p;
|
|
int error = -ESRCH;
|
|
|
|
rcu_read_lock();
|
|
p = find_task_by_vpid(pid);
|
|
if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
|
|
error = check_kill_permission(sig, info, p);
|
|
/*
|
|
* The null signal is a permissions and process existence
|
|
* probe. No signal is actually delivered.
|
|
*/
|
|
if (!error && sig) {
|
|
error = do_send_sig_info(sig, info, p, PIDTYPE_PID);
|
|
/*
|
|
* If lock_task_sighand() failed we pretend the task
|
|
* dies after receiving the signal. The window is tiny,
|
|
* and the signal is private anyway.
|
|
*/
|
|
if (unlikely(error == -ESRCH))
|
|
error = 0;
|
|
}
|
|
}
|
|
rcu_read_unlock();
|
|
|
|
return error;
|
|
}
|
|
|
|
static int do_tkill(pid_t tgid, pid_t pid, int sig)
|
|
{
|
|
struct kernel_siginfo info;
|
|
|
|
clear_siginfo(&info);
|
|
info.si_signo = sig;
|
|
info.si_errno = 0;
|
|
info.si_code = SI_TKILL;
|
|
info.si_pid = task_tgid_vnr(current);
|
|
info.si_uid = from_kuid_munged(current_user_ns(), current_uid());
|
|
|
|
return do_send_specific(tgid, pid, sig, &info);
|
|
}
|
|
|
|
/**
|
|
* sys_tgkill - send signal to one specific thread
|
|
* @tgid: the thread group ID of the thread
|
|
* @pid: the PID of the thread
|
|
* @sig: signal to be sent
|
|
*
|
|
* This syscall also checks the @tgid and returns -ESRCH even if the PID
|
|
* exists but it's not belonging to the target process anymore. This
|
|
* method solves the problem of threads exiting and PIDs getting reused.
|
|
*/
|
|
SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid_t, pid, int, sig)
|
|
{
|
|
/* This is only valid for single tasks */
|
|
if (pid <= 0 || tgid <= 0)
|
|
return -EINVAL;
|
|
|
|
return do_tkill(tgid, pid, sig);
|
|
}
|
|
|
|
/**
|
|
* sys_tkill - send signal to one specific task
|
|
* @pid: the PID of the task
|
|
* @sig: signal to be sent
|
|
*
|
|
* Send a signal to only one task, even if it's a CLONE_THREAD task.
|
|
*/
|
|
SYSCALL_DEFINE2(tkill, pid_t, pid, int, sig)
|
|
{
|
|
/* This is only valid for single tasks */
|
|
if (pid <= 0)
|
|
return -EINVAL;
|
|
|
|
return do_tkill(0, pid, sig);
|
|
}
|
|
|
|
static int do_rt_sigqueueinfo(pid_t pid, int sig, kernel_siginfo_t *info)
|
|
{
|
|
/* Not even root can pretend to send signals from the kernel.
|
|
* Nor can they impersonate a kill()/tgkill(), which adds source info.
|
|
*/
|
|
if ((info->si_code >= 0 || info->si_code == SI_TKILL) &&
|
|
(task_pid_vnr(current) != pid))
|
|
return -EPERM;
|
|
|
|
/* POSIX.1b doesn't mention process groups. */
|
|
return kill_proc_info(sig, info, pid);
|
|
}
|
|
|
|
/**
|
|
* sys_rt_sigqueueinfo - send signal information to a signal
|
|
* @pid: the PID of the thread
|
|
* @sig: signal to be sent
|
|
* @uinfo: signal info to be sent
|
|
*/
|
|
SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig,
|
|
siginfo_t __user *, uinfo)
|
|
{
|
|
kernel_siginfo_t info;
|
|
int ret = __copy_siginfo_from_user(sig, &info, uinfo);
|
|
if (unlikely(ret))
|
|
return ret;
|
|
return do_rt_sigqueueinfo(pid, sig, &info);
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo,
|
|
compat_pid_t, pid,
|
|
int, sig,
|
|
struct compat_siginfo __user *, uinfo)
|
|
{
|
|
kernel_siginfo_t info;
|
|
int ret = __copy_siginfo_from_user32(sig, &info, uinfo);
|
|
if (unlikely(ret))
|
|
return ret;
|
|
return do_rt_sigqueueinfo(pid, sig, &info);
|
|
}
|
|
#endif
|
|
|
|
static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, kernel_siginfo_t *info)
|
|
{
|
|
/* This is only valid for single tasks */
|
|
if (pid <= 0 || tgid <= 0)
|
|
return -EINVAL;
|
|
|
|
/* Not even root can pretend to send signals from the kernel.
|
|
* Nor can they impersonate a kill()/tgkill(), which adds source info.
|
|
*/
|
|
if ((info->si_code >= 0 || info->si_code == SI_TKILL) &&
|
|
(task_pid_vnr(current) != pid))
|
|
return -EPERM;
|
|
|
|
return do_send_specific(tgid, pid, sig, info);
|
|
}
|
|
|
|
SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig,
|
|
siginfo_t __user *, uinfo)
|
|
{
|
|
kernel_siginfo_t info;
|
|
int ret = __copy_siginfo_from_user(sig, &info, uinfo);
|
|
if (unlikely(ret))
|
|
return ret;
|
|
return do_rt_tgsigqueueinfo(tgid, pid, sig, &info);
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
COMPAT_SYSCALL_DEFINE4(rt_tgsigqueueinfo,
|
|
compat_pid_t, tgid,
|
|
compat_pid_t, pid,
|
|
int, sig,
|
|
struct compat_siginfo __user *, uinfo)
|
|
{
|
|
kernel_siginfo_t info;
|
|
int ret = __copy_siginfo_from_user32(sig, &info, uinfo);
|
|
if (unlikely(ret))
|
|
return ret;
|
|
return do_rt_tgsigqueueinfo(tgid, pid, sig, &info);
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* For kthreads only, must not be used if cloned with CLONE_SIGHAND
|
|
*/
|
|
void kernel_sigaction(int sig, __sighandler_t action)
|
|
{
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
current->sighand->action[sig - 1].sa.sa_handler = action;
|
|
if (action == SIG_IGN) {
|
|
sigset_t mask;
|
|
|
|
sigemptyset(&mask);
|
|
sigaddset(&mask, sig);
|
|
|
|
flush_sigqueue_mask(&mask, ¤t->signal->shared_pending);
|
|
flush_sigqueue_mask(&mask, ¤t->pending);
|
|
recalc_sigpending();
|
|
}
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
}
|
|
EXPORT_SYMBOL(kernel_sigaction);
|
|
|
|
void __weak sigaction_compat_abi(struct k_sigaction *act,
|
|
struct k_sigaction *oact)
|
|
{
|
|
}
|
|
|
|
int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
|
|
{
|
|
struct task_struct *p = current, *t;
|
|
struct k_sigaction *k;
|
|
sigset_t mask;
|
|
|
|
if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
|
|
return -EINVAL;
|
|
|
|
k = &p->sighand->action[sig-1];
|
|
|
|
spin_lock_irq(&p->sighand->siglock);
|
|
if (oact)
|
|
*oact = *k;
|
|
|
|
sigaction_compat_abi(act, oact);
|
|
|
|
if (act) {
|
|
sigdelsetmask(&act->sa.sa_mask,
|
|
sigmask(SIGKILL) | sigmask(SIGSTOP));
|
|
*k = *act;
|
|
/*
|
|
* POSIX 3.3.1.3:
|
|
* "Setting a signal action to SIG_IGN for a signal that is
|
|
* pending shall cause the pending signal to be discarded,
|
|
* whether or not it is blocked."
|
|
*
|
|
* "Setting a signal action to SIG_DFL for a signal that is
|
|
* pending and whose default action is to ignore the signal
|
|
* (for example, SIGCHLD), shall cause the pending signal to
|
|
* be discarded, whether or not it is blocked"
|
|
*/
|
|
if (sig_handler_ignored(sig_handler(p, sig), sig)) {
|
|
sigemptyset(&mask);
|
|
sigaddset(&mask, sig);
|
|
flush_sigqueue_mask(&mask, &p->signal->shared_pending);
|
|
for_each_thread(p, t)
|
|
flush_sigqueue_mask(&mask, &t->pending);
|
|
}
|
|
}
|
|
|
|
spin_unlock_irq(&p->sighand->siglock);
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp,
|
|
size_t min_ss_size)
|
|
{
|
|
struct task_struct *t = current;
|
|
|
|
if (oss) {
|
|
memset(oss, 0, sizeof(stack_t));
|
|
oss->ss_sp = (void __user *) t->sas_ss_sp;
|
|
oss->ss_size = t->sas_ss_size;
|
|
oss->ss_flags = sas_ss_flags(sp) |
|
|
(current->sas_ss_flags & SS_FLAG_BITS);
|
|
}
|
|
|
|
if (ss) {
|
|
void __user *ss_sp = ss->ss_sp;
|
|
size_t ss_size = ss->ss_size;
|
|
unsigned ss_flags = ss->ss_flags;
|
|
int ss_mode;
|
|
|
|
if (unlikely(on_sig_stack(sp)))
|
|
return -EPERM;
|
|
|
|
ss_mode = ss_flags & ~SS_FLAG_BITS;
|
|
if (unlikely(ss_mode != SS_DISABLE && ss_mode != SS_ONSTACK &&
|
|
ss_mode != 0))
|
|
return -EINVAL;
|
|
|
|
if (ss_mode == SS_DISABLE) {
|
|
ss_size = 0;
|
|
ss_sp = NULL;
|
|
} else {
|
|
if (unlikely(ss_size < min_ss_size))
|
|
return -ENOMEM;
|
|
}
|
|
|
|
t->sas_ss_sp = (unsigned long) ss_sp;
|
|
t->sas_ss_size = ss_size;
|
|
t->sas_ss_flags = ss_flags;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
SYSCALL_DEFINE2(sigaltstack,const stack_t __user *,uss, stack_t __user *,uoss)
|
|
{
|
|
stack_t new, old;
|
|
int err;
|
|
if (uss && copy_from_user(&new, uss, sizeof(stack_t)))
|
|
return -EFAULT;
|
|
err = do_sigaltstack(uss ? &new : NULL, uoss ? &old : NULL,
|
|
current_user_stack_pointer(),
|
|
MINSIGSTKSZ);
|
|
if (!err && uoss && copy_to_user(uoss, &old, sizeof(stack_t)))
|
|
err = -EFAULT;
|
|
return err;
|
|
}
|
|
|
|
int restore_altstack(const stack_t __user *uss)
|
|
{
|
|
stack_t new;
|
|
if (copy_from_user(&new, uss, sizeof(stack_t)))
|
|
return -EFAULT;
|
|
(void)do_sigaltstack(&new, NULL, current_user_stack_pointer(),
|
|
MINSIGSTKSZ);
|
|
/* squash all but EFAULT for now */
|
|
return 0;
|
|
}
|
|
|
|
int __save_altstack(stack_t __user *uss, unsigned long sp)
|
|
{
|
|
struct task_struct *t = current;
|
|
int err = __put_user((void __user *)t->sas_ss_sp, &uss->ss_sp) |
|
|
__put_user(t->sas_ss_flags, &uss->ss_flags) |
|
|
__put_user(t->sas_ss_size, &uss->ss_size);
|
|
if (err)
|
|
return err;
|
|
if (t->sas_ss_flags & SS_AUTODISARM)
|
|
sas_ss_reset(t);
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
static int do_compat_sigaltstack(const compat_stack_t __user *uss_ptr,
|
|
compat_stack_t __user *uoss_ptr)
|
|
{
|
|
stack_t uss, uoss;
|
|
int ret;
|
|
|
|
if (uss_ptr) {
|
|
compat_stack_t uss32;
|
|
if (copy_from_user(&uss32, uss_ptr, sizeof(compat_stack_t)))
|
|
return -EFAULT;
|
|
uss.ss_sp = compat_ptr(uss32.ss_sp);
|
|
uss.ss_flags = uss32.ss_flags;
|
|
uss.ss_size = uss32.ss_size;
|
|
}
|
|
ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss,
|
|
compat_user_stack_pointer(),
|
|
COMPAT_MINSIGSTKSZ);
|
|
if (ret >= 0 && uoss_ptr) {
|
|
compat_stack_t old;
|
|
memset(&old, 0, sizeof(old));
|
|
old.ss_sp = ptr_to_compat(uoss.ss_sp);
|
|
old.ss_flags = uoss.ss_flags;
|
|
old.ss_size = uoss.ss_size;
|
|
if (copy_to_user(uoss_ptr, &old, sizeof(compat_stack_t)))
|
|
ret = -EFAULT;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
COMPAT_SYSCALL_DEFINE2(sigaltstack,
|
|
const compat_stack_t __user *, uss_ptr,
|
|
compat_stack_t __user *, uoss_ptr)
|
|
{
|
|
return do_compat_sigaltstack(uss_ptr, uoss_ptr);
|
|
}
|
|
|
|
int compat_restore_altstack(const compat_stack_t __user *uss)
|
|
{
|
|
int err = do_compat_sigaltstack(uss, NULL);
|
|
/* squash all but -EFAULT for now */
|
|
return err == -EFAULT ? err : 0;
|
|
}
|
|
|
|
int __compat_save_altstack(compat_stack_t __user *uss, unsigned long sp)
|
|
{
|
|
int err;
|
|
struct task_struct *t = current;
|
|
err = __put_user(ptr_to_compat((void __user *)t->sas_ss_sp),
|
|
&uss->ss_sp) |
|
|
__put_user(t->sas_ss_flags, &uss->ss_flags) |
|
|
__put_user(t->sas_ss_size, &uss->ss_size);
|
|
if (err)
|
|
return err;
|
|
if (t->sas_ss_flags & SS_AUTODISARM)
|
|
sas_ss_reset(t);
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#ifdef __ARCH_WANT_SYS_SIGPENDING
|
|
|
|
/**
|
|
* sys_sigpending - examine pending signals
|
|
* @uset: where mask of pending signal is returned
|
|
*/
|
|
SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, uset)
|
|
{
|
|
sigset_t set;
|
|
|
|
if (sizeof(old_sigset_t) > sizeof(*uset))
|
|
return -EINVAL;
|
|
|
|
do_sigpending(&set);
|
|
|
|
if (copy_to_user(uset, &set, sizeof(old_sigset_t)))
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set32)
|
|
{
|
|
sigset_t set;
|
|
|
|
do_sigpending(&set);
|
|
|
|
return put_user(set.sig[0], set32);
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef __ARCH_WANT_SYS_SIGPROCMASK
|
|
/**
|
|
* sys_sigprocmask - examine and change blocked signals
|
|
* @how: whether to add, remove, or set signals
|
|
* @nset: signals to add or remove (if non-null)
|
|
* @oset: previous value of signal mask if non-null
|
|
*
|
|
* Some platforms have their own version with special arguments;
|
|
* others support only sys_rt_sigprocmask.
|
|
*/
|
|
|
|
SYSCALL_DEFINE3(sigprocmask, int, how, old_sigset_t __user *, nset,
|
|
old_sigset_t __user *, oset)
|
|
{
|
|
old_sigset_t old_set, new_set;
|
|
sigset_t new_blocked;
|
|
|
|
old_set = current->blocked.sig[0];
|
|
|
|
if (nset) {
|
|
if (copy_from_user(&new_set, nset, sizeof(*nset)))
|
|
return -EFAULT;
|
|
|
|
new_blocked = current->blocked;
|
|
|
|
switch (how) {
|
|
case SIG_BLOCK:
|
|
sigaddsetmask(&new_blocked, new_set);
|
|
break;
|
|
case SIG_UNBLOCK:
|
|
sigdelsetmask(&new_blocked, new_set);
|
|
break;
|
|
case SIG_SETMASK:
|
|
new_blocked.sig[0] = new_set;
|
|
break;
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
|
|
set_current_blocked(&new_blocked);
|
|
}
|
|
|
|
if (oset) {
|
|
if (copy_to_user(oset, &old_set, sizeof(*oset)))
|
|
return -EFAULT;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
#endif /* __ARCH_WANT_SYS_SIGPROCMASK */
|
|
|
|
#ifndef CONFIG_ODD_RT_SIGACTION
|
|
/**
|
|
* sys_rt_sigaction - alter an action taken by a process
|
|
* @sig: signal to be sent
|
|
* @act: new sigaction
|
|
* @oact: used to save the previous sigaction
|
|
* @sigsetsize: size of sigset_t type
|
|
*/
|
|
SYSCALL_DEFINE4(rt_sigaction, int, sig,
|
|
const struct sigaction __user *, act,
|
|
struct sigaction __user *, oact,
|
|
size_t, sigsetsize)
|
|
{
|
|
struct k_sigaction new_sa, old_sa;
|
|
int ret;
|
|
|
|
/* XXX: Don't preclude handling different sized sigset_t's. */
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
|
|
if (act && copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
|
|
return -EFAULT;
|
|
|
|
ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
|
|
if (ret)
|
|
return ret;
|
|
|
|
if (oact && copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
}
|
|
#ifdef CONFIG_COMPAT
|
|
COMPAT_SYSCALL_DEFINE4(rt_sigaction, int, sig,
|
|
const struct compat_sigaction __user *, act,
|
|
struct compat_sigaction __user *, oact,
|
|
compat_size_t, sigsetsize)
|
|
{
|
|
struct k_sigaction new_ka, old_ka;
|
|
#ifdef __ARCH_HAS_SA_RESTORER
|
|
compat_uptr_t restorer;
|
|
#endif
|
|
int ret;
|
|
|
|
/* XXX: Don't preclude handling different sized sigset_t's. */
|
|
if (sigsetsize != sizeof(compat_sigset_t))
|
|
return -EINVAL;
|
|
|
|
if (act) {
|
|
compat_uptr_t handler;
|
|
ret = get_user(handler, &act->sa_handler);
|
|
new_ka.sa.sa_handler = compat_ptr(handler);
|
|
#ifdef __ARCH_HAS_SA_RESTORER
|
|
ret |= get_user(restorer, &act->sa_restorer);
|
|
new_ka.sa.sa_restorer = compat_ptr(restorer);
|
|
#endif
|
|
ret |= get_compat_sigset(&new_ka.sa.sa_mask, &act->sa_mask);
|
|
ret |= get_user(new_ka.sa.sa_flags, &act->sa_flags);
|
|
if (ret)
|
|
return -EFAULT;
|
|
}
|
|
|
|
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
|
|
if (!ret && oact) {
|
|
ret = put_user(ptr_to_compat(old_ka.sa.sa_handler),
|
|
&oact->sa_handler);
|
|
ret |= put_compat_sigset(&oact->sa_mask, &old_ka.sa.sa_mask,
|
|
sizeof(oact->sa_mask));
|
|
ret |= put_user(old_ka.sa.sa_flags, &oact->sa_flags);
|
|
#ifdef __ARCH_HAS_SA_RESTORER
|
|
ret |= put_user(ptr_to_compat(old_ka.sa.sa_restorer),
|
|
&oact->sa_restorer);
|
|
#endif
|
|
}
|
|
return ret;
|
|
}
|
|
#endif
|
|
#endif /* !CONFIG_ODD_RT_SIGACTION */
|
|
|
|
#ifdef CONFIG_OLD_SIGACTION
|
|
SYSCALL_DEFINE3(sigaction, int, sig,
|
|
const struct old_sigaction __user *, act,
|
|
struct old_sigaction __user *, oact)
|
|
{
|
|
struct k_sigaction new_ka, old_ka;
|
|
int ret;
|
|
|
|
if (act) {
|
|
old_sigset_t mask;
|
|
if (!access_ok(act, sizeof(*act)) ||
|
|
__get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
|
|
__get_user(new_ka.sa.sa_restorer, &act->sa_restorer) ||
|
|
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
|
|
__get_user(mask, &act->sa_mask))
|
|
return -EFAULT;
|
|
#ifdef __ARCH_HAS_KA_RESTORER
|
|
new_ka.ka_restorer = NULL;
|
|
#endif
|
|
siginitset(&new_ka.sa.sa_mask, mask);
|
|
}
|
|
|
|
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
|
|
|
|
if (!ret && oact) {
|
|
if (!access_ok(oact, sizeof(*oact)) ||
|
|
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
|
|
__put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) ||
|
|
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
|
|
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
|
|
return -EFAULT;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endif
|
|
#ifdef CONFIG_COMPAT_OLD_SIGACTION
|
|
COMPAT_SYSCALL_DEFINE3(sigaction, int, sig,
|
|
const struct compat_old_sigaction __user *, act,
|
|
struct compat_old_sigaction __user *, oact)
|
|
{
|
|
struct k_sigaction new_ka, old_ka;
|
|
int ret;
|
|
compat_old_sigset_t mask;
|
|
compat_uptr_t handler, restorer;
|
|
|
|
if (act) {
|
|
if (!access_ok(act, sizeof(*act)) ||
|
|
__get_user(handler, &act->sa_handler) ||
|
|
__get_user(restorer, &act->sa_restorer) ||
|
|
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
|
|
__get_user(mask, &act->sa_mask))
|
|
return -EFAULT;
|
|
|
|
#ifdef __ARCH_HAS_KA_RESTORER
|
|
new_ka.ka_restorer = NULL;
|
|
#endif
|
|
new_ka.sa.sa_handler = compat_ptr(handler);
|
|
new_ka.sa.sa_restorer = compat_ptr(restorer);
|
|
siginitset(&new_ka.sa.sa_mask, mask);
|
|
}
|
|
|
|
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
|
|
|
|
if (!ret && oact) {
|
|
if (!access_ok(oact, sizeof(*oact)) ||
|
|
__put_user(ptr_to_compat(old_ka.sa.sa_handler),
|
|
&oact->sa_handler) ||
|
|
__put_user(ptr_to_compat(old_ka.sa.sa_restorer),
|
|
&oact->sa_restorer) ||
|
|
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
|
|
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
|
|
return -EFAULT;
|
|
}
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_SGETMASK_SYSCALL
|
|
|
|
/*
|
|
* For backwards compatibility. Functionality superseded by sigprocmask.
|
|
*/
|
|
SYSCALL_DEFINE0(sgetmask)
|
|
{
|
|
/* SMP safe */
|
|
return current->blocked.sig[0];
|
|
}
|
|
|
|
SYSCALL_DEFINE1(ssetmask, int, newmask)
|
|
{
|
|
int old = current->blocked.sig[0];
|
|
sigset_t newset;
|
|
|
|
siginitset(&newset, newmask);
|
|
set_current_blocked(&newset);
|
|
|
|
return old;
|
|
}
|
|
#endif /* CONFIG_SGETMASK_SYSCALL */
|
|
|
|
#ifdef __ARCH_WANT_SYS_SIGNAL
|
|
/*
|
|
* For backwards compatibility. Functionality superseded by sigaction.
|
|
*/
|
|
SYSCALL_DEFINE2(signal, int, sig, __sighandler_t, handler)
|
|
{
|
|
struct k_sigaction new_sa, old_sa;
|
|
int ret;
|
|
|
|
new_sa.sa.sa_handler = handler;
|
|
new_sa.sa.sa_flags = SA_ONESHOT | SA_NOMASK;
|
|
sigemptyset(&new_sa.sa.sa_mask);
|
|
|
|
ret = do_sigaction(sig, &new_sa, &old_sa);
|
|
|
|
return ret ? ret : (unsigned long)old_sa.sa.sa_handler;
|
|
}
|
|
#endif /* __ARCH_WANT_SYS_SIGNAL */
|
|
|
|
#ifdef __ARCH_WANT_SYS_PAUSE
|
|
|
|
SYSCALL_DEFINE0(pause)
|
|
{
|
|
while (!signal_pending(current)) {
|
|
__set_current_state(TASK_INTERRUPTIBLE);
|
|
schedule();
|
|
}
|
|
return -ERESTARTNOHAND;
|
|
}
|
|
|
|
#endif
|
|
|
|
static int sigsuspend(sigset_t *set)
|
|
{
|
|
current->saved_sigmask = current->blocked;
|
|
set_current_blocked(set);
|
|
|
|
while (!signal_pending(current)) {
|
|
__set_current_state(TASK_INTERRUPTIBLE);
|
|
schedule();
|
|
}
|
|
set_restore_sigmask();
|
|
return -ERESTARTNOHAND;
|
|
}
|
|
|
|
/**
|
|
* sys_rt_sigsuspend - replace the signal mask for a value with the
|
|
* @unewset value until a signal is received
|
|
* @unewset: new signal mask value
|
|
* @sigsetsize: size of sigset_t type
|
|
*/
|
|
SYSCALL_DEFINE2(rt_sigsuspend, sigset_t __user *, unewset, size_t, sigsetsize)
|
|
{
|
|
sigset_t newset;
|
|
|
|
/* XXX: Don't preclude handling different sized sigset_t's. */
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
|
|
if (copy_from_user(&newset, unewset, sizeof(newset)))
|
|
return -EFAULT;
|
|
return sigsuspend(&newset);
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
COMPAT_SYSCALL_DEFINE2(rt_sigsuspend, compat_sigset_t __user *, unewset, compat_size_t, sigsetsize)
|
|
{
|
|
sigset_t newset;
|
|
|
|
/* XXX: Don't preclude handling different sized sigset_t's. */
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
return -EINVAL;
|
|
|
|
if (get_compat_sigset(&newset, unewset))
|
|
return -EFAULT;
|
|
return sigsuspend(&newset);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_OLD_SIGSUSPEND
|
|
SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask)
|
|
{
|
|
sigset_t blocked;
|
|
siginitset(&blocked, mask);
|
|
return sigsuspend(&blocked);
|
|
}
|
|
#endif
|
|
#ifdef CONFIG_OLD_SIGSUSPEND3
|
|
SYSCALL_DEFINE3(sigsuspend, int, unused1, int, unused2, old_sigset_t, mask)
|
|
{
|
|
sigset_t blocked;
|
|
siginitset(&blocked, mask);
|
|
return sigsuspend(&blocked);
|
|
}
|
|
#endif
|
|
|
|
__weak const char *arch_vma_name(struct vm_area_struct *vma)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline void siginfo_buildtime_checks(void)
|
|
{
|
|
BUILD_BUG_ON(sizeof(struct siginfo) != SI_MAX_SIZE);
|
|
|
|
/* Verify the offsets in the two siginfos match */
|
|
#define CHECK_OFFSET(field) \
|
|
BUILD_BUG_ON(offsetof(siginfo_t, field) != offsetof(kernel_siginfo_t, field))
|
|
|
|
/* kill */
|
|
CHECK_OFFSET(si_pid);
|
|
CHECK_OFFSET(si_uid);
|
|
|
|
/* timer */
|
|
CHECK_OFFSET(si_tid);
|
|
CHECK_OFFSET(si_overrun);
|
|
CHECK_OFFSET(si_value);
|
|
|
|
/* rt */
|
|
CHECK_OFFSET(si_pid);
|
|
CHECK_OFFSET(si_uid);
|
|
CHECK_OFFSET(si_value);
|
|
|
|
/* sigchld */
|
|
CHECK_OFFSET(si_pid);
|
|
CHECK_OFFSET(si_uid);
|
|
CHECK_OFFSET(si_status);
|
|
CHECK_OFFSET(si_utime);
|
|
CHECK_OFFSET(si_stime);
|
|
|
|
/* sigfault */
|
|
CHECK_OFFSET(si_addr);
|
|
CHECK_OFFSET(si_addr_lsb);
|
|
CHECK_OFFSET(si_lower);
|
|
CHECK_OFFSET(si_upper);
|
|
CHECK_OFFSET(si_pkey);
|
|
|
|
/* sigpoll */
|
|
CHECK_OFFSET(si_band);
|
|
CHECK_OFFSET(si_fd);
|
|
|
|
/* sigsys */
|
|
CHECK_OFFSET(si_call_addr);
|
|
CHECK_OFFSET(si_syscall);
|
|
CHECK_OFFSET(si_arch);
|
|
#undef CHECK_OFFSET
|
|
|
|
/* usb asyncio */
|
|
BUILD_BUG_ON(offsetof(struct siginfo, si_pid) !=
|
|
offsetof(struct siginfo, si_addr));
|
|
if (sizeof(int) == sizeof(void __user *)) {
|
|
BUILD_BUG_ON(sizeof_field(struct siginfo, si_pid) !=
|
|
sizeof(void __user *));
|
|
} else {
|
|
BUILD_BUG_ON((sizeof_field(struct siginfo, si_pid) +
|
|
sizeof_field(struct siginfo, si_uid)) !=
|
|
sizeof(void __user *));
|
|
BUILD_BUG_ON(offsetofend(struct siginfo, si_pid) !=
|
|
offsetof(struct siginfo, si_uid));
|
|
}
|
|
#ifdef CONFIG_COMPAT
|
|
BUILD_BUG_ON(offsetof(struct compat_siginfo, si_pid) !=
|
|
offsetof(struct compat_siginfo, si_addr));
|
|
BUILD_BUG_ON(sizeof_field(struct compat_siginfo, si_pid) !=
|
|
sizeof(compat_uptr_t));
|
|
BUILD_BUG_ON(sizeof_field(struct compat_siginfo, si_pid) !=
|
|
sizeof_field(struct siginfo, si_pid));
|
|
#endif
|
|
}
|
|
|
|
void __init signals_init(void)
|
|
{
|
|
siginfo_buildtime_checks();
|
|
|
|
sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC);
|
|
}
|
|
|
|
#ifdef CONFIG_KGDB_KDB
|
|
#include <linux/kdb.h>
|
|
/*
|
|
* kdb_send_sig - Allows kdb to send signals without exposing
|
|
* signal internals. This function checks if the required locks are
|
|
* available before calling the main signal code, to avoid kdb
|
|
* deadlocks.
|
|
*/
|
|
void kdb_send_sig(struct task_struct *t, int sig)
|
|
{
|
|
static struct task_struct *kdb_prev_t;
|
|
int new_t, ret;
|
|
if (!spin_trylock(&t->sighand->siglock)) {
|
|
kdb_printf("Can't do kill command now.\n"
|
|
"The sigmask lock is held somewhere else in "
|
|
"kernel, try again later\n");
|
|
return;
|
|
}
|
|
new_t = kdb_prev_t != t;
|
|
kdb_prev_t = t;
|
|
if (t->state != TASK_RUNNING && new_t) {
|
|
spin_unlock(&t->sighand->siglock);
|
|
kdb_printf("Process is not RUNNING, sending a signal from "
|
|
"kdb risks deadlock\n"
|
|
"on the run queue locks. "
|
|
"The signal has _not_ been sent.\n"
|
|
"Reissue the kill command if you want to risk "
|
|
"the deadlock.\n");
|
|
return;
|
|
}
|
|
ret = send_signal(sig, SEND_SIG_PRIV, t, PIDTYPE_PID);
|
|
spin_unlock(&t->sighand->siglock);
|
|
if (ret)
|
|
kdb_printf("Fail to deliver Signal %d to process %d.\n",
|
|
sig, t->pid);
|
|
else
|
|
kdb_printf("Signal %d is sent to process %d.\n", sig, t->pid);
|
|
}
|
|
#endif /* CONFIG_KGDB_KDB */
|