Files
Greg Kroah-Hartman 2ed49dc1be Merge 5.10.238 into android12-5.10-lts
Changes in 5.10.238
	ALSA: usb-audio: Add second USB ID for Jabra Evolve 65 headset
	drm/nouveau: Fix WARN_ON in nouveau_fence_context_kill()
	EDAC/altera: Test the correct error reg offset
	EDAC/altera: Set DDR and SDMMC interrupt mask before registration
	i2c: imx-lpi2c: Fix clock count when probe defers
	parisc: Fix double SIGFPE crash
	amd-xgbe: Fix to ensure dependent features are toggled with RX checksum offload
	mmc: renesas_sdhi: Fix error handling in renesas_sdhi_probe
	wifi: brcm80211: fmac: Add error handling for brcmf_usb_dl_writeimage()
	dm-integrity: fix a warning on invalid table line
	dm: always update the array size in realloc_argv on success
	iommu/amd: Fix potential buffer overflow in parse_ivrs_acpihid
	iommu/vt-d: Apply quirk_iommu_igfx for 8086:0044 (QM57/QS57)
	tracing: Fix oob write in trace_seq_to_buffer()
	net/sched: act_mirred: don't override retval if we already lost the skb
	net/mlx5: E-Switch, Initialize MAC Address for Default GID
	net/mlx5: Remove return statement exist at the end of void function
	net/mlx5: E-switch, Fix error handling for enabling roce
	net_sched: drr: Fix double list add in class with netem as child qdisc
	net_sched: hfsc: Fix a UAF vulnerability in class with netem as child qdisc
	net_sched: ets: Fix double list add in class with netem as child qdisc
	net_sched: qfq: Fix double list add in class with netem as child qdisc
	net: dlink: Correct endianness handling of led_mode
	net: ipv6: fix UDPv6 GSO segmentation with NAT
	bnxt_en: Fix ethtool -d byte order for 32-bit values
	nvme-tcp: fix premature queue removal and I/O failover
	net: lan743x: Fix memleak issue when GSO enabled
	net: fec: ERR007885 Workaround for conventional TX
	PCI: imx6: Skip controller_id generation logic for i.MX7D
	of: module: add buffer overflow check in of_modalias()
	Revert "drm/meson: vclk: fix calculation of 59.94 fractional rates"
	irqchip/gic-v2m: Add const to of_device_id
	irqchip/gic-v2m: Mark a few functions __init
	irqchip/gic-v2m: Prevent use after free of gicv2m_get_fwnode()
	usb: chipidea: ci_hdrc_imx: use dev_err_probe()
	usb: chipidea: ci_hdrc_imx: implement usb_phy_init() error handling
	dm: fix copying after src array boundaries
	scsi: target: Fix WRITE_SAME No Data Buffer crash
	can: mcp251xfd: mcp251xfd_remove(): fix order of unregistration calls
	openvswitch: Fix unsafe attribute parsing in output_userspace()
	can: gw: use call_rcu() instead of costly synchronize_rcu()
	rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep()
	can: gw: fix RCU/BH usage in cgw_create_job()
	netfilter: ipset: fix region locking in hash types
	net: dsa: b53: allow leaky reserved multicast
	net: dsa: b53: fix VLAN ID for untagged vlan on bridge leave
	net: dsa: b53: fix learning on VLAN unaware bridges
	Input: synaptics - enable InterTouch on Dynabook Portege X30-D
	Input: synaptics - enable InterTouch on Dynabook Portege X30L-G
	Input: synaptics - enable InterTouch on Dell Precision M3800
	Input: synaptics - enable SMBus for HP Elitebook 850 G1
	Input: synaptics - enable InterTouch on TUXEDO InfinityBook Pro 14 v5
	staging: iio: adc: ad7816: Correct conditional logic for store mode
	staging: axis-fifo: Remove hardware resets for user errors
	staging: axis-fifo: Correct handling of tx_fifo_depth for size validation
	iio: adc: ad7606: fix serial register access
	iio: adis16201: Correct inclinometer channel resolution
	iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo
	iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_tagged_fifo
	usb: uhci-platform: Make the clock really optional
	xenbus: Use kref to track req lifetime
	module: ensure that kobject_put() is safe for module type kobjects
	ocfs2: switch osb->disable_recovery to enum
	ocfs2: implement handshaking with ocfs2 recovery thread
	ocfs2: stop quota recovery before disabling quotas
	usb: gadget: tegra-xudc: ACK ST_RC after clearing CTRL_RUN
	usb: host: tegra: Prevent host controller crash when OTG port is used
	usb: typec: tcpm: delay SNK_TRY_WAIT_DEBOUNCE to SRC_TRYWAIT transition
	usb: typec: ucsi: displayport: Fix NULL pointer access
	USB: usbtmc: use interruptible sleep in usbtmc_read
	usb: usbtmc: Fix erroneous get_stb ioctl error returns
	usb: usbtmc: Fix erroneous wait_srq ioctl return
	usb: usbtmc: Fix erroneous generic_read ioctl return
	types: Complement the aligned types with signed 64-bit one
	iio: adc: dln2: Use aligned_s64 for timestamp
	MIPS: Fix MAX_REG_OFFSET
	drm/panel: simple: Update timings for AUO G101EVN010
	nvme: unblock ctrl state transition for firmware update
	do_umount(): add missing barrier before refcount checks in sync case
	platform/x86: asus-wmi: Fix wlan_ctrl_by_user detection
	iio: adc: ad7768-1: Fix insufficient alignment of timestamp.
	iio: chemical: sps30: use aligned_s64 for timestamp
	RDMA/rxe: Fix slab-use-after-free Read in rxe_queue_cleanup bug
	nfs: handle failure of nfs_get_lock_context in unlock path
	spi: loopback-test: Do not split 1024-byte hexdumps
	net_sched: Flush gso_skb list too during ->change()
	net: cadence: macb: Fix a possible deadlock in macb_halt_tx.
	net: dsa: sja1105: discard incoming frames in BR_STATE_LISTENING
	ALSA: sh: SND_AICA should depend on SH_DMA_API
	qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
	NFSv4/pnfs: Reset the layout state after a layoutreturn
	dmaengine: Revert "dmaengine: dmatest: Fix dmatest waiting less when interrupted"
	ACPI: PPTT: Fix processor subtable walk
	ALSA: es1968: Add error handling for snd_pcm_hw_constraint_pow2()
	tracing: samples: Initialize trace_array_printk() with the correct function
	phy: Fix error handling in tegra_xusb_port_init
	phy: renesas: rcar-gen3-usb2: Set timing registers only once
	wifi: mt76: disable napi on driver removal
	dmaengine: ti: k3-udma: Add missing locking
	dmaengine: ti: k3-udma: Use cap_mask directly from dma_device structure instead of a local copy
	clocksource/i8253: Use raw_spinlock_irqsave() in clockevent_i8253_disable()
	ASoC: q6afe-clocks: fix reprobing of the driver
	drm/vmwgfx: Fix a deadlock in dma buf fence polling
	usb: typec: altmodes/displayport: create sysfs nodes as driver's default device attribute group
	usb: typec: fix potential array underflow in ucsi_ccg_sync_control()
	usb: typec: fix pm usage counter imbalance in ucsi_ccg_sync_control()
	selftests/mm: compaction_test: support platform with huge mount of memory
	btrfs: don't BUG_ON() when 0 reference count at btrfs_lookup_extent_info()
	netfilter: nf_tables: pass nft_chain to destroy function, not nft_ctx
	netfilter: nf_tables: wait for rcu grace period on net_device removal
	netfilter: nf_tables: do not defer rule destruction via call_rcu
	ice: arfs: fix use-after-free when freeing @rx_cpu_rmap
	scsi: target: iscsi: Fix timeout on deleted connection
	dma-mapping: avoid potential unused data compilation warning
	cgroup: Fix compilation issue due to cgroup_mutex not being exported
	kconfig: merge_config: use an empty file as initfile
	NFSv4: Check for delegation validity in nfs_start_delegation_return_locked()
	mailbox: use error ret code of of_parse_phandle_with_args()
	fbdev: fsl-diu-fb: add missing device_remove_file()
	fbcon: Use correct erase colour for clearing in fbcon
	fbdev: core: tileblit: Implement missing margin clearing for tileblit
	NFSv4: Treat ENETUNREACH errors as fatal for state recovery
	SUNRPC: rpc_clnt_set_transport() must not change the autobind setting
	SUNRPC: rpcbind should never reset the port to the value '0'
	thermal/drivers/qoriq: Power down TMU on system suspend
	dql: Fix dql->limit value when reset.
	tools/build: Don't pass test log files to linker
	pNFS/flexfiles: Report ENETDOWN as a connection error
	libnvdimm/labels: Fix divide error in nd_label_data_init()
	mmc: host: Wait for Vdd to settle on card power off
	i2c: qup: Vote for interconnect bandwidth to DRAM
	i2c: pxa: fix call balance of i2c->clk handling routines
	btrfs: avoid linker error in btrfs_find_create_tree_block()
	btrfs: send: return -ENAMETOOLONG when attempting a path that is too long
	um: Store full CSGSFS and SS register from mcontext
	um: Update min_low_pfn to match changes in uml_reserved
	ext4: reorder capability check last
	scsi: st: Tighten the page format heuristics with MODE SELECT
	scsi: st: ERASE does not change tape location
	tcp: reorganize tcp_in_ack_event() and tcp_count_delivered()
	rtc: rv3032: fix EERD location
	kbuild: fix argument parsing in scripts/config
	dm: restrict dm device size to 2^63-512 bytes
	xen: Add support for XenServer 6.1 platform device
	posix-timers: Add cond_resched() to posix_timer_add() search loop
	netfilter: conntrack: Bound nf_conntrack sysctl writes
	arm64/mm: Check PUD_TYPE_TABLE in pud_bad()
	mmc: sdhci: Disable SD card clock before changing parameters
	ipv6: save dontfrag in cork
	arm64: tegra: p2597: Fix gpio for vdd-1v8-dis regulator
	powerpc/prom_init: Fixup missing #size-cells on PowerBook6,7
	tcp: bring back NUMA dispersion in inet_ehash_locks_alloc()
	rtc: ds1307: stop disabling alarms on probe
	ieee802154: ca8210: Use proper setters and getters for bitwise types
	ARM: tegra: Switch DSI-B clock parent to PLLD on Tegra114
	media: c8sectpfe: Call of_node_put(i2c_bus) only once in c8sectpfe_probe()
	dm cache: prevent BUG_ON by blocking retries on failed device resumes
	orangefs: Do not truncate file size
	drm/amdgpu: Do not program AGP BAR regs under SRIOV in gfxhub_v1_0.c
	media: cx231xx: set device_caps for 417
	pinctrl: bcm281xx: Use "unsigned int" instead of bare "unsigned"
	net: ethernet: ti: cpsw_new: populate netdev of_node
	net: pktgen: fix mpls maximum labels list parsing
	ipv4: fib: Move fib_valid_key_len() to rtm_to_fib_config().
	clk: imx8mp: inform CCF of maximum frequency of clocks
	x86/bugs: Make spectre user default depend on MITIGATION_SPECTRE_V2
	hwmon: (gpio-fan) Add missing mutex locks
	drm/mediatek: mtk_dpi: Add checks for reg_h_fre_con existence
	fpga: altera-cvp: Increase credit timeout
	PCI: brcmstb: Expand inbound window size up to 64GB
	PCI: brcmstb: Add a softdep to MIP MSI-X driver
	net/mlx5: Avoid report two health errors on same syndrome
	drm/amdkfd: KFD release_work possible circular locking
	net: xgene-v2: remove incorrect ACPI_PTR annotation
	bonding: report duplicate MAC address in all situations
	soc: ti: k3-socinfo: Do not use syscon helper to build regmap
	x86/nmi: Add an emergency handler in nmi_desc & use it in nmi_shootdown_cpus()
	cpuidle: menu: Avoid discarding useful information
	libbpf: Fix out-of-bound read
	MIPS: Use arch specific syscall name match function
	MIPS: pm-cps: Use per-CPU variables as per-CPU, not per-core
	clocksource: mips-gic-timer: Enable counter when CPUs start
	scsi: mpt3sas: Send a diag reset if target reset fails
	wifi: rtw88: Fix rtw_init_vht_cap() for RTL8814AU
	wifi: rtw88: Fix rtw_init_ht_cap() for RTL8814AU
	wifi: rtw88: Fix rtw_desc_to_mcsrate() to handle MCS16-31
	net: pktgen: fix access outside of user given buffer in pktgen_thread_write()
	EDAC/ie31200: work around false positive build warning
	can: c_can: Use of_property_present() to test existence of DT property
	eth: mlx4: don't try to complete XDP frames in netpoll
	PCI: Fix old_size lower bound in calculate_iosize() too
	ACPI: HED: Always initialize before evged
	net/mlx5: Modify LSB bitmask in temperature event to include only the first bit
	net/mlx5: Apply rate-limiting to high temperature warning
	ASoC: ops: Enforce platform maximum on initial value
	ASoC: tas2764: Power up/down amp on mute ops
	ASoC: soc-dai: check return value at snd_soc_dai_set_tdm_slot()
	pinctrl: devicetree: do not goto err when probing hogs in pinctrl_dt_to_map
	smack: recognize ipv4 CIPSO w/o categories
	media: v4l: Memset argument to 0 before calling get_mbus_config pad op
	net/mlx4_core: Avoid impossible mlx4_db_alloc() order value
	phy: core: don't require set_mode() callback for phy_get_mode() to work
	drm/amd/display: Initial psr_version with correct setting
	net/mlx5: Extend Ethtool loopback selftest to support non-linear SKB
	net/mlx5e: set the tx_queue_len for pfifo_fast
	net/mlx5e: reduce rep rxq depth to 256 for ECPF
	ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure().
	wifi: rtw88: Fix download_firmware_validate() for RTL8814AU
	hwmon: (xgene-hwmon) use appropriate type for the latency value
	vxlan: Annotate FDB data races
	rcu: handle quiescent states for PREEMPT_RCU=n, PREEMPT_COUNT=y
	rcu: fix header guard for rcu_all_qs()
	scsi: lpfc: Handle duplicate D_IDs in ndlp search-by D_ID routine
	scsi: st: Restore some drive settings after reset
	HID: usbkbd: Fix the bit shift number for LED_KANA
	drm/ast: Find VBIOS mode from regular display size
	bpftool: Fix readlink usage in get_fd_type
	perf/amd/ibs: Fix perf_ibs_op.cnt_mask for CurCnt
	wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate
	spi: zynqmp-gqspi: Always acknowledge interrupts
	regulator: ad5398: Add device tree support
	drm/atomic: clarify the rules around drm_atomic_state->allow_modeset
	drm: Add valid clones check
	pinctrl: meson: define the pull up/down resistor value as 60 kOhm
	ASoC: Intel: bytcr_rt5640: Add DMI quirk for Acer Aspire SW3-013
	ALSA: hda/realtek: Add quirk for HP Spectre x360 15-df1xxx
	nvmet-tcp: don't restore null sk_state_change
	btrfs: correct the order of prelim_ref arguments in btrfs__prelim_ref
	xenbus: Allow PVH dom0 a non-local xenstore
	__legitimize_mnt(): check for MNT_SYNC_UMOUNT should be under mount_lock
	xfrm: Sanitize marks before insert
	bridge: netfilter: Fix forwarding of fragmented packets
	net: dwmac-sun8i: Use parsed internal PHY address instead of 1
	sch_hfsc: Fix qlen accounting bug when using peek in hfsc_enqueue()
	net/tipc: fix slab-use-after-free Read in tipc_aead_encrypt_done
	crypto: algif_hash - fix double free in hash_accept
	padata: do not leak refcount in reorder_work
	can: bcm: add locking for bcm_op runtime updates
	can: bcm: add missing rcu read protection for procfs content
	ALSA: pcm: Fix race of buffer access at PCM OSS layer
	llc: fix data loss when reading from a socket in llc_ui_recvmsg()
	drm/edid: fixed the bug that hdr metadata was not reset
	memcg: always call cond_resched() after fn()
	mm/page_alloc.c: avoid infinite retries caused by cpuset race
	spi: spi-fsl-dspi: restrict register range for regmap access
	spi: spi-fsl-dspi: Halt the module after a new message transfer
	spi: spi-fsl-dspi: Reset SR flags before sending a new message
	kbuild: Disable -Wdefault-const-init-unsafe
	drm/i915/gvt: fix unterminated-string-initialization warning
	smb: client: Fix use-after-free in cifs_fill_dirent
	smb: client: Reset all search buffer pointers when releasing buffer
	net_sched: hfsc: Address reentrant enqueue adding class to eltree twice
	coredump: fix error handling for replace_fd()
	pid: add pidfd_prepare()
	fork: use pidfd_prepare()
	coredump: hand a pidfd to the usermode coredump helper
	HID: quirks: Add ADATA XPG alpha wireless mouse support
	nfs: don't share pNFS DS connections between net namespaces
	platform/x86: thinkpad_acpi: Support also NEC Lavie X1475JAS
	um: let 'make clean' properly clean underlying SUBARCH as well
	spi: spi-sun4i: fix early activation
	tpm: tis: Double the timeout B to 4s
	platform/x86: fujitsu-laptop: Support Lifebook S2110 hotkeys
	platform/x86: thinkpad_acpi: Ignore battery threshold change event notification
	xen/swiotlb: relax alignment requirements
	perf/arm-cmn: Initialise cmn->cpu earlier
	Linux 5.10.238

Change-Id: I35ae49dcc741e7a596a8faadb9fb8c9de436f5c0
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2025-06-05 10:42:42 +00:00

217 lines
6.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_PID_H
#define _LINUX_PID_H
#include <linux/rculist.h>
#include <linux/wait.h>
#include <linux/refcount.h>
enum pid_type
{
PIDTYPE_PID,
PIDTYPE_TGID,
PIDTYPE_PGID,
PIDTYPE_SID,
PIDTYPE_MAX,
};
/*
* What is struct pid?
*
* A struct pid is the kernel's internal notion of a process identifier.
* It refers to individual tasks, process groups, and sessions. While
* there are processes attached to it the struct pid lives in a hash
* table, so it and then the processes that it refers to can be found
* quickly from the numeric pid value. The attached processes may be
* quickly accessed by following pointers from struct pid.
*
* Storing pid_t values in the kernel and referring to them later has a
* problem. The process originally with that pid may have exited and the
* pid allocator wrapped, and another process could have come along
* and been assigned that pid.
*
* Referring to user space processes by holding a reference to struct
* task_struct has a problem. When the user space process exits
* the now useless task_struct is still kept. A task_struct plus a
* stack consumes around 10K of low kernel memory. More precisely
* this is THREAD_SIZE + sizeof(struct task_struct). By comparison
* a struct pid is about 64 bytes.
*
* Holding a reference to struct pid solves both of these problems.
* It is small so holding a reference does not consume a lot of
* resources, and since a new struct pid is allocated when the numeric pid
* value is reused (when pids wrap around) we don't mistakenly refer to new
* processes.
*/
/*
* struct upid is used to get the id of the struct pid, as it is
* seen in particular namespace. Later the struct pid is found with
* find_pid_ns() using the int nr and struct pid_namespace *ns.
*/
struct upid {
int nr;
struct pid_namespace *ns;
};
struct pid
{
refcount_t count;
unsigned int level;
spinlock_t lock;
/* lists of tasks that use this pid */
struct hlist_head tasks[PIDTYPE_MAX];
struct hlist_head inodes;
/* wait queue for pidfd notifications */
wait_queue_head_t wait_pidfd;
struct rcu_head rcu;
struct upid numbers[1];
};
extern struct pid init_struct_pid;
extern const struct file_operations pidfd_fops;
struct file;
extern struct pid *pidfd_pid(const struct file *file);
struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags);
int pidfd_prepare(struct pid *pid, unsigned int flags, struct file **ret);
static inline struct pid *get_pid(struct pid *pid)
{
if (pid)
refcount_inc(&pid->count);
return pid;
}
extern void put_pid(struct pid *pid);
extern struct task_struct *pid_task(struct pid *pid, enum pid_type);
static inline bool pid_has_task(struct pid *pid, enum pid_type type)
{
return !hlist_empty(&pid->tasks[type]);
}
extern struct task_struct *get_pid_task(struct pid *pid, enum pid_type);
extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
/*
* these helpers must be called with the tasklist_lock write-held.
*/
extern void attach_pid(struct task_struct *task, enum pid_type);
extern void detach_pid(struct task_struct *task, enum pid_type);
extern void change_pid(struct task_struct *task, enum pid_type,
struct pid *pid);
extern void exchange_tids(struct task_struct *task, struct task_struct *old);
extern void transfer_pid(struct task_struct *old, struct task_struct *new,
enum pid_type);
struct pid_namespace;
extern struct pid_namespace init_pid_ns;
extern int pid_max;
extern int pid_max_min, pid_max_max;
/*
* look up a PID in the hash table. Must be called with the tasklist_lock
* or rcu_read_lock() held.
*
* find_pid_ns() finds the pid in the namespace specified
* find_vpid() finds the pid by its virtual id, i.e. in the current namespace
*
* see also find_task_by_vpid() set in include/linux/sched.h
*/
extern struct pid *find_pid_ns(int nr, struct pid_namespace *ns);
extern struct pid *find_vpid(int nr);
/*
* Lookup a PID in the hash table, and return with it's count elevated.
*/
extern struct pid *find_get_pid(int nr);
extern struct pid *find_ge_pid(int nr, struct pid_namespace *);
extern struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
size_t set_tid_size);
extern void free_pid(struct pid *pid);
extern void disable_pid_allocation(struct pid_namespace *ns);
/*
* ns_of_pid() returns the pid namespace in which the specified pid was
* allocated.
*
* NOTE:
* ns_of_pid() is expected to be called for a process (task) that has
* an attached 'struct pid' (see attach_pid(), detach_pid()) i.e @pid
* is expected to be non-NULL. If @pid is NULL, caller should handle
* the resulting NULL pid-ns.
*/
static inline struct pid_namespace *ns_of_pid(struct pid *pid)
{
struct pid_namespace *ns = NULL;
if (pid)
ns = pid->numbers[pid->level].ns;
return ns;
}
/*
* is_child_reaper returns true if the pid is the init process
* of the current namespace. As this one could be checked before
* pid_ns->child_reaper is assigned in copy_process, we check
* with the pid number.
*/
static inline bool is_child_reaper(struct pid *pid)
{
return pid->numbers[pid->level].nr == 1;
}
/*
* the helpers to get the pid's id seen from different namespaces
*
* pid_nr() : global id, i.e. the id seen from the init namespace;
* pid_vnr() : virtual id, i.e. the id seen from the pid namespace of
* current.
* pid_nr_ns() : id seen from the ns specified.
*
* see also task_xid_nr() etc in include/linux/sched.h
*/
static inline pid_t pid_nr(struct pid *pid)
{
pid_t nr = 0;
if (pid)
nr = pid->numbers[0].nr;
return nr;
}
pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
pid_t pid_vnr(struct pid *pid);
#define do_each_pid_task(pid, type, task) \
do { \
if ((pid) != NULL) \
hlist_for_each_entry_rcu((task), \
&(pid)->tasks[type], pid_links[type]) {
/*
* Both old and new leaders may be attached to
* the same pid in the middle of de_thread().
*/
#define while_each_pid_task(pid, type, task) \
if (type == PIDTYPE_PID) \
break; \
} \
} while (0)
#define do_each_pid_thread(pid, type, task) \
do_each_pid_task(pid, type, task) { \
struct task_struct *tg___ = task; \
for_each_thread(tg___, task) {
#define while_each_pid_thread(pid, type, task) \
} \
task = tg___; \
} while_each_pid_task(pid, type, task)
#endif /* _LINUX_PID_H */