Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Petr Malat <oss@malat.biz>, Xin Long <lucien.xin@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>, Sasha Levin <sashal@kernel.org>,
	marcelo.leitner@gmail.com, linux-sctp@vger.kernel.org
Subject: [PATCH AUTOSEL 6.14 019/108] sctp: Do not wake readers in __sctp_write_space()
Date: Tue,  3 Jun 2025 20:54:02 -0400	[thread overview]
Message-ID: <20250604005531.4178547-19-sashal@kernel.org> (raw)
In-Reply-To: <20250604005531.4178547-1-sashal@kernel.org>

From: Petr Malat <oss@malat.biz>

[ Upstream commit af295892a7abbf05a3c2ba7abc4d81bb448623d6 ]

Function __sctp_write_space() doesn't set poll key, which leads to
ep_poll_callback() waking up all waiters, not only these waiting
for the socket being writable. Set the key properly using
wake_up_interruptible_poll(), which is preferred over the sync
variant, as writers are not woken up before at least half of the
queue is available. Also, TCP does the same.

Signed-off-by: Petr Malat <oss@malat.biz>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20250516081727.1361451-1-oss@malat.biz
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

Based on my analysis of the commit and comparison with similar
historical commits, here is my assessment: **YES** This commit should be
backported to stable kernel trees. ## Detailed Analysis: ### 1. **Core
Issue Being Fixed** The commit addresses a specific bug in SCTP's
`__sctp_write_space()` function where `wake_up_interruptible()` is
called without setting a poll key. This causes `ep_poll_callback()` to
wake up **all** waiters on the socket, not just those waiting for
writability (EPOLLOUT events). This is inefficient and can cause
spurious wake-ups for readers waiting on the same socket. ### 2. **Code
Changes Analysis** The fix is minimal and surgical: ```c // Before:
wake_up_interruptible(&wq->wait); // After:
wake_up_interruptible_poll(&wq->wait, EPOLLOUT | EPOLLWRNORM |
EPOLLWRBAND); ``` ### 3. **Consistency with Existing Patterns** Looking
at `/home/sasha/linux/net/core/stream.c:41-42`, I can see that the fix
aligns with established patterns in the kernel networking stack: ```c
wake_up_interruptible_poll(&wq->wait, EPOLLOUT | EPOLLWRNORM |
EPOLLWRBAND); ``` This is exactly what TCP and other protocols use in
their write space callbacks, making SCTP consistent with the rest of the
networking subsystem. ### 4. **Comparison with Historical Similar
Commits** **Positive Indicators (matching YES backports):** - **Similar
Commit #1**: Also SCTP-related, fixes socket behavior issue affecting
users - **Similar Commit #4**: TCP polling fix with similar wake-up
improvements - **Similar Commit #5**: SCTP wake-up related fix that was
backported **Risk Assessment:** - The change is contained to a single
function (`__sctp_write_space`) - No architectural changes - Follows
existing kernel patterns exactly - Low regression risk - improves
efficiency without changing core behavior ### 5. **Impact and Benefits**
- **Performance improvement**: Eliminates spurious wake-ups for readers
when only write space becomes available - **Correctness**: Ensures only
appropriate waiters are woken (those waiting for EPOLLOUT) -
**Consistency**: Aligns SCTP behavior with TCP and other protocols ###
6. **Stable Tree Criteria Compliance** ✅ **Important bugfix**: Fixes
incorrect polling behavior affecting performance ✅ **Minimal risk**:
Single-line change following established patterns ✅ **Small and
contained**: Only affects one function in SCTP ✅ **No new features**:
Pure bugfix ✅ **No architectural changes**: Maintains existing
interfaces ### 7. **Clear Author Intent** The commit message explicitly
states this change makes SCTP behave "as TCP does," indicating this is a
correctness fix to align with established networking patterns rather
than a new feature. This commit exhibits all the characteristics of a
good stable backport candidate: it's a small, contained bugfix that
improves correctness and performance without introducing new
functionality or significant risk.

 net/sctp/socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 53725ee7ba06d..b301d64d9d80f 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -9100,7 +9100,8 @@ static void __sctp_write_space(struct sctp_association *asoc)
 		wq = rcu_dereference(sk->sk_wq);
 		if (wq) {
 			if (waitqueue_active(&wq->wait))
-				wake_up_interruptible(&wq->wait);
+				wake_up_interruptible_poll(&wq->wait, EPOLLOUT |
+						EPOLLWRNORM | EPOLLWRBAND);
 
 			/* Note that we try to include the Async I/O support
 			 * here by modeling from the current TCP/UDP code.
-- 
2.39.5


  parent reply	other threads:[~2025-06-04  0:56 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-04  0:53 [PATCH AUTOSEL 6.14 001/108] net: macb: Check return value of dma_set_mask_and_coherent() Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 002/108] net: lan743x: Modify the EEPROM and OTP size for PCI1xxxx devices Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 003/108] tipc: use kfree_sensitive() for aead cleanup Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 004/108] f2fs: use vmalloc instead of kvmalloc in .init_{,de}compress_ctx Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 005/108] bpf: Check rcu_read_lock_trace_held() in bpf_map_lookup_percpu_elem() Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 006/108] Bluetooth: btusb: Add new VID/PID 13d3/3584 for MT7922 Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 007/108] i2c: designware: Invoke runtime suspend on quick slave re-registration Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 008/108] wifi: mt76: mt7996: drop fragments with multicast or broadcast RA Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 009/108] emulex/benet: correct command version selection in be_cmd_get_stats() Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 010/108] Bluetooth: btusb: Add new VID/PID 13d3/3630 for MT7925 Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 011/108] Bluetooth: btusb: Add RTL8851BE device 0x0bda:0xb850 Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 012/108] Bluetooth: ISO: Fix not using SID from adv report Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 013/108] Bluetooth: btmrvl_sdio: Fix wakeup source leaks on device unbind Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 014/108] Bluetooth: btmtksdio: " Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 015/108] wifi: mt76: mt76x2: Add support for LiteOn WN4516R,WN4519R Sasha Levin
2025-06-04  0:53 ` [PATCH AUTOSEL 6.14 016/108] wifi: mt76: mt7921: add 160 MHz AP for mt7922 device Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 017/108] wifi: mt76: mt7925: introduce thermal protection Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 018/108] wifi: mac80211: validate SCAN_FLAG_AP in scan request during MLO Sasha Levin
2025-06-04  0:54 ` Sasha Levin [this message]
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 020/108] libbpf/btf: Fix string handling to support multi-split BTF Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 021/108] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 022/108] i2c: tegra: check msg length in SMBUS block read Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 023/108] i2c: npcm: Add clock toggle recovery Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 024/108] clk: qcom: gcc-x1e80100: Set FORCE MEM CORE for UFS clocks Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 025/108] clk: qcom: gcc: Set FORCE_MEM_CORE_ON for gcc_ufs_axi_clk for 8650/8750 Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 026/108] net: dlink: add synchronization for stats update Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 027/108] wifi: ath12k: fix macro definition HAL_RX_MSDU_PKT_LENGTH_GET Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 028/108] wifi: ath12k: fix a possible dead lock caused by ab->base_lock Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 029/108] wifi: ath11k: Fix QMI memory reuse logic Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 030/108] iommu/amd: Allow matching ACPI HID devices without matching UIDs Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 031/108] wifi: rtw89: leave idle mode when setting WEP encryption for AP mode Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 032/108] tcp: always seek for minimal rtt in tcp_rcv_rtt_update() Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 033/108] tcp: remove zero TCP TS samples for autotuning Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 034/108] tcp: fix initial tp->rcvq_space.space value for passive TS enabled flows Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 035/108] tcp: add receive queue awareness in tcp_rcv_space_adjust() Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 036/108] x86/sgx: Prevent attempts to reclaim poisoned pages Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 037/108] ipv4/route: Use this_cpu_inc() for stats on PREEMPT_RT Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 038/108] net: page_pool: Don't recycle into cache " Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 039/108] xfrm: validate assignment of maximal possible SEQ number Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 040/108] openvswitch: Stricter validation for the userspace action Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 041/108] net: atlantic: generate software timestamp just before the doorbell Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 042/108] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_set_by_name() Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 043/108] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get_direction() Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 044/108] bpf: Pass the same orig_call value to trampoline functions Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 045/108] net: stmmac: generate software timestamp just before the doorbell Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 046/108] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_gpio_set_direction() Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 047/108] libbpf: Check bpf_map_skeleton link for NULL Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 048/108] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get() Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 049/108] net/mlx5: HWS, fix counting of rules in the matcher Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 050/108] net: mlx4: add SOF_TIMESTAMPING_TX_SOFTWARE flag when getting ts info Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 051/108] net: vertexcom: mse102x: Return code for mse102x_rx_pkt_spi Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 052/108] wifi: rtw88: rtw8822bu VID/PID for BUFFALO WI-U2-866DM Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 053/108] wireless: purelifi: plfxlc: fix memory leak in plfxlc_usb_wreq_asyn() Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 054/108] wifi: mac80211: do not offer a mesh path if forwarding is disabled Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 055/108] bpftool: Fix cgroup command to only show cgroup bpf programs Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 056/108] clk: rockchip: rk3036: mark ddrphy as critical Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 057/108] hid-asus: check ROG Ally MCU version and warn Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 058/108] rtla: Define __NR_sched_setattr for LoongArch Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 059/108] wifi: iwlwifi: mvm: fix beacon CCK flag Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 060/108] wifi: iwlwifi: dvm: pair transport op-mode enter/leave Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 061/108] bpf: Add bpf_rbtree_{root,left,right} kfunc Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 062/108] f2fs: fix to bail out in get_new_segment() Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 063/108] netfilter: nft_set_pipapo: clamp maximum map bucket size to INT_MAX Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 064/108] libbpf: Add identical pointer detection to btf_dedup_is_equiv() Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 065/108] scsi: lpfc: Fix lpfc_check_sli_ndlp() handling for GEN_REQUEST64 commands Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 066/108] scsi: smartpqi: Add new PCI IDs Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 067/108] iommu/amd: Ensure GA log notifier callbacks finish running before module unload Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 068/108] wifi: iwlwifi: pcie: make sure to lock rxq->read Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 069/108] wifi: rtw89: 8922a: fix TX fail with wrong VCO setting Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 070/108] wifi: mac80211_hwsim: Prevent tsf from setting if beacon is disabled Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 071/108] netdevsim: Mark NAPI ID on skb in nsim_rcv Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 072/108] net/mlx5: HWS, Fix IP version decision Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 073/108] bpf: Use proper type to calculate bpf_raw_tp_null_args.mask index Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 074/108] wifi: mac80211: VLAN traffic in multicast path Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 075/108] Revert "mac80211: Dynamically set CoDel parameters per station" Sasha Levin
2025-06-04  0:54 ` [PATCH AUTOSEL 6.14 076/108] wifi: iwlwifi: Add missing MODULE_FIRMWARE for Qu-c0-jf-b0 Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 077/108] net: bridge: mcast: update multicast contex when vlan state is changed Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 078/108] net: bridge: mcast: re-implement br_multicast_{enable, disable}_port functions Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 079/108] vxlan: Do not treat dst cache initialization errors as fatal Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 080/108] bnxt_en: Remove unused field "ref_count" in struct bnxt_ulp Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 081/108] vxlan: Add RCU read-side critical sections in the Tx path Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 082/108] wifi: ath12k: correctly handle mcast packets for clients Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 083/108] wifi: ath12k: using msdu end descriptor to check for rx multicast packets Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 084/108] net: ethernet: ti: am65-cpsw: handle -EPROBE_DEFER Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 085/108] software node: Correct a OOB check in software_node_get_reference_args() Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 086/108] wifi: ath12k: make assoc link associate first Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 087/108] isofs: fix Y2038 and Y2156 issues in Rock Ridge TF entry Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 088/108] pinctrl: mcp23s08: Reset all pins to input at probe Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 089/108] wifi: ath12k: fix failed to set mhi state error during reboot with hardware grouping Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 090/108] scsi: lpfc: Use memcpy() for BIOS version Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 091/108] sock: Correct error checking condition for (assign|release)_proto_idx() Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 092/108] i40e: fix MMIO write access to an invalid page in i40e_clear_hw Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 093/108] ixgbe: Fix unreachable retry logic in combined and byte I2C write functions Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 094/108] RDMA/hns: initialize db in update_srq_db() Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 095/108] ice: fix check for existing switch rule Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 096/108] usbnet: asix AX88772: leave the carrier control to phylink Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 097/108] f2fs: fix to set atomic write status more clear Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 098/108] bpf, sockmap: Fix data lost during EAGAIN retries Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 099/108] net: ethernet: cortina: Use TOE/TSO on all TCP Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 100/108] octeontx2-pf: Add error log forcn10k_map_unmap_rq_policer() Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 101/108] wifi: ath12k: Fix incorrect rates sent to firmware Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 102/108] wifi: ath12k: Fix the enabling of REO queue lookup table feature Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 103/108] wifi: ath12k: Fix memory leak due to multiple rx_stats allocation Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 104/108] wifi: ath11k: determine PM policy based on machine model Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 105/108] wifi: ath12k: fix link valid field initialization in the monitor Rx Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 106/108] wifi: ath12k: fix incorrect CE addresses Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 107/108] wifi: ath12k: Pass correct values of center freq1 and center freq2 for 160 MHz Sasha Levin
2025-06-04  0:55 ` [PATCH AUTOSEL 6.14 108/108] net/mlx5: HWS, Harden IP version definer checks Sasha Levin

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=20250604005531.4178547-19-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=marcelo.leitner@gmail.com \
    --cc=oss@malat.biz \
    --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