All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Jiacheng Yu <yujiacheng3@huawei.com>,
	Petr Pavlu <petr.pavlu@suse.com>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6 0068/1674] params: fix charp corruption on allocation failure
Date: Sat, 17 Oct 2026 17:39:00 +0200	[thread overview]
Message-ID: <20261017160432.881180962@linuxfoundation.org> (raw)
In-Reply-To: <20261017160431.119607952@linuxfoundation.org>

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

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

From: Jiacheng Yu <yujiacheng3@huawei.com>

[ Upstream commit 3dfaae04243cde460d82dfc2a7dd0bb6664d20ae ]

param_set_charp() stores charp parameters in allocated memory after slab is
available, and releases the previous value when the parameter is updated.

The previous value is released before the replacement allocation succeeds.
If kmalloc_parameter() fails, the setter returns -ENOMEM with the parameter
left as NULL.

Failing zswap's compressor update before zswap is initialized can later
trigger:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:strcmp+0x10/0x30
  Call Trace:
    zswap_setup+0x3b1/0x490
    zswap_enabled_param_set+0x5b/0xa0
    param_attr_store+0x93/0xe0
    module_attr_store+0x1c/0x30
    kernfs_fop_write_iter+0x116/0x1f0

Allocate and copy the replacement first, then replace the parameter value
only after allocation succeeds.

Fixes: e180a6b7759a ("param: fix charp parameters set via sysfs")
Cc: stable@vger.kernel.org
Signed-off-by: Jiacheng Yu <yujiacheng3@huawei.com>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/params.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/params.c b/kernel/params.c
index f6d11831749be..12fb187ebf63e 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -265,6 +265,7 @@ EXPORT_SYMBOL_GPL(param_set_uint_minmax);
 
 int param_set_charp(const char *val, const struct kernel_param *kp)
 {
+	char *tmp;
 	size_t len, maxlen = 1024;
 
 	len = strnlen(val, maxlen + 1);
@@ -273,19 +274,20 @@ int param_set_charp(const char *val, const struct kernel_param *kp)
 		return -ENOSPC;
 	}
 
-	maybe_kfree_parameter(*(char **)kp->arg);
-
 	/*
 	 * This is a hack. We can't kmalloc() in early boot, and we
 	 * don't need to; this mangled commandline is preserved.
 	 */
 	if (slab_is_available()) {
-		*(char **)kp->arg = kmalloc_parameter(len + 1);
-		if (!*(char **)kp->arg)
+		tmp = kmalloc_parameter(len + 1);
+		if (!tmp)
 			return -ENOMEM;
-		strcpy(*(char **)kp->arg, val);
+		memcpy(tmp, val, len + 1);
 	} else
-		*(const char **)kp->arg = val;
+		tmp = (char *)val;
+
+	maybe_kfree_parameter(*(char **)kp->arg);
+	*(char **)kp->arg = tmp;
 
 	return 0;
 }
-- 
2.53.0




  parent reply	other threads:[~2026-10-17 16:54 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 15:37 [PATCH 6.6 0000/1674] 6.6.160-rc1 review Greg Kroah-Hartman
2026-10-17 15:37 ` [PATCH 6.6 0001/1674] dma-direct: simplify the use atomic pool logic in dma_direct_alloc Greg Kroah-Hartman
2026-10-17 15:37 ` [PATCH 6.6 0002/1674] dma-direct: return struct page from dma_direct_alloc_from_pool() Greg Kroah-Hartman
2026-10-17 15:37 ` [PATCH 6.6 0003/1674] xfrm: prevent policy_hthresh.work from racing with netns teardown Greg Kroah-Hartman
2026-10-17 15:37 ` [PATCH 6.6 0004/1674] ocfs2: Avoid touching renamed directory if parent does not change Greg Kroah-Hartman
2026-10-17 15:37 ` [PATCH 6.6 0005/1674] net/mlx5e: Fix netif state handling Greg Kroah-Hartman
2026-10-17 15:37 ` [PATCH 6.6 0006/1674] net: ena: Add validation for completion descriptors consistency Greg Kroah-Hartman
2026-10-17 15:37 ` [PATCH 6.6 0007/1674] x86/CPU/AMD: Clear virtualized VMLOAD/VMSAVE on Zen4 client Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0008/1674] apparmor: fix out-of-bounds write when null terminating a label vec Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0009/1674] xen/balloon: improve accuracy of initial balloon target for dom0 Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0010/1674] x86/xen: fix init of balloon stats again Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0011/1674] nfsd: fix nfsd_file leak on inter-server COPY setup failure Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0012/1674] ceph: properly decrypt filenames in vmalloc() buffers Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0013/1674] smb: client: fix OOB read/write from unvalidated DataOffset in coalesce_t2() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0014/1674] HID: sony: fix UAF of ghl_poke_timer / ghl_urb at driver unbind Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0015/1674] HID: universal-pidff: stop the device when force-feedback init fails Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0016/1674] ocfs2: validate dx_root extent list fields during block read Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0017/1674] ocfs2: validate directory-index entry counts when reading metadata Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0018/1674] wifi: rtl8xxxu: fix use-after-free from rx_urb_wq on stop Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0019/1674] udf: Fix data loss when converting inline inodes to out of line Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0020/1674] usb: storage: realtek_cr: fix use-after-free on disconnect Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0021/1674] staging: rtl8723bs: fix spacing around operators Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0022/1674] staging: rtl8723bs: fix OOB read in rtw_restruct_wmm_ie() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0023/1674] ftrace: Take trace_array reference before accessing its ftrace_ops Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0024/1674] nvme: add missing SRCU grace period in error path Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0025/1674] KVM: s390: Zero initialize data structures for inject_pfault_token Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0026/1674] scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0027/1674] scsi: qla2xxx: Fix queue teardown NULL dma_free and bitmap locking Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0028/1674] scsi: qla2xxx: Fix use-after-free of qpair work on queue teardown Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0029/1674] scsi: qla2xxx: Validate BSG request_len before reading vendor_cmd[] Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0030/1674] f2fs: validate MOVE_RANGE destination size Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0031/1674] f2fs: embed f2fs_gc_kthread in f2fs_sb_info Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0032/1674] tracing: Fix memory corruption from a "STACKTRACE" histogram key Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0033/1674] Bluetooth: btqcomsmd: Convert to platform remove callback returning void Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0034/1674] Bluetooth: btqcomsmd: destroy RPMsg endpoints before freeing hci_dev Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0035/1674] genetlink: pin family module during policy dump Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0036/1674] io_uring/rw: end write accounting from ->ki_complete Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0037/1674] net: bridge: use option bits for CFM/MRP frame handlers Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0038/1674] ieee802154: cc2520: fix FIFOP work use-after-free Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0039/1674] landlock: Fix use-after-free of the sources parent directory Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0040/1674] ALSA: usb-audio: Optimize the copy of packet sizes for implicit fb handling Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0041/1674] ALSA: usb-audio: Clamp implicit feedback packet count to URB capacity Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0042/1674] wifi: libipw: reject TKIP frames without a full MIC Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0043/1674] smb: mark the new channel addition log as informational log with cifs_info Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0044/1674] smb: client: fix use-after-free of iface in cifs_try_adding_channels() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0045/1674] smb: client: fix OOB struct field reads in move_smb2_ea_to_cifs() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0046/1674] vlan: require the MAC header to be present in __vlan_insert_inner_tag() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0047/1674] pinctrl: sunxi: keep a shadow copy of the data register output latches Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0048/1674] drm/i915/hdcp: Add encoder check in intel_hdcp_get_capability Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0049/1674] drm/i915/hdcp: Add encoder check in hdcp2_get_capability Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0050/1674] kvm: s390: Reject memory region operations for ucontrol VMs Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0051/1674] media: av7110: fix a spectre vulnerability Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0052/1674] ethtool: fail closed if we cant get max channel used in indirection tables Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0053/1674] KEYS: trusted: Fix TPM teardown ordering Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0054/1674] zram: fixup read_block_state() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0055/1674] zram: fix out-of-bounds access in read_block_state() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0056/1674] nfsd: size fh_verify server sockaddr slot by xpt_locallen Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0057/1674] nfsd: check nfsd4_acl_to_attr() return value in nfsd4_create() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0058/1674] nfsd: fix clock domain mismatch in clients_still_reclaiming() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0059/1674] coresight: etm3x: Fix cntr_val_show() to match cntr_val_store() behavior Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0060/1674] cpufreq: apple-soc: Fix OPP table cleanup Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0061/1674] ACPI: TAD: Rearrange RT data validation checking Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0062/1674] ACPI: TAD: Split three functions to untangle runtime PM handling Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0063/1674] ACPI: TAD: Add locking around AML evaluations Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0064/1674] params: Do not go over the limit when getting the string length Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0065/1674] params: Use size_add() for kmalloc() Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0066/1674] params: Sort headers Greg Kroah-Hartman
2026-10-17 15:38 ` [PATCH 6.6 0067/1674] params: Fix multi-line comment style Greg Kroah-Hartman
2026-10-17 15:39 ` Greg Kroah-Hartman [this message]
2026-10-17 15:39 ` [PATCH 6.6 0069/1674] ASoC: codecs: aw88261: reduce log spam Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0070/1674] ASoC: codecs: aw88261: only check PLL and clock state at power-up Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0071/1674] dmaengine: Add devm_dma_request_chan() Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0072/1674] i2c: mxs: fix DMA channel leak on probe error Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0073/1674] lockd: fix swapped arguments in nlmsvc_match_ip() Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0074/1674] mmc: via-sdmmc: cancel card-detect work on remove Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0075/1674] platform/x86: ISST: Validate parameter for core power state Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0076/1674] platform/x86: ISST: Validate max level for set feature Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0077/1674] power: supply: qcom_battmgr: fix use-after-free Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0078/1674] hwrng: stm32 - Fix runtime PM cleanup on registration failure Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0079/1674] i3c: master: Do not treat master device as a duplicate target Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0080/1674] i3c: master: Fix use-after-free of master->this Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0081/1674] wifi: mt76: mt7996: bound the device EEPROM address before the EFUSE copy Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0082/1674] usb: gadget: f_mass_storage: fix null pointer dereference in fsg_common_set_num_buffers() Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0083/1674] staging: sm750fb: fix mono image source stride mismatch in lynxfb_ops_imageblit() Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0084/1674] tracing/probes: Fix anon_stack check for unnamed bitfields in btf_find_struct_member Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0085/1674] ftrace: Synchronize the initialization of ftrace_ops Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0086/1674] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0087/1674] nvme-fabrics: fix DHCHAP secret leak on parse failure Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0088/1674] clk: qcom: Fix test_ctl_hi field for DEFAULT_EVO PLLs Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0089/1674] mm/mremap: reset unfaulted VMA page offset for MREMAP_DONTUNMAP Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0090/1674] media: platform: mtk-mdp3: fix NULL deref on failed SCP lookup Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0091/1674] media: rkvdec: Propagate platform_get_irq() errors Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0092/1674] scsi: qla2xxx: Null out freed pointers in qla2x00_mem_alloc() error path Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0093/1674] scsi: qla2xxx: Fix 64G link speed reporting in get_data_rate Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0094/1674] scsi: qla2xxx: Use ring-slot helpers in __qla2x00_alloc_iocbs Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0095/1674] scsi: qla2xxx: Use memset_io() to clear QLAFX00 request ring slot Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0096/1674] scsi: qla2xxx: Fix soft lockup polling continuation IOCB signature Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0097/1674] f2fs: limit recovery filename logging to stored length Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0098/1674] f2fs: fix dentry folio leak in find_in_level Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0099/1674] drm/sysfb: simpledrm: Improve panel-size validation Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0100/1674] drm/sysfb: simpledrm: Improve stride validation Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0101/1674] drm/sysfb: ofdrm: Fix integer overflow in fb_size calculation Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0102/1674] drm/sysfb: ofdrm: Fix is_avivo() constant comparison bug Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0103/1674] ipmr: account multicast table and route memory Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0104/1674] virtio-mmio: Remove virtqueue list from mmio device Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0105/1674] virtio_mmio: disable IRQ wake before free_irq Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0106/1674] net/sched: act_api: release all action references on NEWACTION failure Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0107/1674] erofs: preserve LZMA decoders on resize failure Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0108/1674] erofs: add sysfs feature entry for xattr prefixes Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0109/1674] mptcp: pm: drop match in userspace_pm_append_new_local_addr Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0110/1674] sock: add sock_kmemdup helper Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0111/1674] mptcp: use sock_kmemdup for address entry Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0112/1674] mptcp: pm: userspace: fix address ID overflow Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0113/1674] mptcp: pm: reset retrans_time when ADD_ADDR entry is reused Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0115/1674] smb: client: fix cifsFileInfo reference leak in deferred close Greg Kroah-Hartman
2026-10-17 15:39 ` [PATCH 6.6 0124/1674] drm/amdgpu: Fix acpi device leak in amdgpu_acpi_enumerate_xcc() Greg Kroah-Hartman

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20261017160432.881180962@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=patches@lists.linux.dev \
    --cc=petr.pavlu@suse.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yujiacheng3@huawei.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.