id
stringlengths
40
40
instruction
stringlengths
68
308
input
stringlengths
17
33.4k
output
stringlengths
100
30k
f8373d7090b745728de66308deeecc67e8d319ce
Analyze and fix the following issue in the Linux kernel code: sctp: fix uninit-value in __sctp_rcv_asconf_lookup()
Problem Details: __sctp_rcv_asconf_lookup() in net/sctp/input.c only checks that the ASCONF chunk can hold the ADDIP header and a parameter header, then calls af->from_addr_param(), which reads the full address (16 bytes for IPv6) trusting the parameter's declared length. An unauthenticated peer can send a truncated t...
```diff diff --git a/net/sctp/input.c b/net/sctp/input.c index e119e460ccde..864741fae418 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c @@ -1204,6 +1204,14 @@ static struct sctp_association *__sctp_rcv_asconf_lookup( /* Skip over the ADDIP header and find the Address parameter */ param = (union sctp_addr_par...
9f9fdd88e9f6cc28aa7e57472d054bef52d5d3f7
Analyze and fix the following issue in the Linux kernel code: net: eth: benet: Use strscpy() to copy strings into arrays
Problem Details: Replacing strcpy() with strscpy() ensures that overflow of the target buffer cannot happen. Signed-off-by: David Laight <david.laight.linux@gmail.com> Link: https://patch.msgid.link/20260608095500.2567-4-david.laight.linux@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
```diff diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index eab81e073e1e..230c91559322 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -2508,7 +2508,7 @@ int lancer_cmd_read_object(struct be_adapter *a...
d930276f2cddd0b7294cac7a8fe7b877f6d9e08d
Analyze and fix the following issue in the Linux kernel code: bnxt_en: Fix NULL pointer dereference
Problem Details: PCIe errors detected by a Root Port or Downstream Port cause error recovery services to run on all subordinate devices regardless of administrative state. The .error_detected() callback, bnxt_io_error_detected(), disables and synchronizes IRQs via bnxt_disable_int_sync(), which calls bnxt_cp_num_to_ir...
```diff diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 35e1f8f663c7..c999f9733326 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5748,7 +5748,7 @@ static void bnxt_disable_int_sync(struct bnxt *bp) { ...
a5f8a90ac9f77c678a9781c0a464b635e0d63e49
Analyze and fix the following issue in the Linux kernel code: sctp: stream: fully roll back denied add-stream state
Problem Details: When ADD_OUT_STREAMS is denied, SCTP only shrinks the queued chunks and then lowers outcnt. That leaves removed stream metadata behind, so a later re-add can reuse a stale ext and hit a null-pointer dereference in the scheduler get path. Fix the rollback by tearing down the removed stream state the sa...
```diff diff --git a/net/sctp/stream.c b/net/sctp/stream.c index c2247793c88b..5c2fdedea088 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c @@ -1038,6 +1038,7 @@ struct sctp_chunk *sctp_process_strreset_resp( stsn, rtsn, GFP_ATOMIC); } else if (req->type == SCTP_PARAM_RESET_ADD_OUT_STREAMS) { struct sct...
e813df3ef5294b1ad548cd21dd8df0d0683873a4
Analyze and fix the following issue in the Linux kernel code: ASoC: renesas: fsi: Fix register access from in-flight IRQ after shutdown
Problem Details: In-flight IRQs may still be running when the SPU clock is disabled, leading to register access after shutdown and causing system hangs. Fix this to use fsi_stream_is_working() when handling in-flight IRQ handlers. If no streams are active, the handler now returns immediately to prevent hardware access...
```diff diff --git a/sound/soc/renesas/fsi.c b/sound/soc/renesas/fsi.c index 0bd0e0c8c5a3..3e3c6fd7c56b 100644 --- a/sound/soc/renesas/fsi.c +++ b/sound/soc/renesas/fsi.c @@ -470,6 +470,10 @@ static int fsi_get_current_fifo_samples(struct fsi_priv *fsi, static void fsi_count_fifo_err(struct fsi_priv *fsi) { + if (!...
859efe92b0bc9a6cabbb4ca9c201d58249de86f4
Analyze and fix the following issue in the Linux kernel code: ASoC: renesas: fsi: Fix trigger stop ordering
Problem Details: Call fsi_stream_stop() before fsi_hw_shutdown(). This matches the existing order in the suspend path. This change ensures all register accesses during stream shutdown are fully completed before disabling the clocks. Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Suggested-by: Kuninori ...
```diff diff --git a/sound/soc/renesas/fsi.c b/sound/soc/renesas/fsi.c index 8cbd7acc26f4..800ac40f9680 100644 --- a/sound/soc/renesas/fsi.c +++ b/sound/soc/renesas/fsi.c @@ -1586,10 +1586,10 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, ret = fsi_stream_transfer(io); break; case ...
1a1e62a5a48494cdf33e3bfb82fb8f408da7c4cc
Analyze and fix the following issue in the Linux kernel code: kconfig: tests: fix typo in comment
Problem Details: scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py contains a typo "COFIG_" for "CONFIG_". Fix it. Discovered while searching for typos in CONFIG_* variable references. Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com> Link: https://patch.msgid.link/20260609021712.7965-1-enelsonmoore@gm...
```diff diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py b/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py index ffd469d1f226..791ed659c76b 100644 --- a/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py @@ -8,7 +8,7 @@ for s...
9b2929eed4d2d30f1aebe45bd2a8973eaab2428c
Analyze and fix the following issue in the Linux kernel code: ASoC: codecs: aw88261: make volume control usable
Problem Details: - Invert the value to match userspace expectations (in the hardware, positive numbers represent negative dB attenuation) - Provide TLV metadata for the dB scale (and divide the raw values by 2 as the excessive precision used by HW is not representable in TLV) - Do not unnecessarily reset the volume...
```diff diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c index bc37067bef96..b14ca4163043 100644 --- a/sound/soc/codecs/aw88261.c +++ b/sound/soc/codecs/aw88261.c @@ -15,6 +15,7 @@ #include <linux/regulator/consumer.h> #include <sound/soc.h> #include <sound/pcm_params.h> +#include <sound/tlv.h> ...
79c053a1ff9d3ab31cefbc791e8d7816ba830491
Analyze and fix the following issue in the Linux kernel code: ASoC: codecs: aw88261: fix incorrect masks for boost regs
Problem Details: The boost-related register fields used in aw88261_reg_force_set use the exact same definitions as the rest of the fields, where the mask must be inverted when passing it to regmap_update_bits, but they weren't inverted here. Fixes: 028a2ae25691 ("ASoC: codecs: Add aw88261 amplifier driver") Signed-off...
```diff diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c index acf17dd4a90e..bc37067bef96 100644 --- a/sound/soc/codecs/aw88261.c +++ b/sound/soc/codecs/aw88261.c @@ -245,22 +245,22 @@ static void aw88261_reg_force_set(struct aw88261 *aw88261) if (aw88261->frcset_en == AW88261_FRCSET_ENABLE) { ...
1b92b0673d5e9a2f68f998194cbc73718358cd72
Analyze and fix the following issue in the Linux kernel code: ASoC: codecs: aw88261: support changing sample rate and bit width
Problem Details: The aw88261 driver only worked with 32-bit 48kHz streams so far due to the lack of a proper PLL initialization sequence. Fix by selecting all the necessary PLL settings based on what was passed to us by the hw_params/set_fmt ops. This replaces the strange downstream routine that tries two divider modes...
```diff diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c index a6805d5405cd..2064e72b51af 100644 --- a/sound/soc/codecs/aw88261.c +++ b/sound/soc/codecs/aw88261.c @@ -13,6 +13,7 @@ #include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <sound/soc.h> +#include <sound/pcm_params.h...
3c60184e39b57e5efe664fe8540cdbc1bc7ea899
Analyze and fix the following issue in the Linux kernel code: spi: dw: fix race between IRQ handler and error handler on SMP
Problem Details: On SMP systems, dw_spi_handle_err() can be called from the SPI core kthread while the IRQ handler is still accessing the FIFO on another CPU. Resetting the chip via dw_spi_reset_chip() during an active FIFO read/write causes a bus error. Fix this by calling disable_irq() before the chip reset, which m...
```diff diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index b47637888c5c..4672bc2a873a 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -472,7 +472,9 @@ static inline void dw_spi_abort(struct spi_controller *ctlr) if (dws->dma_mapped) dws->dma_ops->dma_stop(dws); + d...
0e152e4126fa14e697d8514cdd1567b18c679f08
Analyze and fix the following issue in the Linux kernel code: ASoC: amd: yc: Add DMI quirk for ASUS EXPERTBOOK PM1403CDA
Problem Details: Add a DMI quirk for the ASUS EXPERTBOOK PM1403CDA fixing the issue where the internal microphone was not detected. Link: https://bugzilla.kernel.org/show_bug.cgi?id=221608 Signed-off-by: Zhang Heng <zhangheng@kylinos.cn> Link: https://patch.msgid.link/20260604125815.42297-1-zhangheng@kylinos.cn Signed...
```diff diff --git a/sound/soc/amd/yc/acp6x-mach.c b/sound/soc/amd/yc/acp6x-mach.c index b426cda529a9..ce229f5d0d46 100644 --- a/sound/soc/amd/yc/acp6x-mach.c +++ b/sound/soc/amd/yc/acp6x-mach.c @@ -808,6 +808,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_BOARD_NAME, "MS-17LN"), ...
606c0826bd90384a54571c0c5475ca41f50164ea
Analyze and fix the following issue in the Linux kernel code: spi: meson-spifc: fix runtime PM leak on remove
Problem Details: pm_runtime_get_sync() increments the runtime PM usage counter even when it returns an error. meson_spifc_remove() uses it to resume the controller before disabling runtime PM, but never drops the usage counter again. Balance the get with pm_runtime_put_noidle() after disabling runtime PM, matching the...
```diff diff --git a/drivers/spi/spi-meson-spifc.c b/drivers/spi/spi-meson-spifc.c index d700fa315223..e36aa94bbdae 100644 --- a/drivers/spi/spi-meson-spifc.c +++ b/drivers/spi/spi-meson-spifc.c @@ -345,6 +345,7 @@ static void meson_spifc_remove(struct platform_device *pdev) { pm_runtime_get_sync(&pdev->dev); pm_r...
fe221742e388bea3f5856b5d9b2cb0a037020ea4
Analyze and fix the following issue in the Linux kernel code: software node: allow passing reference args to PROPERTY_ENTRY_REF()
Problem Details: When dynamically creating software nodes and properties for subsequent use with software_node_register() current implementation of PROPERTY_ENTRY_REF() is not suitable because it creates a temporary instance of struct software_node_ref_args on stack which will later disappear, and software_node_registe...
```diff diff --git a/include/linux/property.h b/include/linux/property.h index e30ef23a9af3..14c304db4664 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -471,12 +471,18 @@ struct property_entry { #define PROPERTY_ENTRY_STRING(_name_, _val_) \ __PROPERTY_ENTRY_ELEMENT(_name_, str, STRING, ...
48c0162f647bb47e6084ffbc71b8f213f5e2f4f8
Analyze and fix the following issue in the Linux kernel code: nvmet-rdma: handle inline data with a nonzero offset
Problem Details: nvmet_rdma_use_inline_sg() maps the host-controlled inline data offset into the per-command inline scatterlist. The bounds check admits any offset with off + len <= inline_data_size, but the mapping still assumes the data begins in the first inline page: sg->offset = off; sg->length = min_t(int, le...
```diff diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c index ac26f4f774c4..ea1185b8267e 100644 --- a/drivers/nvme/target/rdma.c +++ b/drivers/nvme/target/rdma.c @@ -666,7 +666,8 @@ static void nvmet_rdma_release_rsp(struct nvmet_rdma_rsp *rsp) if (rsp->n_rdma) nvmet_rdma_rw_ctx_destroy(rsp); ...
5ac5ec84734fd338867055d4d7b650f18a023cb0
Analyze and fix the following issue in the Linux kernel code: spi: qcom-geni: Fix cs_change handling on the last transfer
Problem Details: TPM TIS SPI probe fails with: tpm_tis_spi: probe of spi11.0 failed with error -110 TPM TIS SPI sets cs_change=1 on single-transfer messages to keep CS asserted across the header, wait-state, and data phases of a transaction. CS deassertion between these phases violates the TCG SPI flow control spe...
```diff diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index d5fb0edc8e0c..23c6d3a37341 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -440,10 +440,15 @@ static int setup_gsi_xfer(struct spi_transfer *xfer, struct spi_geni_master *mas return ret; } - if (!xf...
1f7a5cfe44bf96bf54ce879339c896598db8e12e
Analyze and fix the following issue in the Linux kernel code: hwmon: (ina238) Add support for samples and update_interval
Problem Details: Expose INA238 ADC averaging count (AVG) and conversion timing (VBUSCT/VSHCT/VTCT) through chip-level hwmon attributes: chip/samples chip/update_interval Use per-chip conversion-time lookup tables so the same helpers work for INA228/INA237/INA238/INA700/INA780 and SQ52206. Cache ADC_CONFIG in driv...
```diff diff --git a/drivers/hwmon/ina238.c b/drivers/hwmon/ina238.c index c20dd164a6a6..179012680080 100644 --- a/drivers/hwmon/ina238.c +++ b/drivers/hwmon/ina238.c @@ -15,6 +15,7 @@ #include <linux/module.h> #include <linux/of.h> #include <linux/regmap.h> +#include <linux/util_macros.h> /* INA238 register defi...
e5248a7426030db1e126363f72afdb3b71339a5c
Analyze and fix the following issue in the Linux kernel code: svcrdma: wake sq waiters when the transport closes
Problem Details: Threads parked in svc_rdma_sq_wait() on sc_sq_ticket_wait or sc_send_wait can hang indefinitely in TASK_UNINTERRUPTIBLE state across transport teardown, pinning svc_xprt references and blocking svc_rdma_free(). The close path sets XPT_CLOSE before invoking xpo_detach and both wait_event predicates inc...
```diff diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h index 4ba39f07371d..5aadb47b3b0e 100644 --- a/include/linux/sunrpc/svc_rdma.h +++ b/include/linux/sunrpc/svc_rdma.h @@ -328,6 +328,7 @@ extern int svc_rdma_result_payload(struct svc_rqst *rqstp, unsigned int offset, unsigned ...
2090b05803faab8a9fa62fbff871007862cac1b7
Analyze and fix the following issue in the Linux kernel code: nfsd: reset write verifier on deferred writeback errors
Problem Details: nfsd_vfs_write() and nfsd_commit() both call filemap_check_wb_err() to detect deferred writeback errors, but neither rotates the server's write verifier (nn->writeverf) when this check fails. Every other durable-storage-failure path in these functions calls commit_reset_write_verifier() before returnin...
```diff diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index cba473969429..7e6468bdc723 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1513,8 +1513,10 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, nfsd_stats_io_write_add(nn, exp, *cnt); fsnotify_modify(file); host_err = filemap_check_wb_err(file->...
57aee7a35bb12753057c5b65d72d1f46c0e95b07
Analyze and fix the following issue in the Linux kernel code: nfsd: avoid leaking pre-allocated openowner on unconfirmed retry race
Problem Details: When find_or_alloc_open_stateowner() encounters an unconfirmed owner, it calls release_openowner() and sets oo = NULL. Control then falls through past the `if (oo)` guard -- which would have freed any pre-allocated `new` -- and unconditionally executes `new = alloc_stateowner(...)`. If `new` was alread...
```diff diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2cf021b202a6..a42f34842d77 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5276,6 +5276,7 @@ retry: /* Replace unconfirmed owners without checking for replay. */ release_openowner(oo); oo = NULL; + goto retry; } if (oo) { ...
d00e32f84ca1a77cb67a3fbf59f58dada95f5a21
Analyze and fix the following issue in the Linux kernel code: sunrpc: wait for in-flight TLS handshake callback when cancel loses race
Problem Details: When wait_for_completion_interruptible_timeout() in svc_tcp_handshake() returns 0 (timeout) or -ERESTARTSYS (signal) and tls_handshake_cancel() then returns false, handshake_complete() has won the cancellation race: it has set HANDSHAKE_F_REQ_COMPLETED and is about to invoke svc_tcp_handshake_done(), b...
```diff diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 6a75ac4565db..50e5e7f5b762 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -513,6 +513,10 @@ static void svc_tcp_handshake(struct svc_xprt *xprt) svc_xprt_put(xprt); goto out_close; } + /* Cancellation lost to handshake_c...
4f988f3a2808fb659f3880c282041ff067acad78
Analyze and fix the following issue in the Linux kernel code: sunrpc: pin svc_xprt across the asynchronous TLS handshake callback
Problem Details: svc_tcp_handshake() stores the raw svc_xprt pointer in tls_handshake_args.ta_data and submits the request through tls_server_hello_x509(). The handshake core takes only sock_hold(req->hr_sk); nothing references the embedding struct svc_sock that svc_tcp_handshake_done() reaches via container_of(). Two...
```diff diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index c434b6a6637d..6a75ac4565db 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -471,6 +471,7 @@ static void svc_tcp_handshake_done(void *data, int status, key_serial_t peerid) } clear_bit(XPT_HANDSHAKE, &xprt->xpt_flags); complete_...
0853ac544c590880d797b04daa33fcb72b6be0e1
Analyze and fix the following issue in the Linux kernel code: nfsd: fix posix_acl leak on SETACL decode failure
Problem Details: nfsaclsvc_decode_setaclargs() and nfs3svc_decode_setaclargs() each call nfs_stream_decode_acl() twice, first for NFS_ACL and then for NFS_DFACL. Each successful call transfers ownership of a freshly allocated posix_acl into argp->acl_access or argp->acl_default. If the first call succeeds but the sec...
```diff diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 0ac538c76180..76305b86c1a9 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -131,10 +131,7 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst *rqstp) resp->status = fh_getattr(fh, &resp->stat); out: - /* argp->acl_{access,default} may have...
24c975bbdd564d7d0ad90294bfa69729830345de
Analyze and fix the following issue in the Linux kernel code: nfsd: fix posix_acl leak and ignored error in nfsd4_create_file
Problem Details: nfsd4_create_file() has two bugs in its ACL handling: The return value of nfsd4_acl_to_attr() is silently discarded. When the NFSv4-to-POSIX ACL conversion fails (e.g., -EINVAL for unsupported ACE types), the file is created without any ACL and the client receives NFS4_OK. This violates RFC 7530/888...
```diff diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 14e329cfdfa6..8561540ab2db 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -253,7 +253,7 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, .na_iattr = iap, .na_seclabel = &open->op_label, }; - struct dentry *parent, *c...
e186fa1c057f5eccb22afb1e83e34c0627085868
Analyze and fix the following issue in the Linux kernel code: nfsd: check get_user() return when reading princhashlen
Problem Details: In __cld_pipe_inprogress_downcall(), the get_user() that reads princhashlen from the userspace cld_msg_v2 buffer does not check its return value. A failing copy leaves princhashlen with uninitialised stack contents, which are then used to drive memdup_user() and stored as princhash.len on the resulting...
```diff diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index b338473d6e52..6ea25a52d2f4 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -718,7 +718,8 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, return PTR_ERR(namecopy); name.data = namecopy; name.le...
0150459b05490b88b7e7378a31550a9e07b5517c
Analyze and fix the following issue in the Linux kernel code: nfsd: fix inverted cp_ttl check in async copy reaper
Problem Details: nfsd4_async_copy_reaper() is supposed to keep completed async copy state around for NFSD_COPY_INITIAL_TTL (10) laundromat ticks so that OFFLOAD_STATUS can report the result, then reap the state once the countdown expires. The TTL predicate is inverted: `if (--copy->cp_ttl)` is true while ticks remain ...
```diff diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 71bb2489e5a6..14e329cfdfa6 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1470,7 +1470,7 @@ void nfsd4_async_copy_reaper(struct nfsd_net *nn) list_for_each_safe(pos, next, &clp->async_copies) { copy = list_entry(pos, struct nfsd4_co...
a60f25a800846ab8e5a13f8a9d05111f2aee55a7
Analyze and fix the following issue in the Linux kernel code: nfsd: fix dead ACL conflict guard in nfsd4_create
Problem Details: nfsd4_create() steals create->cr_dpacl/cr_pacl into the local nfsd_attrs via the designated initializer, then immediately sets the source pointers to NULL. The subsequent conflict guard tests the already-nilled source fields, making it permanently dead code: if (create->cr_acl) { if (creat...
```diff diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index ab39ec885440..71bb2489e5a6 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -837,7 +837,7 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto out_aftermask; if (create->cr_acl) { - if (create->cr_dpacl ||...
9e18e83b8846a5c3fe13fc8a464b4865d33996c6
Analyze and fix the following issue in the Linux kernel code: NFSD: Fix SECINFO_NO_NAME decode error cleanup
Problem Details: nfsd4_decode_secinfo_no_name() currently initializes sin_exp after decoding sin_style. If the XDR stream is truncated, the decoder returns nfserr_bad_xdr before sin_exp is initialized. Since commit 3fdc54646234 ("NFSD: Reduce amount of struct nfsd4_compoundargs that needs clearing"), the inline iops a...
```diff diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 20355dc3f1d1..e17488a911f7 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2008,10 +2008,11 @@ static __be32 nfsd4_decode_secinfo_no_name(struct nfsd4_compoundargs *argp, union nfsd4_op_u *u) { struct nfsd4_secinfo_no_name *sin = &u...
18d216788bef06332ff8901670ecf1ed8f6eb614
Analyze and fix the following issue in the Linux kernel code: sunrpc: harden rq_procinfo lifecycle to prevent double-free
Problem Details: The svc_release_rqst() function executes the callback inside rqstp->rq_procinfo->pc_release. However, if a worker thread begins processing a new request and encounters an early error path (e.g., unsupported protocol, short frame, or bad auth) before a valid rq_procinfo is installed, a stale release hoo...
```diff diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 576fa42e7abf..ae9ec4bf34f7 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -1598,6 +1598,12 @@ static void svc_release_rqst(struct svc_rqst *rqstp) if (procp && procp->pc_release) procp->pc_release(rqstp); + + /* + * A subsequent svc_release...
18c1cc69886192e33536498289d26dba6894e3d5
Analyze and fix the following issue in the Linux kernel code: SUNRPC: Return an error from xdr_buf_to_bvec() on overflow
Problem Details: xdr_buf_to_bvec() returns a slot count even when the caller's bvec budget is exhausted partway through the xdr_buf. Callers feed that count into iov_iter_bvec() and continue as if the conversion had succeeded, silently sending or writing fewer bytes than the data length declares. For an NFS WRITE the s...
```diff diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index ba97e287c007..cba473969429 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1440,7 +1440,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, unsigned long exp_op_flags = 0; unsigned int pflags = current->flags; bool restore_flags = false; ...
42f5b80dda6b86e424054baf1475df686c403d5c
Analyze and fix the following issue in the Linux kernel code: SUNRPC: Bound-check xdr_buf_to_bvec() stores before writing
Problem Details: xdr_buf_to_bvec() writes a bio_vec into the caller's array before testing whether that slot is in range, and the head branch performs the store with no check at all. When the caller's budget is exactly used up, the next store lands one element past the end of the array. The overflow label returns count...
```diff diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 6bd588dfbfc0..8f52782d8a37 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -152,6 +152,8 @@ unsigned int xdr_buf_to_bvec(struct bio_vec *bvec, unsigned int bvec_size, unsigned int count = 0; if (head->iov_len) { + if (unlikely(count >= bvec_s...
30d55c8aabb261bc3f427d6b9aae7ef6206063f9
Analyze and fix the following issue in the Linux kernel code: nfsd: release layout stid on setlease failure
Problem Details: nfs4_alloc_stid() publishes the new stid into cl->cl_stateids via idr_alloc_cyclic() under cl_lock before returning to nfsd4_alloc_layout_stateid(). When nfsd4_layout_setlease() then fails, the error path frees the layout stateid directly with kmem_cache_free() without ever calling idr_remove(), leavin...
```diff diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c index c550b83f4432..f34320e4c2f4 100644 --- a/fs/nfsd/nfs4layouts.c +++ b/fs/nfsd/nfs4layouts.c @@ -253,10 +253,12 @@ nfsd4_alloc_layout_stateid(struct nfsd4_compound_state *cstate, ls->ls_file = find_any_file(fp); BUG_ON(!ls->ls_file); + ls->ls_...
6e4c62caecf792e8a15ad9bc7f371e57c17e3302
Analyze and fix the following issue in the Linux kernel code: lockd: Avoid hashing uninitialized bytes in nlm4svc_lookup_file()
Problem Details: file_hash() digests the first LOCKD_FH_HASH_SIZE bytes of nfs_fh.data when bucketing nlm_files[], independent of fh.size. Commit 3de744ee4e45 ("lockd: Use xdrgen XDR functions for the NLMv4 TEST procedure") set .pc_argzero to zero for the converted procedures and moved file-handle population into nlm4s...
```diff diff --git a/fs/lockd/lockd.h b/fs/lockd/lockd.h index 0be0dac59ea2..e418a50c4180 100644 --- a/fs/lockd/lockd.h +++ b/fs/lockd/lockd.h @@ -52,6 +52,14 @@ */ #define LOCKD_DFLT_TIMEO 10 +/* + * Number of leading bytes of nfs_fh.data that file_hash() + * digests when bucketing nlm_files[]. Sized for historic...
70a38f87bed7f0694fd07988b47b2db1e10d8df3
Analyze and fix the following issue in the Linux kernel code: lockd: Plug nlm_file refcount leak on cached nlm_do_fopen() failure
Problem Details: The cached-file path in nlm_lookup_file() reaches the found: label unconditionally, even when nlm_do_fopen() fails. At that label *result and file->f_count are updated before the error is returned. The wrappers nlm3svc_lookup_file() and nlm4svc_lookup_file() then bail out of their switch without copyin...
```diff diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index 0b81d8db0919..58b87ec52930 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -150,6 +150,8 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, mutex_lock(&file->f_mutex); nfserr = nlm_do_fopen(rqstp, file, mode); m...
f16a1513452edb532fec81e591c64c320866719c
Analyze and fix the following issue in the Linux kernel code: lockd: Plug nlm_file leak when nlm_do_fopen() fails
Problem Details: A client can repeatedly drive nlm_do_fopen() failures by presenting file handles that the underlying export rejects. After kzalloc_obj() succeeds in nlm_lookup_file(), the freshly allocated nlm_file is not yet inserted into nlm_files[]. The nlm_do_fopen() failure path jumps to out_unlock, which release...
```diff diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index e24bacea7e03..0b81d8db0919 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -166,7 +166,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, nfserr = nlm_do_fopen(rqstp, file, mode); if (nfserr) - goto out_unlock; + ...
516403d4d85607fdef3ca41d4a56b54e5566fa9a
Analyze and fix the following issue in the Linux kernel code: Revert "NFSD: Defer sub-object cleanup in export put callbacks"
Problem Details: This reverts commit 48db892356d6cb80f6942885545de4a6dd8d2a29. Commit 48db892356d6 ("NFSD: Defer sub-object cleanup in export put callbacks") moved path_put() and auth_domain_put() out of svc_export_put() and expkey_put() and behind queue_rcu_work() to close a claimed use-after-free in e_show() and c_s...
```diff diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index eb020054f9a3..a47c90f40422 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -39,30 +39,19 @@ * second map contains a reference to the entry in the first map. */ -static struct workqueue_struct *nfsd_export_wq; - #define EXPKEY_HASHBITS 8 #de...
a39f0ce0c9da20986b429e2db3e4e8739035d61b
Analyze and fix the following issue in the Linux kernel code: Revert "svcrdma: Use contiguous pages for RDMA Read sink buffers"
Problem Details: Jonathan Flynn reports that commit 18755b8c2f24 ("svcrdma: Use contiguous pages for RDMA Read sink buffers") regresses NFS/RDMA WRITE throughput from 73.9 GiB/s to 30.3 GiB/s on a 128-core single-NUMA-node server driving dual 400Gb/s links with 640 nfsd threads. Server CPU utilization rises from 8.5% t...
```diff diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c index cca8ec973de4..13554793b039 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_rw.c +++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c @@ -745,216 +745,6 @@ int svc_rdma_prepare_reply_chunk(struct svcxprt_rdma *rdma, return xdr->len; } -/*...
1b8d52328e0d37a51d1a4b11cf0f118a59dc4239
Analyze and fix the following issue in the Linux kernel code: lockd: Unify cast_status
Problem Details: cast_status folds internal lock-daemon sentinels into NLMv1/v3 wire status codes for the v3 reply path. Two variants have existed since the original kernel import: a strict allowlist under CONFIG_LOCKD_V4 and a sentinel-translation form for the !CONFIG_LOCKD_V4 build. The split was never grounded in ...
```diff diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index f62b0b39c5e9..4836887f11ef 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -203,7 +203,6 @@ nlm3svc_lookup_file(struct svc_rqst *rqstp, struct nlm_host *host, return nlm_granted; } -#ifdef CONFIG_LOCKD_V4 static inline __be32 cast_stat...
5c0d3a859ba6d66eb3b587fae1ad81ce518d9bd0
Analyze and fix the following issue in the Linux kernel code: lockd: Remove C macros that are no longer used
Problem Details: The conversion of all NLMv3 procedures to xdrgen-generated XDR functions is complete. The hand-rolled XDR size calculation macros (Ck, No, St, Rg) and the nlm_void structure definition served only the older implementations and are now unused. Also removes NLMDBG_FACILITY, which was set to the client d...
```diff diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index ef1ae701b43b..f62b0b39c5e9 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -24,8 +24,6 @@ #include "share.h" #include "nlm3xdr_gen.h" -#define NLMDBG_FACILITY NLMDBG_CLIENT - /* * Size of an NFSv2 file handle, in bytes, which is 32. ...
b3ef4d4688ebb78ed46d9c3adc6f2b82f1e05721
Analyze and fix the following issue in the Linux kernel code: lockd: Rename struct nlm_cookie to lockd_cookie
Problem Details: Machine-generated XDR types derived from the NLM specification use names that match the protocol. Internal lockd types with identical names cause compilation failures when machine-generated encoders replace hand-coded ones. Rename the internal struct nlm_cookie type to lockd_cookie to prevent such col...
```diff diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c index 2058733eacf8..6d881f9702a9 100644 --- a/fs/lockd/clnt4xdr.c +++ b/fs/lockd/clnt4xdr.c @@ -132,13 +132,13 @@ static int decode_netobj(struct xdr_stream *xdr, * netobj cookie; */ static void encode_cookie(struct xdr_stream *xdr, - const struct ...
b3d200166a35305ac77941845dcab99bb6badd76
Analyze and fix the following issue in the Linux kernel code: lockd: Do not monitor when looking up the LOCK_MSG callback host
Problem Details: A LOCK_MSG handler that fails to obtain a host returns rpc_system_err, which causes the dispatcher to send an RPC-level error rather than an NLM LOCK_RES denial. Before the xdrgen conversion, the outer host lookup was unmonitored, so an NSM upcall failure was reported back to the client through LOCK_RE...
```diff diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index 886b56317e5f..e3a6d69c1fa6 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -698,7 +698,7 @@ static __be32 nlm4svc_proc_lock_msg(struct svc_rqst *rqstp) struct nlm4_lockargs_wrapper *argp = rqstp->rq_argp; struct nlm_host *host; - h...
2175ca75882e346c9d8741a2196693d70f635340
Analyze and fix the following issue in the Linux kernel code: lockd: Translate nlm__int__deadlock in __nlm4svc_proc_lock_msg()
Problem Details: When nlmsvc_lock() detects a deadlock it returns the internal sentinel nlm__int__deadlock (30001), which version-specific handlers must translate to a wire-valid status before the reply is encoded. The xdrgen LOCK_MSG handler stores the sentinel unmodified in resp->status; the LOCK_RES callback then p...
```diff diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index 2bd71bc2b481..886b56317e5f 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -668,6 +668,8 @@ __nlm4svc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_res *resp) resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock, argp->...
5412049208e669925f7b08bbfabe3cd28a598c5b
Analyze and fix the following issue in the Linux kernel code: lockd: Correct kernel-doc status descriptions for NLMv4 GRANTED
Problem Details: NLM_GRANTED is a server-to-client callback; the local node responds in the role of the client. The kernel-doc for nlm4svc_proc_granted attributes NLM4_DENIED and NLM4_DENIED_GRACE_PERIOD to "the server", but per the Open Group XNFS specification the responder for this procedure is the client host, and ...
```diff diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index 41cab858de57..fc9ed4abb7ca 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -513,12 +513,12 @@ out: * nlm4_res NLMPROC4_GRANTED(nlm4_testargs) = 5; * * Permissible procedure status codes: - * %NLM4_GRANTED: The requested lock w...
5cca6056f2bae9be14566e0f7f6e351103a6aef3
Analyze and fix the following issue in the Linux kernel code: lockd: Stop warning on nlm__int__drop_reply in !V4 cast_status
Problem Details: cast_status folds internal lock-daemon sentinels into NLMv1/v3 wire status codes. The !CONFIG_LOCKD_V4 variant warns when an unrecognized status falls into the internal-sentinel range, gated by be32_to_cpu(status) >= 30000. nlm__int__drop_reply is defined as cpu_to_be32(30000), so it sits at the lowe...
```diff diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index c0a3487719e2..110e186802b6 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -49,7 +49,7 @@ static inline __be32 cast_status(__be32 status) status = nlm_lck_denied_nolocks; break; default: - if (be32_to_cpu(status) >= 30000) + if (be...
a9b9eb085884cd50de41b8ecb8d0fb9d3268cdfb
Analyze and fix the following issue in the Linux kernel code: SUNRPC: Switch MIC token generation to crypto/krb5
Problem Details: gss_krb5_get_mic_v2() currently computes the MIC checksum by driving a crypto_ahash directly, calling gss_krb5_checksum() with the message body and GSS token header. Replace this with a call to crypto_krb5_get_mic(), which performs the same keyed hash operation through the crypto/krb5 library. RFC 412...
```diff diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c index 31c2c86b873f..3a8e6710a51b 100644 --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c @@ -1103,3 +1103,85 @@ gss_krb5_aead_decrypt(struct krb5_ctx *kctx, u32 offset, u32 len, *t...
e9be933959b581effd426f93b86654f5fbf0c574
Analyze and fix the following issue in the Linux kernel code: SUNRPC: Add helpers to convert xdr_buf byte ranges to scatterlists
Problem Details: The crypto/krb5 library accepts data in scatterlist form, but the GSS-API layer presents RPC payloads as struct xdr_buf. Bridge that gap with a pair of helper functions: xdr_buf_to_sg() - populate a caller-supplied scatterlist array from a byte range xdr_buf_to_sg...
```diff diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index b639a6fafcbc..f82446993fde 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -140,6 +140,21 @@ int xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp); void xdr_free_bvec(struct xdr_buf *buf); unsigned int xdr_buf_...
86b9898920a6d02b4149f4fef9efd77b8aa3b9ca
Analyze and fix the following issue in the Linux kernel code: NFSD: Handle layout stid in nfsd4_drop_revoked_stid()
Problem Details: nfsd4_drop_revoked_stid() has no SC_TYPE_LAYOUT case, so when a client sends FREE_STATEID for an admin-revoked layout stid, the default branch releases cl_lock and returns without unhashing or releasing the stid. The stid remains in the IDR and on the per-client list until the client is destroyed. Re...
```diff diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 3c2eb03f78c6..ed20f6102117 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5056,6 +5056,7 @@ static void nfsd4_drop_revoked_stid(struct nfs4_stid *s) { struct nfs4_client *cl = s->sc_client; LIST_HEAD(reaplist); + struct nfs4_layou...
6ec91df8aff77e2e8fe3179c1f3fc15b43a40ba3
Analyze and fix the following issue in the Linux kernel code: iommu/dma: Do not try to iommu_map a 0 length region in swiotlb
Problem Details: iommu_dma_iova_link_swiotlb() processes a mapping that is unaligned in three parts, the head, middle and trailer. If the middle is empty because there are no aligned pages it will call down to iommu_map() with a 0 size which the iommupt implementation will fail as illegal. It then tries to do an error...
```diff diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 54d96e847f16..381b60d9e7ce 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1918,12 +1918,18 @@ static int iommu_dma_iova_link_swiotlb(struct device *dev, return 0; } + /* + * After removing the partial h...
2f884d371fafea137afea504d49ee4a7c8d7985b
Analyze and fix the following issue in the Linux kernel code: bpf: Allow LPM map access from sleepable BPF programs
Problem Details: trie_lookup_elem() annotates its rcu_dereference_check() walks with only rcu_read_lock_bh_held(). Because rcu_dereference_check(p, c) resolves to "c || rcu_read_lock_held()", this passes for XDP/NAPI and classic RCU readers but fails for sleepable BPF programs, which enter via __bpf_prog_enter_sleepab...
```diff diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c index 0f57608b385d..4d6f25db9ba1 100644 --- a/kernel/bpf/lpm_trie.c +++ b/kernel/bpf/lpm_trie.c @@ -246,7 +246,7 @@ static void *trie_lookup_elem(struct bpf_map *map, void *_key) /* Start walking the trie from the root node ... */ - for (node = rc...
5d563a5da8717629ae72f9eadf1e0e340bd1658b
Analyze and fix the following issue in the Linux kernel code: drm/vc4: fix krealloc() memory leak
Problem Details: Don't just overwrite the original pointer passed to krealloc() with its return value without checking latter: MEM = krealloc(MEM, SZ, GFP); If krealloc() returns NULL, that erases the pointer to the still allocated memory, hence leaks this memory. Instead, use a temporary variable, check it's not...
```diff diff --git a/drivers/gpu/drm/vc4/vc4_validate_shaders.c b/drivers/gpu/drm/vc4/vc4_validate_shaders.c index d48cf76983c0..66502a6a4a8e 100644 --- a/drivers/gpu/drm/vc4/vc4_validate_shaders.c +++ b/drivers/gpu/drm/vc4/vc4_validate_shaders.c @@ -290,15 +290,16 @@ static bool require_uniform_address_uniform(struct ...
68f4e480b089abae26fbab0c38c3df3cbac3d79d
Analyze and fix the following issue in the Linux kernel code: selftests/bpf: Avoid spurious spmc parallel selftest errors in libarena
Problem Details: The libarena parallel spmc selftest is nondeterministic by design. As a result it depends up to a point on the relative timing between the producer and consumer threads. This introduces the possibility for two kinds of spurious failures that this patch addresses. 1) Spurious timeouts. The test proceed...
```diff diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c index 981c845e2d15..f08f2a92e194 100644 --- a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c +++ b/tools/testing/selftests/bpf/l...
9aeba1351a22bd8c90515cd8e1462934d766932a
Analyze and fix the following issue in the Linux kernel code: regulator: mt6359: Fix vbbck default internal supply name
Problem Details: This issue was pointed out by Sashiko. vbbck is fed internally from vio18. For the MT6359, the default supply name was incorrectly set as "VIO18", instead of the supply's default "VIO18". In practice this still works, but it causes the regulator description copy and replace to always happen. For the M...
```diff diff --git a/drivers/regulator/mt6359-regulator.c b/drivers/regulator/mt6359-regulator.c index 7bda382ddd81..7c3a3ecb3641 100644 --- a/drivers/regulator/mt6359-regulator.c +++ b/drivers/regulator/mt6359-regulator.c @@ -693,7 +693,7 @@ static const struct mt6359_regulator_info mt6359_regulators[] = { MT635...
6eb287509dcf3508d2363934e82d9da7cf612f99
Analyze and fix the following issue in the Linux kernel code: RDMA/mlx5: Use strscpy() to copy strings into arrays
Problem Details: Replacing strcpy() with strscpy() ensures that overflow of the target buffer cannot happen. Link: https://patch.msgid.link/r/20260608095500.2567-2-david.laight.linux@gmail.com Signed-off-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
```diff diff --git a/drivers/infiniband/hw/mlx5/data_direct.c b/drivers/infiniband/hw/mlx5/data_direct.c index 8e89dbe40c23..d57484245c38 100644 --- a/drivers/infiniband/hw/mlx5/data_direct.c +++ b/drivers/infiniband/hw/mlx5/data_direct.c @@ -88,7 +88,7 @@ int mlx5_data_direct_ib_reg(struct mlx5_ib_dev *ibdev, char *vu...
bade9a3150d44ed20b8c6484c4c8a943b7289abb
Analyze and fix the following issue in the Linux kernel code: IB/mlx4: Fill in the access_flags if IB_MR_REREG_ACCESS is not specified
Problem Details: Sashiko noticed mlx4 was using whatever random access flags were provided when IB_MR_REREG_ACCESS is not used. Since IB_MR_REREG_TRANS needs access_flags it used the random ones which means it doesn't work sensibly if userspace provides only IB_MR_REREG_TRANS. Keep track of the current access_flag of ...
```diff diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h index 598954dd0613..2b6cc011b25d 100644 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h @@ -136,6 +136,7 @@ struct mlx4_ib_mr { dma_addr_t page_map; u32 npages; u32 max_pages...
a750ca72af72dde9744468fdca6eda0b698a1cfc
Analyze and fix the following issue in the Linux kernel code: ASoC: sma1307: Fix uevent string leaks in fault worker
Problem Details: sma1307_check_fault_worker() stores dynamically allocated uevent strings in envp[0]. Several fault conditions are checked in sequence, so a later fault can overwrite envp[0] before the final kfree() and leak the previous allocation. The same flow can leave an OT1 volume entry in envp[1] while envp[0] ...
```diff diff --git a/sound/soc/codecs/sma1307.c b/sound/soc/codecs/sma1307.c index 1de6bd1e4ee7..c52fe95b30c6 100644 --- a/sound/soc/codecs/sma1307.c +++ b/sound/soc/codecs/sma1307.c @@ -1592,6 +1592,7 @@ static void sma1307_check_fault_worker(struct work_struct *work) struct sma1307_priv *sma1307 = container_o...
fd46668d538993218eea19c6925c868ac0f2630c
Analyze and fix the following issue in the Linux kernel code: ASoC: SOF: ipc3-control: Fix heap overflow in bytes_ext put/get
Problem Details: The ipc_control_data buffer is allocated as kzalloc(max_size), where max_size covers the entire struct sof_ipc_ctrl_data including its flexible array payload. However, the bounds checks in bytes_ext_put and _bytes_ext_get compared user data lengths against max_size directly, ignoring that cdata->data s...
```diff diff --git a/sound/soc/sof/ipc3-control.c b/sound/soc/sof/ipc3-control.c index 1f5538bbc50f..d1697401b1da 100644 --- a/sound/soc/sof/ipc3-control.c +++ b/sound/soc/sof/ipc3-control.c @@ -398,9 +398,17 @@ static int sof_ipc3_bytes_ext_put(struct snd_sof_control *scontrol, } /* be->max is coming from topolo...
1f97760417b5faa60e9642fd0ed61eb17d0b1b39
Analyze and fix the following issue in the Linux kernel code: ASoC: SOF: ipc3-control: Fix TOCTOU in bytes_put and bytes_get
Problem Details: In sof_ipc3_bytes_put(), the size used for the memcpy is derived from the old data->size already in the buffer, not the incoming new data's size field. If the new data has a different size, the copy length is wrong: it may truncate valid data or copy stale bytes. Similarly, sof_ipc3_bytes_get() checks...
```diff diff --git a/sound/soc/sof/ipc3-control.c b/sound/soc/sof/ipc3-control.c index 4b907d8cf58a..1f5538bbc50f 100644 --- a/sound/soc/sof/ipc3-control.c +++ b/sound/soc/sof/ipc3-control.c @@ -315,10 +315,13 @@ static int sof_ipc3_bytes_get(struct snd_sof_control *scontrol, } /* be->max has been verified to be ...
390aa4c9339bb0ec0bc8d554e830faf93ca9d49e
Analyze and fix the following issue in the Linux kernel code: ASoC: SOF: ipc3-control: Validate size in snd_sof_update_control
Problem Details: In snd_sof_update_control(), firmware-provided cdata->num_elems is checked against local_cdata->data->size but never against the actual allocation size. If local_cdata->data->size was previously set to an inconsistent value, the memcpy could write past the allocated buffer. Add a bounds check to ensur...
```diff diff --git a/sound/soc/sof/ipc3-control.c b/sound/soc/sof/ipc3-control.c index 23b0ae3ad414..4b907d8cf58a 100644 --- a/sound/soc/sof/ipc3-control.c +++ b/sound/soc/sof/ipc3-control.c @@ -535,6 +535,15 @@ static void snd_sof_update_control(struct snd_sof_control *scontrol, return; } + /* Verify the siz...
8791977d7289f6e9d2b014f60a5455f053a7bc04
Analyze and fix the following issue in the Linux kernel code: ASoC: SOF: ipc3-control: Use overflow checks in control_update size calc
Problem Details: In sof_ipc3_control_update(), the expected_size calculation uses firmware-provided cdata->num_elems in arithmetic that could overflow on 32-bit platforms, wrapping to a small value. This would allow the cdata->rhdr.hdr.size comparison to pass with mismatched sizes, potentially leading to out-of-bounds ...
```diff diff --git a/sound/soc/sof/ipc3-control.c b/sound/soc/sof/ipc3-control.c index 2b1befad6d5c..23b0ae3ad414 100644 --- a/sound/soc/sof/ipc3-control.c +++ b/sound/soc/sof/ipc3-control.c @@ -626,16 +626,28 @@ static void sof_ipc3_control_update(struct snd_sof_dev *sdev, void *ipc_control_ return; } - expecte...
5bdfeccb7fbf6e000fc783cd8412732e67c1ad0c
Analyze and fix the following issue in the Linux kernel code: ASoC: SOF: ipc4-control: Validate notification payload size
Problem Details: Validate MODULE_NOTIFICATION payload length before reading bytes/channel data in control update handling. Fixes: 2a28b5240f2b ("ASoC: SOF: ipc4-control: Add support for generic bytes control") Cc: stable@vger.kernel.org Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Liam G...
```diff diff --git a/sound/soc/sof/ipc4-control.c b/sound/soc/sof/ipc4-control.c index aa31eed05730..8d86d32a16ca 100644 --- a/sound/soc/sof/ipc4-control.c +++ b/sound/soc/sof/ipc4-control.c @@ -875,6 +875,16 @@ static void sof_ipc4_control_update(struct snd_sof_dev *sdev, void *ipc_message) */ if (type == SND_S...
3ad673e7139cf214afd24321a829aad6575f4163
Analyze and fix the following issue in the Linux kernel code: ASoC: SOF: ipc4-control: Fix TOCTOU in sof_ipc4_bytes_put
Problem Details: In sof_ipc4_bytes_put(), the copy size is derived from the old data->size in the buffer rather than the incoming new data's size field from ucontrol. If the new data has a different size, the copy uses the wrong length: it may truncate valid data or copy stale bytes. Fix by validating and using the in...
```diff diff --git a/sound/soc/sof/ipc4-control.c b/sound/soc/sof/ipc4-control.c index 4ce821f96a91..aa31eed05730 100644 --- a/sound/soc/sof/ipc4-control.c +++ b/sound/soc/sof/ipc4-control.c @@ -554,6 +554,8 @@ static int sof_ipc4_bytes_put(struct snd_sof_control *scontrol, struct snd_soc_component *scomp = scontrol-...
7ecac01cf1c094a55c687572bbc874f75e15eb84
Analyze and fix the following issue in the Linux kernel code: s390/ap: Fix locking issue in SE bind and associate sysfs functions
Problem Details: Revisit and reorganize the locking and lock coverage of the ap->lock spinlock as used in the two sysfs functions se_bind_store() and se_associate_store(). A kernel run reported a possible deadlock situation, caused by holding the spinlock (ap->lock) while triggering a uevent. The fix rearranges the co...
```diff diff --git a/drivers/s390/crypto/ap_queue.c b/drivers/s390/crypto/ap_queue.c index 232b786d81d1..bc03b2101e39 100644 --- a/drivers/s390/crypto/ap_queue.c +++ b/drivers/s390/crypto/ap_queue.c @@ -961,34 +961,37 @@ static ssize_t se_bind_store(struct device *dev, __ap_flush_queue(aq); aq->rapq_fbit = 1; ...
6042c91df60e825625bc7d5c5c3b5a87b91d5805
Analyze and fix the following issue in the Linux kernel code: ASoC: SOF: amd: fix for ipc flags check
Problem Details: Firmware will set dsp_ack to 1 when firmware sends response for the IPC command issued by host. Similarly dsp_msg flag will be updated to 1. During ACP D0 entry, the value read from the sof_dsp_ack_write scratch flag can be uninitialized. A non-zero garbage value is treated as a pending DSP IPC ack be...
```diff diff --git a/sound/soc/sof/amd/acp-ipc.c b/sound/soc/sof/amd/acp-ipc.c index 3cd4674dd800..94025bc799ea 100644 --- a/sound/soc/sof/amd/acp-ipc.c +++ b/sound/soc/sof/amd/acp-ipc.c @@ -181,14 +181,14 @@ irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context) } dsp_msg = snd_sof_dsp_read(sdev, ACP_DSP_BAR...
26acdaa357cded33a37f575cd5f6bae1033b3a5d
Analyze and fix the following issue in the Linux kernel code: nvme: fix crash and memory leak during invalid cdev teardown
Problem Details: In the NVMe multipath code, if nvme_add_ns_head_cdev() fails during nvme_mpath_set_live(), the error is ignored. However, during teardown, nvme_remove_head() unconditionally calls nvme_cdev_del(). This teardown asymmetry leads to a kernel panic if the character device was never successfully initialized...
```diff diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index d37fc70fe48a..c6930e43cfea 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3894,7 +3894,8 @@ void nvme_cdev_del(struct cdev *cdev, struct device *cdev_device) put_device(cdev_device); } -int nvme_cdev_add(struct...
f994752b11273ded7ec6b49ae5c1d319eef21743
Analyze and fix the following issue in the Linux kernel code: net: ethtool: optionally skip rtnl_lock on IOCTL path
Problem Details: Convert the IOCTL path similarly to how we converted Netlink. The device lookup gets a little hairy. We could take rtnl_lock unconditionally and drop it before calling the driver (this would avoid the reference + liveness check). But I think being able to make progress even if rtnl is dead-locked is qu...
```diff diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 74c8109b0cf3..da29017c757f 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1375,6 +1375,7 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev, * within RTNL. * @rss_indir_user_size: Number of user prov...
38b7a274cf84af9b1f4b602b8e2741565b81947b
Analyze and fix the following issue in the Linux kernel code: igc: skip RX timestamp header for frame preemption verification
Problem Details: When RX hardware timestamping is enabled, a 16-byte inline timestamp header is added to the start of the packet buffer, causing FPE handshake verification to fail. Because an incorrect packet buffer is passed to igc_fpe_handle_mpacket(), the mem_is_zero() check inspects the timestamp metadata instead ...
```diff diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 8ac16808023c..c470d2354ce8 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2649,7 +2649,7 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vect...
7bd4355272de34c2e90e34b72c5613736d03c32b
Analyze and fix the following issue in the Linux kernel code: ixgbe: do not configure xps for XDP queues
Problem Details: netif_set_xps_queue() should not be called for an XDP Tx queue, since such queues are not netdev-exposed. On systems with number of CPUs >=64, on E610 adapter, netdev is configured with maximum number queue pairs being 63 (due to MSI-X assignment), but configuring XDP results in 64 XDP queues. So, dur...
```diff diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 2646ee6f295f..9ec250c26284 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -3958,7 +3958,8 @@ void ixgbe_configure_tx_ring(struct ixg...
d1e8f9fd6b98307bc8d2863c7baa465d8a5a43be
Analyze and fix the following issue in the Linux kernel code: idpf: add padding to PTP virtchnl structures
Problem Details: Add padding to virtchnl2 PTP structures to match the Control Plane expected message sizes: * virtchnl2_ptp_get_dev_clk_time: 8 -> 16 bytes * virtchnl2_ptp_set_dev_clk_time: 8 -> 16 bytes * virtchnl2_ptp_get_cross_time: 16 -> 24 bytes The FW expects the above sizes and PTP negotiation fails due to the ...
```diff diff --git a/drivers/net/ethernet/intel/idpf/virtchnl2.h b/drivers/net/ethernet/intel/idpf/virtchnl2.h index 02ae447cc24a..39fea65c075c 100644 --- a/drivers/net/ethernet/intel/idpf/virtchnl2.h +++ b/drivers/net/ethernet/intel/idpf/virtchnl2.h @@ -1572,13 +1572,15 @@ VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_ptp_...
f865a57896bd92d7662eb2818d8f48872e2cbbc7
Analyze and fix the following issue in the Linux kernel code: PCI: mediatek: Fix IRQ domain leak when port fails to enable
Problem Details: When mtk_pcie_enable_port() fails, mtk_pcie_port_free() removes the port from pcie->ports and frees the port structure. However, the IRQ domains set up earlier by mtk_pcie_init_irq_domain() are never freed. Fix this by refactoring mtk_pcie_irq_teardown() into a per-port helper, mtk_pcie_irq_teardown_p...
```diff diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index dcfc7408340f..f34d91e495bc 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -530,23 +530,27 @@ static void mtk_pcie_enable_msi(struct mtk_pcie_port *port) write...
c268f949e219f9e179558e836f457f6c5fbec416
Analyze and fix the following issue in the Linux kernel code: cxl: Fix CXL_HEADERLOG_SIZE to match RAS Capability size
Problem Details: The CXL r4.0 8.2.4.17.7 RAS Capability Structure has total length 0x58 bytes (CXL_RAS_CAPABILITY_LENGTH); the Header Log occupies the trailing 64 bytes at offset 0x18. CXL_HEADERLOG_SIZE was defined as SZ_512, eight times the actual on-device size. header_log_copy() reads CXL_HEADERLOG_SIZE_U32 (128)...
```diff diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c index 006c6ffc2f56..99fb00949c2f 100644 --- a/drivers/cxl/core/ras.c +++ b/drivers/cxl/core/ras.c @@ -8,6 +8,10 @@ #include <cxlpci.h> #include "trace.h" +/* Check that UCE header definition is maintained to keep ABI intact */ +static_assert(CXL_...
34b9a83c50660148bde01cde16451dbe78369749
Analyze and fix the following issue in the Linux kernel code: nvmet: fix refcount leak in nvmet_sq_create()
Problem Details: In nvmet_sq_create(), a reference on the ctrl is taken via kref_get_unless_zero() before calling nvmet_check_sqid(). If nvmet_check_sqid() fails, the function returns the error directly without releasing the reference, leading to a leak. Fix this by jumping to the "ctrl_put" label, which already perfo...
```diff diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 62dd59b9aa4f..4477c4d6b1ee 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -944,7 +944,7 @@ u16 nvmet_sq_create(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq, status = nvmet_check_sqid(ctrl, sqid, true); ...
4b0dc84b293984f75598881809fb2d3daf54a2a8
Analyze and fix the following issue in the Linux kernel code: PCI: meson: Add missing remove callback
Problem Details: meson_pcie_probe() powers on the PHY and registers the DesignWare host bridge with dw_pcie_host_init(), but the driver has no remove callback. On driver unbind or module unload, the driver core therefore proceeds to devres cleanup without first unregistering the host bridge or powering off the PHY. Ad...
```diff diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c index 8d495bcc3a41..225d887cd0a3 100644 --- a/drivers/pci/controller/dwc/pci-meson.c +++ b/drivers/pci/controller/dwc/pci-meson.c @@ -453,6 +453,14 @@ err_phy: return ret; } +static void meson_pcie_remove(struct pl...
b12341b98d5ac52f48ca1390e1e371aed81346c8
Analyze and fix the following issue in the Linux kernel code: PCI: meson: Propagate devm_add_action_or_reset() failure
Problem Details: meson_pcie_probe_clock() enables a clock and then registers a devres action to disable it during teardown. If devm_add_action_or_reset() fails, it runs the action immediately, disabling the clock. The return value is currently ignored, so on that failure path, meson_pcie_probe_clock() returns the disa...
```diff diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c index 0694084f612b..8d495bcc3a41 100644 --- a/drivers/pci/controller/dwc/pci-meson.c +++ b/drivers/pci/controller/dwc/pci-meson.c @@ -204,7 +204,9 @@ static inline struct clk *meson_pcie_probe_clock(struct device *dev, ...
ae2eb64bfd9762536f60b690840adcdf622cdcce
Analyze and fix the following issue in the Linux kernel code: btrfs: fix use-after-free after relocation failure with concurrent COW
Problem Details: If we get a failure during relocation, before we update all the extent buffers that have file extent items pointing to extents from the block group being relocated, we can trigger a user-after-free on the reloc control structure (fs_info->reloc_control) if we have a concurrent task that is COWing a sub...
```diff diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 97f99f830795..0a7d80da9c94 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2796,6 +2796,7 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info) mutex_init(&fs_info->unused_bg_unpin_mutex); mutex_init(&fs_info->reclaim_bgs_lock); m...
b0d27d43791b7a3057c3c4aedf9b4aa033d37c46
Analyze and fix the following issue in the Linux kernel code: btrfs: lzo: reject compressed segment that overflows the compressed input
Problem Details: lzo_decompress_bio() validates each on-disk segment length seg_len only against the workspace cbuf size, not against the compressed input size (compressed_len, the total folio bytes of the bio). A crafted extent can carry a segment whose seg_len passes the cbuf check but runs past the end of the bio, ...
```diff diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c index 2de18c7b563a..6e4aa22853ab 100644 --- a/fs/btrfs/lzo.c +++ b/fs/btrfs/lzo.c @@ -491,6 +491,17 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb) return -EIO; } + /* The segment must not extend beyond the compressed input. */ + ...
acf9ed3a6c0025f44434768b0dd76b0f61ce1171
Analyze and fix the following issue in the Linux kernel code: btrfs: retry faulting in the pages after a zero sized short direct write
Problem Details: Currently btrfs_direct_write() will not try to fault in the pages, but directly fall back to buffered writes, if the first page of the buffer can not be faulted in. For example, during generic/362 with nodatasum mount option, there is a write at file offset 0, length PAGE_SIZE, and the page is not fau...
```diff diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c index 412309825d6f..460326d34143 100644 --- a/fs/btrfs/direct-io.c +++ b/fs/btrfs/direct-io.c @@ -978,7 +978,7 @@ again: if (ret > 0) written = ret; - if (iov_iter_count(from) > 0 && (ret == -EFAULT || ret > 0)) { + if (iov_iter_count(from) > 0 && ...
ff66fe6662330226b3f486014c375538d91c44aa
Analyze and fix the following issue in the Linux kernel code: btrfs: fix incorrect buffered IO fallback for append direct writes
Problem Details: [BUG] With the previous bug of short direct writes fixed, test case generic/362 (*) still fails with the following error with nodatasum mount option: generic/362 0s ... - output mismatch (see /home/adam/xfstests/results//generic/362.out.bad) - output mismatch (see /home/adam/xfstests/results//gener...
```diff diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c index 88cb2e82a507..412309825d6f 100644 --- a/fs/btrfs/direct-io.c +++ b/fs/btrfs/direct-io.c @@ -15,10 +15,12 @@ struct btrfs_dio_data { ssize_t submitted; + loff_t old_isize; struct extent_changeset *data_reserved; struct btrfs_ordered_extent *...
66ff4d366e7eb4d31813d2acabf3af512ce03aa5
Analyze and fix the following issue in the Linux kernel code: btrfs: fix false IO failure after falling back to buffered write
Problem Details: [BUG] The test case generic/362 will fail with "nodatasum" mount option (*): MOUNT_OPTIONS -- -o nodatasum /dev/mapper/test-scratch1 /mnt/scratch generic/362 0s ... - output mismatch (see /home/adam/xfstests/results//generic/362.out.bad) --- tests/generic/362.out 2024-08-24 15:31:37.200000000 ...
```diff diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c index 57167d56dc72..88cb2e82a507 100644 --- a/fs/btrfs/direct-io.c +++ b/fs/btrfs/direct-io.c @@ -624,12 +624,23 @@ static int btrfs_dio_iomap_end(struct inode *inode, loff_t pos, loff_t length, if (submitted < length) { pos += submitted; length -...
c4e7778580d6a623ee2bb0b2790a8907095ce802
Analyze and fix the following issue in the Linux kernel code: btrfs: use verbose assertions in backref.c
Problem Details: While debugging a relocation issue I hit an assertion in backref.c but it was not super useful, since it could not tell what was the unexpected value that triggered the assertion. The stack trace was this: [583246.338097] assertion failed: !cache->nr_nodes, in fs/btrfs/backref.c:3158 [583246.33958...
```diff diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 0abcec0ceead..23c3eeb58dc1 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1256,7 +1256,7 @@ static bool lookup_backref_shared_cache(struct btrfs_backref_share_check_ctx *ct * realizing. We cache results only for extent buffers that lead...
7af30ba6ebc4ddde6dddb3545343a3d22128a588
Analyze and fix the following issue in the Linux kernel code: btrfs: print a message when a missing device re-appears
Problem Details: There is a bug report that fstrim crashed, and that crash is eventually pinned down to a missing device which re-appeared and screwed up callers that only checks BTRFS_DEV_STATE_MISSING, but not BTRFS_DEV_STATE_WRITEABLE nor device->bdev. A missing device re-appearing can be very tricky, as for now it...
```diff diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index f409f870a6bc..6eab4cc73ce4 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -963,6 +963,11 @@ static noinline struct btrfs_device *device_list_add(const char *path, devid, btrfs_dev_name(device), path, current->comm, t...
1b1937eb08f51319bf71575484cde2b8c517aedc
Analyze and fix the following issue in the Linux kernel code: btrfs: do not trim a device which is not writeable
Problem Details: [BUG] There is a bug report that btrfs/242 can randomly fail with the following NULL pointer dereference: run fstests btrfs/242 at 2026-06-01 10:25:08 BTRFS: device fsid d4d7f234-487c-4787-88e4-47a8b68c9874 devid 1 transid 9 /dev/sdc (8:32) scanned by mount (122609) BTRFS info (device sdc): firs...
```diff diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index b20f5a887a53..624d76e0ca01 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -6624,12 +6624,16 @@ static int btrfs_trim_free_extents_throttle(struct btrfs_device *device, *trimmed = 0; - /* Discard not supported = nothing...
dad845f192eb2684ec0c4cb72d184de4cef0808c
Analyze and fix the following issue in the Linux kernel code: btrfs: return real error after lookup failure in btrfs_ioctl_default_subvol()
Problem Details: If we fail to lookup the dir item, we are always returning -ENOENT but that may not be the reason for the failure, as btrfs_lookup_dir_item() can return many different errors, such as -EIO or -ENOMEM for example. Fix this by returning the real error, and also fixup the silly error message, including th...
```diff diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 561f4a90981b..9d47d16394fc 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2829,9 +2829,13 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) if (IS_ERR_OR_NULL(di)) { btrfs_release_path(path); btrfs_end_transac...
532085d00eb54c074bdeae648b194765239f4d11
Analyze and fix the following issue in the Linux kernel code: btrfs: fix deadlock cloning inline extent when using flushoncommit
Problem Details: In commit b48c980b6a7e ("btrfs: fix deadlock between reflink and transaction commit when using flushoncommit") a deadlock was fixed between reflinks and transaction commits when the fs is mounted with the flushoncommit option. This happened when we had to copy an inline extent's data to the destination...
```diff diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c index 0a4628b3007d..9a49d2ecb949 100644 --- a/fs/btrfs/reflink.c +++ b/fs/btrfs/reflink.c @@ -179,10 +179,12 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode, struct btrfs_drop_extents_args drop_args = { 0 }; int ret; struct btrfs_key ke...
5d40d064db81d8b4fad89079c916571f712cb1de
Analyze and fix the following issue in the Linux kernel code: btrfs: avoid unnecessary dev stats updates
Problem Details: [MINOR PROBLEM] When mounting a filesystem with a valid DEV_STATS item, we will always update the DEV_STATS again in the next transaction commit, even if there is no change the values. [CAUSE] During the mount, btrfs_device_init_dev_stats() will read out the on-disk DEV_STATS item for each device. The...
```diff diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 42615e6e7992..4cd9033320f7 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -8209,8 +8209,8 @@ static int btrfs_device_init_dev_stats(struct btrfs_device *device, for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++) { if (item_size >= (1 + ...
052273b63d8e8f63b55ae865f64167a156c5c5af
Analyze and fix the following issue in the Linux kernel code: btrfs: remove the dev stats item when removing a device
Problem Details: [MINOR BUG] The following script will cause DEV_STATS item to be left after the corresponding device is removed: # mkfs.btrfs -f $dev1 # mount $dev1 $mnt # btrfs dev add $dev2 $mnt # umount $mnt ## Without real errors, only at mount time btrfs will update ## dev->dev_stats_ccnt, thus we n...
```diff diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index bfbb63cf14f5..5733b964ab7e 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2397,6 +2397,12 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, return ret; } + ret = btrfs_remove_dev_stat_item(trans, device->devid); + if (unlikely(r...
15a12af71c3e8ad239b538038aa18d2ed6bee7d4
Analyze and fix the following issue in the Linux kernel code: btrfs: remove the dev stats item for replace target device
Problem Details: [MINOR PROBLEM] When a running dev-replace hits some error for the target device (devid 0), there will be a DEV_STATS with error records created at the next transaction commit. Unfortunately that item will never to be deleted. This means at the next dev-replace, if the replace is interrupted, then at...
```diff diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 8f8fa14886de..f34b812f7aab 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -1013,8 +1013,15 @@ error: /* write back the superblocks */ trans = btrfs_start_transaction(root, 0); - if (!IS_ERR(trans)) + if (!IS_ERR(trans)...
a6908f88c9da9778957a07ac568aa643124278a8
Analyze and fix the following issue in the Linux kernel code: btrfs: validate data reloc tree file extent item members
Problem Details: get_new_location() uses BUG_ON() to crash the kernel if the file extent item it looks up has any of offset, compression, encryption, or other_encoding set non-zero. The data reloc inode is only written by relocation's own paths and the four fields are always 0 in what the kernel writes: - insert_pre...
```diff diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 67af02e732d0..955e338dcfd8 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -813,6 +813,7 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr, u64 bytenr, u64 num_bytes) { struct btrfs_root *root =...
89c0dc3de7a73e8aba5e9bfef543eee047a3d0d2
Analyze and fix the following issue in the Linux kernel code: btrfs: annotate lockless read of defrag_bytes in should_nocow()
Problem Details: should_nocow() reads inode->defrag_bytes without holding inode->lock, while btrfs_set_delalloc_extent() and btrfs_clear_delalloc_extent() update it under that spinlock. This is a data race. The read is a quick check used to decide whether to fall back to COW for a NOCOW inode: if defrag_bytes is non-...
```diff diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9ce620085467..61b5594c4206 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2293,7 +2293,7 @@ error: static bool should_nocow(struct btrfs_inode *inode, u64 start, u64 end) { if (inode->flags & (BTRFS_INODE_NODATACOW | BTRFS_INODE_PREALLOC)) { -...
21a3533b99b8a53a026cc9f5041b10795c1f3ae8
Analyze and fix the following issue in the Linux kernel code: btrfs: zoned: always set max_active_zones for zoned devices
Problem Details: When a block device does not report a maximum number of open or active zones, currently assign BTRFS_DEFAULT_MAX_ACTIVE_ZONES (128) to the internal limit, if the device has more than BTRFS_DEFAULT_MAX_ACTIVE_ZONES zones. But if the device has less than BTRFS_DEFAULT_MAX_ACTIVE_ZONES the internal max_...
```diff diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index e3e141258a22..0d850e71af74 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -356,12 +356,33 @@ int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info) return ret; } +static int btrfs_get_max_active_zones(struct btrfs_device *devic...
0279bed34c22dd5ebff12e5af8ef940de93c5523
Analyze and fix the following issue in the Linux kernel code: Revert "btrfs: fix the file offset calculation inside btrfs_decompress_buf2page()"
Problem Details: It seems that af566bdaff54 was tested against a tree which did not contain commit 12851bd921d4 ("fs: Turn page_offset() into a wrapper around folio_pos()). Unfortunately it has a bug of its own; on 32-bit systems, shifting by PAGE_SHIFT will overflow on files larger than 4GiB. Since page_offset() is n...
```diff diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index cce85eebf2be..ffb6b52863a7 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -1170,22 +1170,6 @@ void __cold btrfs_exit_compress(void) bioset_exit(&btrfs_compressed_bioset); } -/* - * The bvec is a single page bvec from a ...
814c3b4ea357297c507158bceb07bcdc5fbe9808
Analyze and fix the following issue in the Linux kernel code: btrfs: zoned: fix deadlock waiting for ticket during data relocation
Problem Details: When performing data relocation on a zoned filesystem, BTRFS can deadlock in handle_reserve_tickets(). The relocation process is waiting on a space reservation ticket that can never be fulfilled, because the relocation itself is the operation responsible for freeing up that space. Fix this by introduc...
```diff diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c index 0970799d0aa4..4293a6383433 100644 --- a/fs/btrfs/delalloc-space.c +++ b/fs/btrfs/delalloc-space.c @@ -134,6 +134,8 @@ int btrfs_alloc_data_chunk_ondemand(const struct btrfs_inode *inode, u64 bytes) if (btrfs_is_free_space_inode(inode))...
52416a27aabc43eab3792fd0ca9f5dabeab58f31
Analyze and fix the following issue in the Linux kernel code: btrfs: zoned: don't account data relocation space-info in statfs free space
Problem Details: Don't account the free space in a data relocation space-info sub-group as usable free space in statfs. This is misleading as no user allocations can be made in this space-info sub-group. It is only a target for relocation. Fixes: f92ee31e031c ("btrfs: introduce btrfs_space_info sub-group") Reviewed-b...
```diff diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 9de67276a8ed..faa4777119ac 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1740,7 +1740,8 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) int mixed = 0; list_for_each_entry(found, &fs_info->space_info, list) { - if (fo...
82fd26090ebdbe6fa4b6039d059a7ea0a974cc36
Analyze and fix the following issue in the Linux kernel code: btrfs: zoned: always set data_relocation_bg
Problem Details: When searching for a data relocation block-group on mount, btrfs_zoned_reserve_data_reloc_bg() is looking for the first empty DATA block-group. But it first checks if the block-group is empty and if yes continues the search, and then checks if it is the first DATA block-group. There is actually no poi...
```diff diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 5f75cf0e14b9..e3e141258a22 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -2765,7 +2765,6 @@ void btrfs_zoned_reserve_data_reloc_bg(struct btrfs_fs_info *fs_info) struct btrfs_block_group *bg; struct list_head *bg_list; u64 alloc_flags; - boo...
5bdb8ec58b54b0e86672ba1991087611c7e52de5
Analyze and fix the following issue in the Linux kernel code: block: propagate in_flight to whole disk on partition I/O
Problem Details: Now when I/O is submitted to a partition, the per-CPU in_flight[] counter is incremented only on the partition's block_device, not on the underlying whole disk. This leads to a problem which can be shown by a fio test: lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS mydev 252:1 0 20G ...
```diff diff --git a/block/blk-core.c b/block/blk-core.c index b0f0a304ea0b..1c637db79e59 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1038,7 +1038,7 @@ unsigned long bdev_start_io_acct(struct block_device *bdev, enum req_op op, { part_stat_lock(); update_io_ticks(bdev, start_time, false); - part_stat_...
51a7c560cffdd3653ac2b930d01410569b23b23e
Analyze and fix the following issue in the Linux kernel code: PM: QoS: Fix misc device registration unwind
Problem Details: cpu_latency_qos_init() registers cpu_dma_latency first and, when CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP is enabled, registers cpu_wakeup_latency afterwards. The second registration overwrites the first return value. As a result, a failure to register cpu_dma_latency can be masked if the second registration s...
```diff diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 398b994b73aa..1944dbeb0d4c 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -519,18 +519,23 @@ static int __init cpu_latency_qos_init(void) int ret; ret = misc_register(&cpu_latency_qos_miscdev); - if (ret < 0) + if (ret < 0) { pr_er...
0fd835f5e9477ebea2439b8ada58f34e1b8cf25a
Analyze and fix the following issue in the Linux kernel code: virtio-blk: clamp zone report to the report buffer capacity
Problem Details: virtblk_report_zones() trusts the device-reported number of zones when walking the report buffer: nz = min_t(u64, virtio64_to_cpu(vblk->vdev, report->nr_zones), nr_zones); ... for (i = 0; i < nz && zone_idx < nr_zones; i++) { ret = virtblk_parse_zone(vblk, &report->zones[i], ...); The buffe...
```diff diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index b1c9a27fe00f..32bf3ba07a9d 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -689,6 +689,8 @@ static int virtblk_report_zones(struct gendisk *disk, sector_t sector, nz = min_t(u64, virtio64_to_cpu(vblk->vde...
9dda3f83ba677b9cc2613cecd9120123000ae50f
Analyze and fix the following issue in the Linux kernel code: PCI: imx6: Assert ref_clk_en after reference clock stabilizes on i.MX95
Problem Details: According to the PHY Databook Common Block Signals section, the ref_clk_en signal must remain de-asserted until the reference clock is running at the appropriate frequency. Once the clock is stable, ref_clk_en can be asserted. For lower power states where the reference clock to the PHY is disabled, ref...
```diff diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index b32748816ac8..cce78a7a1624 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -270,8 +270,6 @@ static int imx95_pcie_select_ref_clk_src(struct imx_pcie *imx_pcie) st...
0c26b1c34d12d4debfb5363cc0be6cdf68e87ba2
Analyze and fix the following issue in the Linux kernel code: PCI: imx6: Configure REF_USE_PAD before PHY reset for i.MX95
Problem Details: According to the i.MX95 PCIe PHY Databook, the ref_use_pad signal in the Common Block Signals section selects the reference clock source connected to the PHY pads. Per the specification, any change to this input must be followed by a PHY reset assertion to take effect. Move the REF_USE_PAD configurati...
```diff diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 773ab65b2afa..b32748816ac8 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -138,6 +138,7 @@ struct imx_pcie_drvdata { const u32 mode_off[IMX_PCIE_MAX_INSTANCES]; ...
fa75b7c85b0d2b6ab1c3ee0f06d35e2b98078c45
Analyze and fix the following issue in the Linux kernel code: bpf: Enforce write checks for BTF pointer helper access
Problem Details: check_mem_reg() verifies both read and write access for global subprogram memory arguments. When the caller register is PTR_TO_BTF_ID, check_helper_mem_access() currently forwards the access to check_ptr_to_btf_access() as BPF_READ regardless of the requested access type. This lets a BTF-backed kernel...
```diff diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index ed7ba0e6a9ce..cdff3e6eb96e 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -6777,7 +6777,7 @@ static int check_helper_mem_access(struct bpf_verifier_env *env, struct bpf_reg_ zero_size_allowed, access_type, meta); case PTR...
782fec4ab945e1f3b9f0ba383fc00c67641d9767
Analyze and fix the following issue in the Linux kernel code: KVM: s390: Add module parameter to fence 2G hugepages
Problem Details: Add the hpage_2g module parameter to KVM to allow enabling or disabling 2G hugepages in KVM. If hpage_2g is enabled but hpage is not enabled, print a message and disable hpage_2g. Opportunistically fix the comment for the hpage module parameter. Reviewed-by: Steffen Eiden <seiden@linux.ibm.com> Sign...
```diff diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index f6521f16532a..abc7941d7bb4 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -204,11 +204,16 @@ static int nested; module_param(nested, int, S_IRUGO); MODULE_PARM_DESC(nested, "Nested virtualization support"); -/* a...