stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 6.12 067/105] io_uring: backport io_should_terminate_tw()
Date: Mon, 22 Sep 2025 21:29:50 +0200	[thread overview]
Message-ID: <20250922192410.663177022@linuxfoundation.org> (raw)
In-Reply-To: <20250922192408.913556629@linuxfoundation.org>

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jens Axboe <axboe@kernel.dk>

Parts of commit b6f58a3f4aa8dba424356c7a69388a81f4459300 upstream.

Backport io_should_terminate_tw() helper to judge whether task_work
should be run or terminated.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 io_uring/io_uring.c  |    3 +--
 io_uring/io_uring.h  |   13 +++++++++++++
 io_uring/poll.c      |    3 +--
 io_uring/timeout.c   |    2 +-
 io_uring/uring_cmd.c |    2 +-
 5 files changed, 17 insertions(+), 6 deletions(-)

--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1359,8 +1359,7 @@ static void io_req_task_cancel(struct io
 void io_req_task_submit(struct io_kiocb *req, struct io_tw_state *ts)
 {
 	io_tw_lock(req->ctx, ts);
-	/* req->task == current here, checking PF_EXITING is safe */
-	if (unlikely(req->task->flags & PF_EXITING))
+	if (unlikely(io_should_terminate_tw()))
 		io_req_defer_failed(req, -EFAULT);
 	else if (req->flags & REQ_F_FORCE_ASYNC)
 		io_queue_iowq(req);
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -421,6 +421,19 @@ static inline bool io_allowed_run_tw(str
 		      ctx->submitter_task == current);
 }
 
+/*
+ * Terminate the request if either of these conditions are true:
+ *
+ * 1) It's being executed by the original task, but that task is marked
+ *    with PF_EXITING as it's exiting.
+ * 2) PF_KTHREAD is set, in which case the invoker of the task_work is
+ *    our fallback task_work.
+ */
+static inline bool io_should_terminate_tw(void)
+{
+	return current->flags & (PF_KTHREAD | PF_EXITING);
+}
+
 static inline void io_req_queue_tw_complete(struct io_kiocb *req, s32 res)
 {
 	io_req_set_res(req, res, 0);
--- a/io_uring/poll.c
+++ b/io_uring/poll.c
@@ -265,8 +265,7 @@ static int io_poll_check_events(struct i
 {
 	int v;
 
-	/* req->task == current here, checking PF_EXITING is safe */
-	if (unlikely(req->task->flags & PF_EXITING))
+	if (unlikely(io_should_terminate_tw()))
 		return -ECANCELED;
 
 	do {
--- a/io_uring/timeout.c
+++ b/io_uring/timeout.c
@@ -303,7 +303,7 @@ static void io_req_task_link_timeout(str
 	int ret = -ENOENT;
 
 	if (prev) {
-		if (!(req->task->flags & PF_EXITING)) {
+		if (!io_should_terminate_tw()) {
 			struct io_cancel_data cd = {
 				.ctx		= req->ctx,
 				.data		= prev->cqe.user_data,
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -118,7 +118,7 @@ static void io_uring_cmd_work(struct io_
 	struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
 	unsigned int flags = IO_URING_F_COMPLETE_DEFER;
 
-	if (current->flags & (PF_EXITING | PF_KTHREAD))
+	if (io_should_terminate_tw())
 		flags |= IO_URING_F_TASK_DEAD;
 
 	/* task_work executor checks the deffered list completion */



  parent reply	other threads:[~2025-09-22 19:39 UTC|newest]

Thread overview: 119+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-22 19:28 [PATCH 6.12 000/105] 6.12.49-rc1 review Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 001/105] wifi: wilc1000: avoid buffer overflow in WID string configuration Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 002/105] nvme: fix PI insert on write Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 003/105] ALSA: firewire-motu: drop EPOLLOUT from poll return values as write is not supported Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 004/105] wifi: mac80211: increase scan_ies_len for S1G Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 005/105] wifi: mac80211: fix incorrect type for ret Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 006/105] pcmcia: omap_cf: Mark driver struct with __refdata to prevent section mismatch Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 007/105] cgroup: split cgroup_destroy_wq into 3 workqueues Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 008/105] btrfs: fix invalid extref key setup when replaying dentry Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 009/105] um: virtio_uml: Fix use-after-free after put_device in probe Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 010/105] um: Fix FD copy size in os_rcv_fd_msg() Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 011/105] dpaa2-switch: fix buffer pool seeding for control traffic Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 012/105] net/tcp: Fix a NULL pointer dereference when using TCP-AO with TCP_REPAIR Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 013/105] qed: Dont collect too many protection override GRC elements Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 014/105] bonding: set random address only when slaves already exist Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 015/105] mptcp: set remote_deny_join_id0 on SYN recv Greg Kroah-Hartman
2025-09-22 19:28 ` [PATCH 6.12 016/105] selftests: mptcp: userspace pm: validate deny-join-id0 flag Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 017/105] mptcp: tfo: record deny join id0 info Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 018/105] selftests: mptcp: sockopt: fix error messages Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 019/105] net: natsemi: fix `rx_dropped` double accounting on `netif_rx()` failure Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 020/105] ice: store max_frame and rx_buf_len only in ice_rx_ring Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 021/105] ice: fix Rx page leak on multi-buffer frames Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 022/105] i40e: remove redundant memory barrier when cleaning Tx descs Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 023/105] igc: dont fail igc_probe() on LED setup error Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 024/105] net/mlx5e: Harden uplink netdev access against device unbind Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 025/105] bonding: dont set oif to bond dev when getting NS target destination Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 026/105] octeon_ep: fix VF MAC address lifecycle handling Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 027/105] tcp: Clear tcp_sk(sk)->fastopen_rsk in tcp_disconnect() Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 028/105] tls: make sure to abort the stream if headers are bogus Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 029/105] Revert "net/mlx5e: Update and set Xon/Xoff upon port speed set" Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 030/105] net: liquidio: fix overflow in octeon_init_instr_queue() Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 031/105] cnic: Fix use-after-free bugs in cnic_delete_task Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 032/105] octeontx2-pf: Fix use-after-free bugs in otx2_sync_tstamp() Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 033/105] perf/x86/intel: Fix crash in icl_update_topdown_event() Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 034/105] ksmbd: smbdirect: validate data_offset and data_length field of smb_direct_data_transfer Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 035/105] ksmbd: smbdirect: verify remaining_data_length respects max_fragmented_recv_size Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 036/105] nilfs2: fix CFI failure when accessing /sys/fs/nilfs2/features/* Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 037/105] crypto: af_alg - Disallow concurrent writes in af_alg_sendmsg Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 038/105] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 039/105] power: supply: bq27xxx: restrict no-battery detection to bq27000 Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 040/105] dm-raid: dont set io_min and io_opt for raid1 Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 041/105] dm-stripe: fix a possible integer overflow Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 042/105] gup: optimize longterm pin_user_pages() for large folio Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 043/105] mm: revert "mm: vmscan.c: fix OOM on swap stress test" Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 044/105] LoongArch: Update help info of ARCH_STRICT_ALIGN Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 045/105] objtool/LoongArch: Mark types based on break immediate code Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 046/105] objtool/LoongArch: Mark special atomic instruction as INSN_BUG type Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 047/105] LoongArch: Fix unreliable stack for live patching Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 048/105] LoongArch: vDSO: Check kcalloc() result in init_vdso() Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 049/105] LoongArch: Align ACPI structures if ARCH_STRICT_ALIGN enabled Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 050/105] LoongArch: Check the return value when creating kobj Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 051/105] iommu/vt-d: Fix __domain_mapping()s usage of switch_to_super_page() Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 052/105] iommu/amd/pgtbl: Fix possible race while increase page table level Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 053/105] btrfs: tree-checker: fix the incorrect inode ref size check Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 054/105] ASoC: qcom: audioreach: Fix lpaif_type configuration for the I2S interface Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 055/105] ASoC: qcom: q6apm-lpass-dais: Fix NULL pointer dereference if source graph failed Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 056/105] ASoC: qcom: q6apm-lpass-dais: Fix missing set_fmt DAI op for I2S Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 057/105] mmc: mvsdio: Fix dma_unmap_sg() nents value Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 058/105] KVM: SVM: Sync TPR from LAPIC into VMCB::V_TPR even if AVIC is active Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 059/105] drm/amd/display: Allow RX6xxx & RX7700 to invoke amdgpu_irq_get/put Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 060/105] net: rfkill: gpio: Fix crash due to dereferencering uninitialized pointer Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 061/105] rds: ib: Increment i_fastreg_wrs before bailing out Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 062/105] mptcp: propagate shutdown to subflows when possible Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 063/105] selftests: mptcp: connect: catch IO errors on listen side Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 064/105] selftests: mptcp: avoid spurious errors on TCP disconnect Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 065/105] ALSA: hda/realtek: Fix mute led for HP Laptop 15-dw4xx Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 066/105] io_uring/cmd: let cmds to know about dying task Greg Kroah-Hartman
2025-09-22 19:29 ` Greg Kroah-Hartman [this message]
2025-09-22 19:29 ` [PATCH 6.12 068/105] io_uring: include dying ring in task_work "should cancel" state Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 069/105] io_uring/msg_ring: kill alloc_cache for io_kiocb allocations Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 070/105] io_uring/kbuf: drop WARN_ON_ONCE() from incremental length check Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 071/105] ASoC: wm8940: Correct PLL rate rounding Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 072/105] ASoC: wm8940: Correct typo in control name Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 073/105] ASoC: wm8974: Correct PLL rate rounding Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 074/105] ASoC: SOF: Intel: hda-stream: Fix incorrect variable used in error message Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 075/105] ASoC: Intel: catpt: Expose correct bit depth to userspace Greg Kroah-Hartman
2025-09-22 19:29 ` [PATCH 6.12 076/105] drm/xe/tile: Release kobject for the failure path Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 077/105] drm: bridge: anx7625: Fix NULL pointer dereference with early IRQ Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 078/105] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 079/105] drm/xe: Fix a NULL vs IS_ERR() in xe_vm_add_compute_exec_queue() Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 080/105] smb: client: fix filename matching of deferred files Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 081/105] smb: client: let smbd_destroy() call disable_work_sync(&info->post_send_credits_work) Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 082/105] crypto: af_alg - Set merge to zero early in af_alg_sendmsg Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 083/105] smb: client: fix smbdirect_recv_io leak in smbd_negotiate() error path Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 084/105] io_uring: fix incorrect io_kiocb reference in io_link_skb Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 085/105] platform/x86: asus-wmi: Fix ROG button mapping, tablet mode on ASUS ROG Z13 Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 086/105] platform/x86: asus-wmi: Re-add extra keys to ignore_key_wlan quirk Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 087/105] x86/bugs: Add SRSO_USER_KERNEL_NO support Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 088/105] x86/bugs: KVM: Add support for SRSO_MSR_FIX Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 089/105] KVM: SVM: Set/clear SRSOs BP_SPEC_REDUCE on 0 <=> 1 VM count transitions Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 090/105] vmxnet3: unregister xdp rxq info in the reset path Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 091/105] mm: add folio_expected_ref_count() for reference count calculation Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 092/105] mm/gup: check ref_count instead of lru before migration Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 093/105] mptcp: pm: nl: announce deny-join-id0 flag Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 094/105] usb: xhci: introduce macro for ring segment list iteration Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 095/105] usb: xhci: remove option to change a default rings TRB cycle bit Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 096/105] xhci: dbc: decouple endpoint allocation from initialization Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 097/105] xhci: dbc: Fix full DbC transfer ring after several reconnects Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 098/105] rtc: pcf2127: fix SPI command byte for PCF2131 backport Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 099/105] minmax.h: add whitespace around operators and after commas Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 100/105] minmax.h: update some comments Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 101/105] minmax.h: reduce the #define expansion of min(), max() and clamp() Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 102/105] minmax.h: use BUILD_BUG_ON_MSG() for the lo < hi test in clamp() Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 103/105] minmax.h: move all the clamp() definitions after the min/max() ones Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 104/105] minmax.h: simplify the variants of clamp() Greg Kroah-Hartman
2025-09-22 19:30 ` [PATCH 6.12 105/105] minmax.h: remove some #defines that are only expanded once Greg Kroah-Hartman
2025-09-22 23:00 ` [PATCH 6.12 000/105] 6.12.49-rc1 review Florian Fainelli
2025-09-23  5:24 ` Naresh Kamboju
2025-09-23  7:26 ` Brett A C Sheffield
2025-09-23  9:47 ` [PATCH 6.12 000/105] " Harshit Mogalapalli
2025-09-23 13:01 ` Mark Brown
2025-09-23 13:10 ` Jon Hunter
2025-09-23 13:42 ` Brett Mastbergen
2025-09-23 13:47 ` Peter Schneider
2025-09-23 15:04 ` Ron Economos
2025-09-23 20:42 ` Miguel Ojeda
2025-09-24  0:27 ` Shuah Khan
2025-09-24  7:00 ` Hardik Garg
2025-09-26 16:37 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250922192410.663177022@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=axboe@kernel.dk \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).