summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
5 daystcp: Don't call skb_clone_and_charge_r() for close()d listener in ↵Kuniyuki Iwashima
tcp_v6_do_rcv(). tcp_v6_do_rcv() no longer calls skb_clone_and_charge_r() for TCP_LISTEN since commit 073d89808c06 ("net: fix data-races around sk->sk_forward_alloc"). However, there is still a small race window between tcp_v6_rcv() and tcp_v6_do_rcv(), where concurrent close() changes TCP_LISTEN to TCP_CLOSE, causing skb_clone_and_charge_r() to be called locklessly and resulting in the splat below. [0] Let's avoid calling skb_clone_and_charge_r() for TCP_CLOSE as well. This is fine for non-listeners because tcp_rcv_state_process() drops skb for TCP_CLOSE and opt_skb was freed immediately anyway. [0]: sk->sk_forward_alloc WARNING: net/ipv4/af_inet.c:162 at inet_sock_destruct+0x64d/0x810 net/ipv4/af_inet.c:162, CPU#1: ksoftirqd/1/28 Modules linked in: CPU: 1 UID: 0 PID: 28 Comm: ksoftirqd/1 Not tainted 7.2.0 #17 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 RIP: 0010:inet_sock_destruct+0x64d/0x810 net/ipv4/af_inet.c:162 Code: 3d 49 ff e9 06 fd ff ff e8 d0 5b 83 f8 90 0f 0b 90 e9 35 fe ff ff e8 c2 5b 83 f8 90 0f 0b 90 e9 c5 fe ff ff e8 b4 5b 83 f8 90 <0f> 0b 90 e9 04 ff ff ff e8 a6 5b 83 f8 90 0f 0b 90 e9 65 fe ff ff RSP: 0018:ffffc90000677bb8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff8880117bde80 RCX: ffffffff8957eb41 RDX: ffff88801dad5d00 RSI: ffffffff8957ec3c RDI: 0000000000000005 RBP: 00000000fffff000 R08: ffffffff8957eb41 R09: 00000000fffff000 R10: 0000000000000005 R11: 0000000000000000 R12: dffffc0000000000 R13: ffff8880117bdf10 R14: ffffffff81c08eb7 R15: 0000000000000003 FS: 0000000000000000(0000) GS:ffff8880d7ae5000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f93a1021138 CR3: 00000000207a9000 CR4: 0000000000350ef0 Call Trace: <TASK> __sk_destruct+0x82/0xae0 net/core/sock.c:2356 rcu_do_batch kernel/rcu/tree.c:2645 [inline] rcu_core+0x59c/0x1100 kernel/rcu/tree.c:2897 handle_softirqs+0x1e4/0x9b0 kernel/softirq.c:622 run_ksoftirqd kernel/softirq.c:1076 [inline] run_ksoftirqd+0x38/0x60 kernel/softirq.c:1068 smpboot_thread_fn+0x458/0xc80 kernel/smpboot.c:160 kthread+0x396/0x4a0 kernel/kthread.c:436 ret_from_fork+0x8e0/0xe40 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK> Fixes: e994b2f0fb92 ("tcp: do not lock listener to process SYN packets") Reported-by: Taras Madan <tarasmadan@google.com> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260914011420.115556-1-kuniyu@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 dayswifi: brcmfmac: log the firmware status when a connect failsRyohei Hashimoto
brcmf_bss_connect_done() receives the firmware event in @e but discards it on the failure path. Every failed connect is reported to cfg80211 as WLAN_STATUS_AUTH_TIMEOUT (16), whatever the firmware actually said, so userspace only ever sees: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16 The all-zero BSSID comes from the same place: conn_params is memset to zero and profile->bssid has not been filled in when the station never associated. status_code=16 therefore carries no information about the cause. It is not an AP response and it does not mean "authentication timed out" - it is the only failure value this driver can produce. This is a recurring source of confusion: [1] has been open since 2023 with more than twenty follow-ups and no explanation of the code, and covers BCM4345/6, BCM43430 and CYW43455 across several kernel versions. It supersedes [2], filed against the firmware repository a day earlier and closed in favour of it. The firmware's own status (BRCMF_E_STATUS_*) is more specific - FAIL, TIMEOUT, NO_NETWORKS, ABORT and so on - and it is already in hand. Log it so the cause can be narrowed down without rebuilding the kernel. bphy_err() is used rather than brcmf_dbg() or brcmf_info(): it is the form the rest of this file uses, and of the three it is the only one that is both visible in a distribution kernel and bounded. brcmf_dbg(CONN) expands to no_printk() unless CONFIG_BRCMDBG is set, which is what makes the reports in [1] and [2] impossible to act on - the people hitting this run stock kernels. brcmf_info() expands to a plain pr_info() in a non-debug build and is not rate limited, and wpa_supplicant retries the association every few seconds, so it would flood the log. bphy_err() is guarded by net_ratelimit() there, so a station retrying against an unreachable AP prints at most a few lines per second. All three fields are printed because only some of them are meaningful on each path into the failure branch. brcmf_is_nonetwork() keys off @status, so that is the useful field for a join that never associated - the case in [1]. brcmf_is_linkdown() keys off @event_code and @flags and does not look at @status at all, so @status can read 0 there; on those events it is @reason which carries the 802.11 reason code, as the mapping in brcmf_map_fw_linkdown_reason() shows. Printing the three together lets the reader tell which path was taken instead of guessing from one number. The status reported to cfg80211 is left alone; changing it would alter what userspace sees. [1] https://github.com/RPi-Distro/firmware-nonfree/issues/38 [2] https://github.com/raspberrypi/firmware/issues/1829 Assisted-by: Claude:claude-opus-5 Signed-off-by: Ryohei Hashimoto <laurel.medalist12@gmail.com> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com> Link: https://patch.msgid.link/20260913165526.4426-1-laurel.medalist12@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
5 dayswifi: brcmfmac: advertise firmware fast roam offload supportCarella Chen
Advertise NL80211_EXT_FEATURE_FAST_ROAM_OFFLOAD only when firmware reports FBT or OKC support. That lets userspace provide PMK material for firmware fast roaming without enabling the path on devices that cannot complete the offloaded roam. Assisted-by: GitHub-Copilot-CLI:gpt-5.5 Signed-off-by: Carella Chen <carella.chen@infineon.com> Signed-off-by: Jason Huang <jason.huang2@infineon.com> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com> Link: https://patch.msgid.link/20260911065656.1269623-6-Jason.Huang2@infineon.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
5 dayswifi: brcmfmac: report port authorization after offloaded roamingDarren Li
Firmware can complete FT or OKC roaming before the driver reports the connect or roam event to cfg80211. Detect those successful offloaded cases when the profile uses firmware 1X or roaming offload and the association request carries PMK cache state, FT is in use, or OKC is enabled. After reporting the connect or roam event, call cfg80211_port_authorized() so nl80211 emits the dedicated NL80211_CMD_PORT_AUTHORIZED event instead of reusing the reserved NL80211_ATTR_PORT_AUTHORIZED flag in CONNECT/ROAM notifications. Assisted-by: GitHub-Copilot-CLI:gpt-5.5 Signed-off-by: Darren Li <hsin-hung.li@cypress.com> Signed-off-by: Chung-Hsien Hsu <Chung-Hsien.Hsu@infineon.com> Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com> Signed-off-by: Carella Chen <carella.chen@infineon.com> Signed-off-by: Jason Huang <jason.huang2@infineon.com> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com> Link: https://patch.msgid.link/20260911065656.1269623-5-Jason.Huang2@infineon.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
5 dayswifi: brcmfmac: add PMK programming for firmware roaming offloadDarren Li
FT and OKC roaming offload need PMK material in firmware even when the initial 802.1X exchange is handled by userspace. Add a roaming firmware-supplicant profile state for those connections and allow PMK configuration while firmware FT or OKC state is active. Program the OKC PMK through the okc_info_pmk iovar before setting the regular PMK when firmware reports OKC state. Only select the roaming firmware-supplicant state when firmware advertises FBT or OKC support; devices without those capabilities keep the profile in the userspace supplicant state and do not issue roaming-offload specific iovars on every connect. For FT-PSK with firmware supplicant support, keep the profile in the PSK firmware-supplicant state. Assisted-by: GitHub-Copilot-CLI:gpt-5.5 Signed-off-by: Darren Li <hsin-hung.li@cypress.com> Signed-off-by: Chung-Hsien Hsu <Chung-Hsien.Hsu@infineon.com> Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com> Co-developed-by: Carella Chen <carella.chen@infineon.com> Signed-off-by: Carella Chen <carella.chen@infineon.com> Co-developed-by: Shelley Yang <shelley.yang@infineon.com> Signed-off-by: Shelley Yang <shelley.yang@infineon.com> Signed-off-by: Jason Huang <jason.huang2@infineon.com> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com> Link: https://patch.msgid.link/20260911065656.1269623-4-Jason.Huang2@infineon.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
5 dayswifi: brcmfmac: detect firmware FBT and OKC supportCarella Chen
Some firmware advertises Fast BSS Transition and Opportunistic Key Caching support through the firmware capability string. Track those capabilities so later roaming offload handling can be enabled only when firmware reports support. Assisted-by: GitHub-Copilot-CLI:gpt-5.5 Signed-off-by: Carella Chen <carella.chen@infineon.com> Signed-off-by: Jason Huang <jason.huang2@infineon.com> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com> Link: https://patch.msgid.link/20260911065656.1269623-3-Jason.Huang2@infineon.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
5 dayswifi: nl80211: add fast roam offload extended featureCarella Chen
Drivers can offload FT or OKC roaming without necessarily advertising full 802.1X 4-way handshake offload. Add an extended feature bit for that capability and allow PMK configuration when it is present. This gives userspace a way to provide PMK or PMK-R0 material needed by fast roaming firmware implementations while keeping the existing 4-way handshake offload capability unchanged. Assisted-by: GitHub-Copilot-CLI:gpt-5.5 Signed-off-by: Carella Chen <carella.chen@infineon.com> Signed-off-by: Jason Huang <jason.huang2@infineon.com> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com> Link: https://patch.msgid.link/20260911065656.1269623-2-Jason.Huang2@infineon.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
5 daysnetlink: specs: tcp_metrics: drop the RTT shift instructionsJakub Kicinski
All four RTT attributes tell the reader to left-shift, which inflates the value by 16 to 64 times, and the two usec ones say the result is in msecs. The attributes carry srtt_us and mdev_us, which hold 3 and 2 fractional bits. The shift to get the integer part would be a right shift. Drop the instructions instead of turning them around. The number of fractional bits is the part worth documenting, whether to shift, divide or convert to a double is up to the caller. While at it fix the acronym on the two variance attributes. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn> Link: https://patch.msgid.link/20260912234337.308298-2-kuba@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysnetlink: specs: tcp_metrics: fix the attribute length checksJakub Kicinski
TCP_FASTOPEN_COOKIE_MAX is the longest cookie we accept, not the shortest one. Cookies are even sized, from 4 bytes up, and the ones Linux itself generates are 8 bytes, so a 16 byte minimum declares all but the longest cookie invalid. The reference policy kept under #if 0 in tcp_metrics.c spells it as a maximum, which is what .len means for NLA_BINARY. The IPv6 addresses err the other way. The policy uses NLA_POLICY_EXACT_LEN() for both, so a request carrying a longer address is rejected with -ERANGE, even though the spec advertises 16 bytes as a mere minimum. Were the policy generated from this spec, as kernel-policy: global promises, the check would turn into NLA_POLICY_MIN_LEN() and start accepting over-long addresses, of which nla_get_in6_addr() would take the first 16 bytes. Nothing generated changes. fopen-cookie is reply-only so it never gets a policy entry, and exact-len only feeds the policy (and the fixed size array form, which needs a sub-type). Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn> Link: https://patch.msgid.link/20260912234337.308298-1-kuba@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daystcp: make smp_rmb() conditional in tcp_poll()Eric Dumazet
Commit a4d258036ed9 ("tcp: Fix race in tcp_poll") added smp_rmb() in tcp_poll() and smp_wmb() in tcp_reset() (now tcp_done_with_error()) to ensure that if tcp_poll() observed socket closure, it would also observe sk->sk_err. Currently, tcp_poll() unconditionally executes smp_rmb() at the end of every invocation, which on weakly-ordered architectures such as ARM64 emits a memory barrier instruction (dmb ishld) on the poll fast path, even for healthy, active sockets. However, tcp_poll() only needs this barrier if socket closure has been observed, to ensure that the error code set by tcp_done_with_error() before socket closure is visible before returning EPOLLERR. Move smp_rmb() inside the conditional block handling socket closure (shutdown == SHUTDOWN_MASK || state == TCP_CLOSE). For healthy connected sockets in epoll, tcp_poll() avoids the barrier entirely. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260913123224.762935-1-edumazet@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysmm: memblock: add missing HugeTLB flag nameMeijing Zhao
Commit 7d163a75f821 ("memblock: make HugeTLB bootmem allocation work with KHO") added MEMBLOCK_RSRV_HUGETLB but did not add the corresponding entry to flagname[]. As a result, memblock debugfs cannot report the flag by name. Add the missing RSV_HUGETLB entry. Fixes: 7d163a75f821 ("memblock: make HugeTLB bootmem allocation work with KHO") Signed-off-by: Meijing Zhao <zhaomeijing@lixiang.com> Signed-off-by: Wandun Chen <chenwandun@lixiang.com> Link: https://lore.kernel.org/lkml/20260821020910.3428585-2-zhaomeijing100@gmail.com/ Link: https://patch.msgid.link/20260915124641.2498280-1-chenwandun1@gmail.com Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
5 daysMerge branch 'for-7.4/block' into for-nextJens Axboe
* for-7.4/block: block: simplify disk_zone_set_cond() block: allow read-only and offline conventional zones block: fail zone management operations to read-only and offline zones block: always treat offline and read-only zones as dead block: propagate readonly and offline conditions to zone write plugs block: retry zone revalidation on capacity change block: drop all zone write plugs on capacity changes block: serialize zone revalidation block: introduce disk_for_all_zone_wplugs() block: improve blkdev_get_zone_info() block: refactor bdev_zone_is_seq() block: remember a zone type regardless of its condition block: refactor disk_update_zone_resources() block: refactor disk_revalidate_zone_resources() block: improve capacity handling during zone revalidation block: remove disk_free_zone_resources() block: cap atomic write size by PI buffer size constraints block: Fix the thaw_bdev reference in bdev_freeze() kernel-doc
5 daysblock: simplify disk_zone_set_cond()Damien Le Moal
disk_zone_set_cond() is used to set a zone condition afer a reset, a finish or a reset all operation. For a single zone reset or finish, we are guaranteed that the target zone is a sequential one that is not offline nor read-only (otherwise, the operation would have failed). For a reset all operation, there is no point in calling this function for offline and read-only zones since the condition checks in disk_zone_set_cond() will result in nothing being done. Simplify all this using disk_zone_is_offline_or_readonly() in blk_zone_reset_all_bio_endio() to skip zones that are offline or read-only. This change allows simplifying disk_zone_set_cond() by removing the zone condition checks. This change is also consistent with the fact that conventional zones can now have the offline or read-only condition. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Hannes Reinecke <hare@kernel.org> Link: https://patch.msgid.link/20260908085745.1082697-17-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: allow read-only and offline conventional zonesDamien Le Moal
With SCSI and ATA SMR HDDs, the storage element depopulation feature can change the condition of conventional zones to read-only (if a write head is depopulated) or to offline (if a read head is depopulated). However, the function blk_revalidate_zone_cond() currently does not allow these conditions for conventional zones, causing a zone revalidation failure. Remove blk_revalidate_zone_cond() and move the zone condition checks for conventional zones to blk_revalidate_conv_zone(), allowing the regular BLK_ZONE_COND_NOT_WP condition as well as the BLK_ZONE_COND_OFFLINE and BLK_ZONE_COND_READONLY conditions to match the conditions that can be seen from a zoned device with depopulated storage elements. The zone condition checks for sequential write required zones are moved to blk_revalidate_seq_zone() without any change to the conditions allowed. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://patch.msgid.link/20260908085745.1082697-16-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: fail zone management operations to read-only and offline zonesDamien Le Moal
Any zone management operation targeting a zone that is in the read-only or offline condition will fail. So there is no point in issuing such BIO. Modify the check in submit_bio_noacct() to use the new helper function bdev_zone_mgmt_allowed() to check that a zone is sequential (as was checked before) and also that the zone is not offline nor read-only. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://patch.msgid.link/20260908085745.1082697-15-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: always treat offline and read-only zones as deadDamien Le Moal
Since any write BIO targeting an offline or a read-only zone will fail, there is no point in keeping zone write plugs for these zones. So for any offline or read-only zone, the zone write plug should always be treated as dead. Do this by modifying disk_check_zone_wplug_dead() to always mark read-only and offline zones as dead to force a removal of the zone write plug from the disk hash table on BIO submission. blk_zone_wplug_prepare_bio() is also modified to have the same checks to immediately fail a write BIO targeting a read-only or offline zone. With these two changes, any newly issued or unplugged write BIO targeting a read-only or offline zone is immediately failed. Finally, disk_zone_wplug_sync_state() is modified to add a call to disk_mark_zone_wplug_dead() for the zone write plug of any read-only or offline zone found during zone revalidation or a report zones. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://patch.msgid.link/20260908085745.1082697-14-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: propagate readonly and offline conditions to zone write plugsDamien Le Moal
When revalidating the zones of a zoned block device, or when handling a zone which has a zone write plug flagged with BLK_ZONE_WPLUG_NEED_WP_UPDATE, the function disk_zone_wplug_sync_wp_offset() is used to update the write pointer offset of a zone write plug. However, this does not take into account the condition of the zone, which may have changed to readonly or offline, which in itself will always cause errors. In order to catch such errors, rename disk_zone_wplug_sync_wp_offset() to disk_zone_wplug_sync_state() and in addition to the zone write pointer, also update the zone write plug condition if the zone is readonly or offline. This change also requires changes to how a reset all zones operation (REQ_OP_ZONE_RESET_ALL) is handled so that the offline or read-only condition of zone write plugs is not overwritten with an erroneous empty condition. To do so, introduce the helper function disk_zone_is_offline_or_readonly() to skip updating the condition of zones that are read-only or offline and that do not have a zone write plug. For zones that have a zone write plug, the helper function disk_zone_wplug_is_offline_or_readonly() is used in disk_zone_wplug_set_wp_offset() to not update a zone write plug write pointer and condition for read-only and offline zones. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://patch.msgid.link/20260908085745.1082697-13-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: retry zone revalidation on capacity changeDamien Le Moal
When disk_revalidate_zone_resources() detects a capacity change, -ENODEV is returned, failing the disk revalidation. However, since a capacity change may happen due to a storage element removal being executed concurrently to blk_revalidate_disk_zones(), we can simply retry the revalidation to capture the new zone state with the new capacity without failing the revalidation. Retrying the revalidation is driven by disk_revalidate_zone_resources() returning -EAGAIN when a new valid capacity is detected. And to avoid getting stuck in an infinite loop revalidating zones, retries are limited to 2. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@kernel.org> Link: https://patch.msgid.link/20260908085745.1082697-12-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: drop all zone write plugs on capacity changesDamien Le Moal
If during revalidation, we detect a capacity change for a zoned block device, e.g. due to a storage element removal on an HDD, we can assume that the device was reformatted, which implies that all sequential zones are empty. For such case, we can remove and free all zone write plugs in the gendisk hash table by marking them as dead, thus avoiding also to leave zone write plugs for zones that are beyond the new device capacity in the disk hash table. Introduce the function disk_revalidate_capacity() to do this and call this new function at the beginning of blk_revalidate_disk_zones(), so that the zone revalidation process can re-create, if needed, any zone write plug for sequential zones that are not empty. The checks on the capacity and zone size that were in blk_revalidate_disk_zones() are moved to disk_revalidate_capacity() and if true, also trigger dropping all zone write plugs. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260908085745.1082697-11-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: serialize zone revalidationDamien Le Moal
The zone related fields of struct gendisk can be modified by blk_revalidate_disk_zones() either on the first scan of the disk, or during user triggered scans or device revalidation, if some characteristics of the disk has changed (e.g. the disk capacity). Changes to these fields are always done with the disk request queue frozen so that BIO processing does not see any inconsistent state of the zones. This implies a contract that reading these zone related fields must always be done while holding a usage count on the request queue of the disk. However, increasing the usage count of the disk request queue cannot be done from the context of blk_revalidate_disk_zones() itself, as that would prevent freezing the disk queue and result in a deadlock. This prevents blk_revalidate_disk_zones() from consulting the zone related fields of struct gendisk to detect, for instance, a change in the number of zones of the disk. For such case, we want to detect the change, take appropriate measures and revalidate exclusively revalidate the zones to avoid concurrent revalidation calls to see the same change while corrections are already on-going. A simple solution to avoid this issue is to introduce a mutex to serialize calls to blk_revalidate_disk_zones() and ensure only a single context at a time can modify the zone related fields of a gendisk. In preparation for handling disk capacity revalidation in blk_revalidate_disk_zones(), do so with the mutex zone_revalidate_mutex. This mutex is initialized in disk_init_zone_resources(), destroyed in disk_release_zone_resources() and taken and released only in blk_revalidate_disk_zones() to serialize the execution of this function. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260908085745.1082697-10-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: introduce disk_for_all_zone_wplugs()Damien Le Moal
Introduce the helper function disk_for_all_zone_wplugs() to allow executing an actor function on all hashed zone write plugs. This helper is used to simplify the implementation of blk_zone_reset_all_bio_endio() and queue_zone_wplugs_show(). Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://patch.msgid.link/20260908085745.1082697-9-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: improve blkdev_get_zone_info()Damien Le Moal
Add a zone state array bound check to ensure that like disk_zone_get_state(), we never attempt to access the zone state array beyond its size. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@kernel.org> Link: https://patch.msgid.link/20260908085745.1082697-8-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: refactor bdev_zone_is_seq()Damien Le Moal
Define the helper function disk_zone_is_seq() and use it to refactor bdev_zone_is_seq(). disk_zone_is_seq() is also used in blk_zone_wplug_handle_write(). Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260908085745.1082697-7-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: remember a zone type regardless of its conditionDamien Le Moal
Currently, bdev_zone_is_seq() identifies a sequential zone by looking at the zone condition, assuming that any zone that does not have the condition BLK_ZONE_COND_NOT_WP is a sequential write required zone. That is correct only as long as the target zoned device does not support storage element depopulation (aka HDD head depopulation), which is a feature that can transition conventional zones to the read-only or offline condition. For such device, we cannot distinguish anymore between conventional and sequential zones using the zone condition as both zone types can have the same conditions. Prepare for fully supporting storage element depopulation and restoration by caching the type of a zone in addition to its condition. This is implemented by reformating the zones_cond array using a more compact zone condition representation with the new enum blk_zstate. This zone condition representation only uses the lower 4 bits of a byte for the condition values, thus leaving the high order 4 bits of each byte entry of the array for flags. The flag BLK_ZFLAG_CONV is defined to indicate conventional zones. The helper functions blk_zstate_to_zone_cond() and blk_zone_cond_to_zstate() are implemented using lookup tables to convert between enum blk_zone_condition values and enum blk_zstate zone condition values. The helper blk_zstate_set() can be used to set a zones_state entry with a zone condition and zone type flags, safely in accordance to the size of the zone state array being accessed. This helper is used in disk_zone_set_cond() to update a zone condition. bdev_zone_is_seq() is modified to use the flags of the zones_state array entries to identify sequential zones. The zones_state array initialization and revalidation is unchanged from the former zones_cond array. Overall, any zone condition that is being considered outside of the zones_state array always uses the enum blk_zone_condition values as before, thus minimizing the number of changes. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://patch.msgid.link/20260908085745.1082697-6-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: refactor disk_update_zone_resources()Damien Le Moal
Since the function disk_update_zone_resources() does a lot of checks beside updating a zoned disk limits and resources, rename this function to disk_revalidate_zone_resources(). To keep all the checks together, move the capacity checks (including the check on the end sector of the last zone of the disk) in blk_revalidate_disk_zones() to this function. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@kernel.org> Link: https://patch.msgid.link/20260908085745.1082697-5-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: refactor disk_revalidate_zone_resources()Damien Le Moal
The function disk_revalidate_zone_resources() is misnamed as it does not revalidate anything but rather allocates the revalidation arguments and then calls disk_alloc_zone_resources() to initialize the disk zone resources if they are needed and not already allocated. Make this function less confusing by renaming it disk_init_revalidate_args() and moving the call to disk_alloc_zone_resources() into blk_revalidate_disk_zones(). As before, this function is only called if the zone resources are needed and not yet allocated. The initialization of the atomic nr_zone_wplugs is also moved to the function disk_init_zone_resources() so that this is done once and not on all revalidation. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://patch.msgid.link/20260908085745.1082697-4-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: improve capacity handling during zone revalidationDamien Le Moal
While executing blk_revalidate_disk_zones(), a disk capacity is looked at using get_capacity() several times: on entry to blk_revalidate_disk_zones(), when allocating zone revalidation arguments in disk_revalidate_zone_resources(), while validating zones in blk_revalidate_zone_cb() and one last time at the end of blk_revalidate_disk_zones() to check that all zones have been inspected. Since this is all done while passthrough commands can be issued, it is possible that a capacity change operation (e.g. the removal of a storage element on a SCSI or SATA disk) is concurrently executed, potentially resulting in an inconsistent or conflicting revalidation with potentially out-of-bound accesses to the zone condition array. Prevent issues by using get_capacity() once on entry to blk_revalidate_disk_zones(), remembering this capacity as a field of struct blk_revalidate_zone_args and using that field while revalidating zones. A final second call to get_capacity() is done at the end of blk_revalidate_disk_zones() to ensure that the disk capacity has not changed, thus revalidating the capacity (and number of zones) itself. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260908085745.1082697-3-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: remove disk_free_zone_resources()Damien Le Moal
In the rare event when revalidating the zones of a zoned block device fails, the device capacity will be dropped to 0. In such case, the zoned block device will either be rescanned and restored or will be dropped entirely and its gendisk will be destroyed. So calling disk_free_zone_resources() from blk_revalidate_disk_zones() in case of an error does not make much sense. We can keep the zone resources in case the device is rescanned and restored and simply free all resources in disk_release_zone_resources() when the gendisk is destroyed. Remove the call to disk_free_zone_resources() from blk_revalidate_disk_zones() and squash disk_free_zone_resources() inside disk_release_zone_resources(). With this change, the conditional creation of the zone write plugs work queue is not necessary anymore as the workqueue will keep existing together with all other resources until the disk is released. This simplifies disk_alloc_zone_resources(). Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://patch.msgid.link/20260908085745.1082697-2-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: cap atomic write size by PI buffer size constraintsJohn Garry
Commit 1418b5633ca9 ("block: cap atomic write size by PI buffer size constraints") attempted to fix atomic writes limits according to integrity limits. However, it just reduced the atomic_write_max_sectors. The other atomic write limits - unit min and unit max - are not derived directly from this value. Update blk_atomic_writes_update_limits() to properly set the atomic write limits according to integrity limits. Signed-off-by: John Garry <john.garry@linux.dev> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260914132323.208321-1-john.garry@linux.dev Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysblock: Fix the thaw_bdev reference in bdev_freeze() kernel-docKarl Mehltretter
The kernel-doc comment of bdev_freeze() refers to thaw_bdev, which was renamed to bdev_thaw by commit 982c3b305843 ("bdev: rename freeze and thaw helpers"). Say bdev_thaw. Fixes: 982c3b305843 ("bdev: rename freeze and thaw helpers") Assisted-by: LLM Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christian Brauner (Amutable) <brauner@kernel.org> Link: https://patch.msgid.link/20260911233415.31271-1-kmehltretter@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysntfs: avoid truncate and writeback deadlockHyunchul Lee
ntfs_non_resident_attr_shrink() drops page-cache folios after freeing clusters and truncating the runlist. The VFS truncate path calls it with mrec_lock held. A folio writeback can need the same lock to resolve its iomap mapping, so truncate can wait for writeback while writeback waits for mrec_lock. A hung-task call stack: truncate: mrec_lock -> truncate_inode_pages() -> folio lock/writeback writeback: folio lock/writeback -> ntfs_write_iomap_begin() -> mrec_lock ntfs_setattr_size() already calls truncate_setsize() before ntfs_truncate_vfs() acquires mrec_lock. Reuse that page-cache truncation in the VFS path and skip the duplicate truncation under mrec_lock. Keep the cleanup for internal attribute callers, which do not call truncate_setsize(). This avoids synchronously flushing the whole discarded tail while preserving page-cache correctness. Fixes: 4e646ecd4475 ("ntfs: drop stale page-cache when shrinking a non-resident attr") Cc: stable@vger.kernel.org Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
5 daysselftests/tc-testing: add hhf hh_limit cap testsJamal Hadi Salim
Cover the new TCA_HHF_HH_FLOWS_LIMIT bound: values above 2*HH_FLOWS_CNT (4294967295, 65536, 2049) are rejected with the configured limit left untouched on both the change and the add path, the boundary value 2048 is accepted (installed at 100 first so the boundary change is load-bearing), and an add-time hh_limit 500 is preserved instead of being clobbered by the default. Reviewed-by: Victor Nogueira <victor@mojatatu.com> Tested-by: hybris <hybris@mojatatu.ai> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/QDISC-B855.v1.20260911153152@mojatatu.com.2 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysnet/sched: hhf: cap hh_flows_limit at change timeJamal Hadi Salim
hhf_change() stores TCA_HHF_HH_FLOWS_LIMIT with no upper bound. A huge hh_flows_limit lets each new heavy-hitter flow pass the hh_flows_current_cnt check in alloc_new_hh() and forces a fixed-size kzalloc(GFP_ATOMIC) per flow under spoofed traffic, for unbounded memory growth. Bound the attribute with NLA_POLICY_MAX() at 2*HH_FLOWS_CNT (the hhf_init() default) and report the rejected value via extack. The deprecated nested parse is kept: legacy tc does not set NLA_F_NESTED on TCA_OPTIONS. Configs relying on hh_limit above the default were relying on unbounded, unsafe behaviour and are not supported going forward. hhf_init() also ran hhf_change() before setting the default hh_flows_limit, so a user-supplied hh_limit at add time was clobbered back to 2048. Set the default before hhf_change() so the configured value sticks. This is a follow-up to commit eb56a495f59b ("net/sched: hhf: clamp quantum in change and init paths"), which bounded the quantum of the same qdisc; the hh_flows_limit bound is the remaining unbounded knob of that series' scope. Conditions to recreate the bug: CAP_NET_ADMIN in a user namespace; tc qdisc change dev X root hhf hh_limit 4294967295 succeeds and the value is echoed by tc qdisc show, unbounding heavy-hitter flow allocations; also tc qdisc add dev X root hhf hh_limit 500 stores 2048 instead of 500. Fixes: 10239edf86f1 ("net-qdisc-hhf: Heavy-Hitter Filter (HHF) qdisc") Cc: stable@vger.kernel.org Reported-by: Sashiko (gemini) <sashiko-bot@kernel.org> Closes: https://sashiko.dev/#/patchset/20260822195509.112717-1-jhs@mojatatu.com Reviewed-by: Victor Nogueira <victor@mojatatu.com> Tested-by: hybris <hybris@mojatatu.ai> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/QDISC-B855.v1.20260911153152@mojatatu.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysMerge branch 'ip_tunnel-support-per-netns-device-unregistration'Paolo Abeni
Kuniyuki Iwashima says: ==================== ip_tunnel: Support per-netns device unregistration. Patch 1 - 3 are prep patches to unlink ip_tunnel device from the hash table in ip_tunnel_dellink() only. Patch 4 removes ip_tunnel_del() from ip_tunnel_uninit() to ip_tunnel_dellink(). Patch 5 & 6 adds mutex to protect the per-netns hash table. Patch 7 uses unregister_netdevice_queue_net() to support cross-netns device unregistration. v2: https://lore.kernel.org/netdev/20260909234422.2416506-1-kuniyu@google.com/ v1: https://lore.kernel.org/netdev/20260907225846.3787676-1-kuniyu@google.com/ ==================== Link: https://patch.msgid.link/20260912230043.2586313-1-kuniyu@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysip_tunnel: Support per-netns device unregistration.Kuniyuki Iwashima
ip_tunnel_delete_net() iterates ip_tunnel devices whose link_net is dying and queues them for destruction. The devices may reside in different netns. Let's use unregister_netdevice_queue_net() to support per-netns device unregistration. Even after ip_tunnel_delete_net() queues a cross-netns ip_tunnel device, ip_tunnel_changelink(), ip_tunnel_dellink(), and ip_tunnel_ctl() could be called concurrently for it (once RTNL is removed). In such a case, __rtnl_net_unlock() will perform the unregistration. Also, ip_tunnel_ctl() needs to check check_net(t->net), otherwise it could create a new dev in dying netns after ip_tunnel_delete_net(). In the example below, we can see the fallback tunnel device (gre0) and the cross-netns device (gre1) are unregistered by different processes: # bpftrace -e '#include <linux/netdevice.h> kprobe:ip_tunnel_uninit { $dev = (struct net_device *)arg0; printf("PID: %d | DEV: %s%s\n", pid, $dev->name, kstack()); } kprobe:ipgre_exit_rtnl { printf("PID: %d%s\n", pid, kstack()); }' & # ip netns add ns1 # ip netns add ns2 # ip -n ns1 link add name gre1 link-netns ns2 \ type gre local 192.168.0.1 remote 192.168.1.1 # ip netns del ns2 PID: 12 ipgre_exit_rtnl+5 ops_undo_list+702 cleanup_net+1122 process_scheduled_works+2538 ... PID: 12 | DEV: gre0 <------ fallback device (itn->fb_tunnel_dev). ip_tunnel_uninit+5 unregister_netdevice_many_notify+7129 unregister_netdevice_many_net+1050 __rtnl_net_unlock+37 ops_undo_list+754 cleanup_net+1122 process_scheduled_works+2538 ... PID: 10 | DEV: gre1 ip_tunnel_uninit+5 unregister_netdevice_many_notify+7129 unregister_netdevice_many_net+1050 rtnl_net_work_func+136 process_scheduled_works+2538 Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260912230043.2586313-8-kuniyu@google.com Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysip_tunnel: Protect ip_tunnel_net.tunnels[] with mutex.Kuniyuki Iwashima
struct ip_tunnel.net is the netns where encapsulated packets flow into. struct ip_tunnel is linked to ip_tunnel_net.tunnels[] of netns. During netns dismantle or module unload, ip_tunnel_delete_net() iterates the list and queues devices for destruction regardless of the devices' netns. Thus, once RTNL is removed, the list can be modified concurrently from different netns due to device removal. Let's protect it with per-netns mutex. Note that dev_siocdevprivate() calls netdev_lock_ops() but it must be NOP for tunnel devices to avoid AB-BA deadlock. DEBUG_NET_WARN_ON_ONCE() is added to annotate the locking explicitly. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260912230043.2586313-7-kuniyu@google.com Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysip_tunnel: Unify error paths in ip_tunnel_newlink() and ip_tunnel_changelink().Kuniyuki Iwashima
The next patch will introduce per-netns mutex and acquire it in ip_tunnel_newlink() and ip_tunnel_changelink(). To make the diff cleaner, let's unify the error paths. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260912230043.2586313-6-kuniyu@google.com Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysip_tunnel: Centralise ip_tunnel_del() to ip_tunnel_dellink().Kuniyuki Iwashima
With the previous patch, itn->fb_tunnel_dev can be removed via ->dellink(). However, ioctl(SIOCDELTUNNEL) still uses unregister_netdevice(), which requires ip_tunnel_del() in ip_tunnel_uninit(). Let's use ip_tunnel_dellink() everywhere to remove ip_tunnel device and remove ip_tunnel_del() in ip_tunnel_uninit(). Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260912230043.2586313-5-kuniyu@google.com Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysip_tunnel: Don't pass rtnl_link_ops to ip_tunnel_delete_net().Kuniyuki Iwashima
ip_tunnel_delete_net() no longer uses the 3rd argument, struct rtnl_link_ops *ops. Let's remove it. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260912230043.2586313-4-kuniyu@google.com Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysip_tunnel: Set itn->fb_tunnel_dev to NULL in ip_tunnel_delete_net().Kuniyuki Iwashima
ip_tunnel_dellink() ignores itn->fb_tunnel_dev, so the per-netns fallback tunnel device cannot be removed by userspace. This also makes default_device_exit_batch() impossible to remove the device since it calls ->dellink(). So, ip_tunnel_delete_net() has to iterate devices in the dying netns and call unregister_netdevice_queue() directly. But then, this duplicates ip_tunnel_del() in ip_tunnel_dellink() and ip_tunnel_uninit(). Let's set itn->fb_tunnel_dev to NULL in ip_tunnel_delete_net() and remove for_each_netdev_safe() in ip_tunnel_delete_net(). Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260912230043.2586313-3-kuniyu@google.com Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysipmr: Call ->dellink() to remove DVMRP tunnel device.Kuniyuki Iwashima
ipmr.c uses unregister_netdevice() to remove DVMRP tunnel devices created in ipmr_new_tunnel(). This is fine because currently ip_tunnel_uninit() also calls ip_tunnel_del() to unlink the device from the hash table. However, we will move ip_tunnel_del() from ip_tunnel_uninit() to ip_tunnel_dellink(). Removing DVMRP tunnel devices by unregister_netdevice() would leave them in the hash table. Let's call ->dellink for DVMRP tunnel devices. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260912230043.2586313-2-kuniyu@google.com Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
5 daysmedia: i2c: t4ka3: drop unmatched runtime PM putGuangshuo Li
t4ka3_probe() marks the device runtime active and enables runtime PM, but does not increment the runtime PM usage counter. Nevertheless, the probe failure path calls pm_runtime_put_noidle(), which has no matching runtime PM get operation. pm_runtime_put_noidle() currently does not decrement usage_count when it is already zero, so the call is ineffective. Remove the unmatched put to keep the runtime PM reference handling balanced and avoid misleading cleanup code. This issue was found by manual code inspection. Fixes: fd55319692151 ("media: Add t4ka3 camera sensor driver") Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
5 daysmedia: i2c: ov2735: fix power cleanup on removeGuangshuo Li
ov2735_probe() explicitly powers on the sensor before enabling runtime PM. The probe failure paths call ov2735_power_off(), but the remove path does not perform the corresponding power-off operation. The managed runtime PM helpers only clean up the runtime PM state. devm_pm_runtime_set_active_enabled() disables runtime PM and restores the suspended state during device resource release, while devm_pm_runtime_get_noresume() drops the runtime PM usage reference. Neither helper invokes ov2735_power_off(). As a result, removing the driver after a successful probe can leave the sensor clock and regulators enabled and the GPIOs in the powered state. Call ov2735_power_off() from ov2735_remove() to match the successful ov2735_power_on() performed during probe. This issue was found by manual code inspection. Fixes: fa9e6df636fb ("media: i2c: add ov2735 image sensor driver") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
5 dayssysctl: Rewrite selftests on top of KTAP helpersJoel Granados
Use kselftest/ktap_helpers.sh so that each test reports its own KTAP result. A failure names the test but continues with the rest of the suite. Tests are functions prefixed by "test_", they run in a subshell and do not leak state to other tests. Sysctl test assertions (assert*) emit a KTAP diagnostic and return a status, never exit. The sysctl selftests arguments are: -r N repeat selected tests N times (default 1) -l list discovered tests -t T space separated tests list. For example "test_1 test_2" -s N base seed for the randomized bitmap iterations. -h, --help help It is a single commit to avoid intermediate states where the runner exists with no tests or where scaffolding is added only to be deleted later in the same series. Neither bisects usefully. Assisted-by: Claude:claude-opus-5 Signed-off-by: Joel Granados <joel.granados@kernel.org>
5 dayssysctl: remove redundant CONFIG_PROC_FS checksOleg Nesterov
Now that CONFIG_PROC_SYSCTL is gone, CONFIG_SYSCTL depends on CONFIG_PROC_FS directly in fs/proc/Kconfig, so the double guard defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS) is redundant. Simplify to "#ifdef CONFIG_SYSCTL". Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Joel Granados <joel.granados@kernel.org>
5 dayssysctl: consolidate CONFIG_SYSCTL into a single block in kernel/sysctl.cOleg Nesterov
After the previous cleanup there are two CONFIG_SYSCTL blocks. Move the second block up into the first one and eliminate the redundant Also add a proc_do_static_key() stub to the #else block. Not strictly necessary today, but consistent with the other stubs declared in include/linux/sysctl.h. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Joel Granados <joel.granados@kernel.org>
5 dayssysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.cOleg Nesterov
After the removal of CONFIG_PROC_SYSCTL, several #ifdef CONFIG_SYSCTL blocks ended up nested inside the outer (now the same) CONFIG_SYSCTL guards. Collapse them and remove a now-stale "/proc/sys support" comment which referred to CONFIG_PROC_SYSCTL. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Bradley Morgan <include@grrlz.net> Signed-off-by: Joel Granados <joel.granados@kernel.org>
5 dayssysctl: Add 0013 to test partially updated vectorsJoel Granados
Add coverage for partially updated sysctl vectors with test 0013. It makes sure that the sysctl vector is unchanged when one of the elements is not valid. Reviewed-by: Bradley Morgan <include@grrlz.net> Signed-off-by: Joel Granados <joel.granados@kernel.org>
5 dayssysctl: Disallow partial updates for erroneous sysctl vectorsJoel Granados
When updating the kernel sysctl vectors there is a chance that not all vector elements are updated due to erroneous input. Use a staging variable that holds a copy of the vector and commits to the actual table->data only when all input is successfully updated. This does **not** make the write atomic as a reader can still see a partially updated vector. The staging is only for vectors; cases where table->data points to a variable should not be staged as they will not be updated on input error. PROC_VEC_UINT is not included because UINT arrays are not allowed. Replace first with nr_conv, incremented where first was cleared. first is exactly nr_conv == 0, and the counter doubles as the number of elements to publish. Example of behavior that is being prevented: # echo "4 4 1 7" > /proc/sys/kernel/printk # echo "1 x" > /proc/sys/kernel/printk -bash: echo: write error: Invalid argument # cat /proc/sys/kernel/printk 1 4 1 7 <- incorrect It should be unchanged ("4 4 1 7") on error. Link: https://lore.kernel.org/all/tencent_A860C873956A52E26AD8D309A308A241BA08@qq.com/ Reviewed-by: Bradley Morgan <include@grrlz.net> Signed-off-by: Joel Granados <joel.granados@kernel.org>
5 dayssysctl: Reject uint arrays before calling the general proc_vecJoel Granados
Move the UINT vector size check to proc_douintvec_conv; the function that routes UINT types only. Route all the UINT calls (including proc_dou8vec_minmax) through proc_douintvec_conv. UINT proc handlers that incorrectly define maxlen will now return -EINVAL instead of 0 in the cases where data is missing, lenp is 0 or ppos is 0. Note that maxlen == 0 is not considered as miss-defined. Reviewed-by: Bradley Morgan <include@grrlz.net> Signed-off-by: Joel Granados <joel.granados@kernel.org>