From: Petr Pavlu <petr.pavlu@suse.com>
To: Jiacheng Yu <yujiacheng3@huawei.com>
Cc: samitolvanen@google.com, rusty@rustcorp.com.au,
hannes@cmpxchg.org, yosry@kernel.org, nphamcs@gmail.com,
liuyongqiang13@huawei.com, linux-modules@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] params: fix charp corruption on allocation failure
Date: Thu, 6 Aug 2026 16:51:32 +0200 [thread overview]
Message-ID: <cbe5e31c-1bf3-4b25-b85e-dc98bf0263f5@suse.com> (raw)
In-Reply-To: <b5d285a0-1e72-443e-aad0-dcac32d00d01@suse.com>
On 7/31/26 4:21 PM, Petr Pavlu wrote:
> On 7/29/26 2:32 PM, Jiacheng Yu wrote:
>> 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>
>
> Looks ok to me.
>
> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
>
> I'll give others more time to comment. If there are no further concerns,
> I plan to take this on modules-fixes.
I've queued the fix on modules-next for v7.3-rc1.
--
Thanks,
Petr
prev parent reply other threads:[~2026-08-06 14:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 8:55 [PATCH] params: fix charp corruption on allocation failure Jiacheng Yu
2026-07-28 10:46 ` Petr Pavlu
2026-07-28 12:22 ` Jiacheng Yu
2026-07-28 12:57 ` Petr Pavlu
2026-07-29 11:22 ` Jiacheng Yu
2026-07-29 12:32 ` [PATCH v2] " Jiacheng Yu
2026-07-31 14:21 ` Petr Pavlu
2026-08-06 14:51 ` Petr Pavlu [this message]
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=cbe5e31c-1bf3-4b25-b85e-dc98bf0263f5@suse.com \
--to=petr.pavlu@suse.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-modules@vger.kernel.org \
--cc=liuyongqiang13@huawei.com \
--cc=nphamcs@gmail.com \
--cc=rusty@rustcorp.com.au \
--cc=samitolvanen@google.com \
--cc=stable@vger.kernel.org \
--cc=yosry@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox