From nobody Mon Jun 8 09:49:30 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F7E6405C36 for ; Thu, 4 Jun 2026 11:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780571124; cv=none; b=l3bQYhFwpBfIdKDo8l8fGtNCcuhHdlRcX83KCTPs2Ifd0eDA3K4L4965muUK+SdbsBsBhsB/JDM9Om1VdsWiNXT+Hlrci40Pp9DEv1CovTNq4kVKq1mtzOQSWA8uQq0qC1Ijs4ce4PUrJbCoax4x2EfTLaQkRjFMc7fwhooCmOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780571124; c=relaxed/simple; bh=C92wi7j9PlBKhkeVJo2ng45cmm9eFGU8sPOk7F3JB84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L5acqm+236P8JSWOuOKJJrTKq39AFBQXB6zy0oQVJ23lNCH/ToebqVpXY3SNVRaxiV6YVyYJfQgam9OQN+/miphHJ/pwIgRBONd2SIMkeNK3FM9C79ctQqs9A0GyVl78JipQo5xh0Dq9ACCGp9lN/ekTeu86J4IEyX8oMyEJUuM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=T6KMsC+a; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="T6KMsC+a" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-490b3e03939so4752825e9.1 for ; Thu, 04 Jun 2026 04:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780571122; x=1781175922; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=niEZAFnY1RLD4JLGZab4EnFoTzKTvX/YTAN74sNfQw8=; b=T6KMsC+a0TrPZf4QJMlyoVXe0gi4auctgiU6LnhrhtHzmXtyW7uVyHxo0rkzxrxMLE CPHBTnEvu0H4coziLY5QiJCMci9gKZSpNN/TZPsDDyYLmfbg3weI/cZwW4W3jKQclozv Xw6pnrJhh3jckDcNVGrdBQ/zBib9orVqVT2gJD7ON34DQ7ng0kQmUjgn8+emwPJlLtoi Rs+fobLJlvtWwZogIhCCcL/QcSh5X/hCa9ngRD1CHv1w6BNJdl1TIvcnzz5v3FEdj8Bm 6o05ItZHHFD8tbhQzsy1znmffAS4ZJYq6ffhB259n5/8r5ygNN2DBVOaknT6YSQmY83t 5KNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780571122; x=1781175922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=niEZAFnY1RLD4JLGZab4EnFoTzKTvX/YTAN74sNfQw8=; b=edaxivlvTy3+YPcmZqpHa7Gid6MEeQTEgEwOtDe/zSvryFdxCMrefOhf96MnU4W8k9 zn6dTli9Q8HIl2gQFjKeRMkVlQodN/rMctJKA4SBPNwnHzEpCq0d7Fu3Pkd8hgZEwJMb txXqPZHiGIQbilyEaLfyt8zcGIJJlVsn06MMGjx64klHTo6Ld77qjZsP7tvuHSdugYGV em6waCBVBvZIXODTOLzG0dihN6/1OamLMTSsFzCK7GmiCpgTTZlSWNrb48mdFeES26qB M/AIf+fuFFMF8w0xDD+5BeDcFCULS/+Q4+LW/6vSzsrokxsAXTcsl+XYzU97tORt3m3F /N+w== X-Forwarded-Encrypted: i=1; AFNElJ+JYr+S0LUUziV+Il6/WcJTkMEsxqnAtmxMon0oq72HHNOo607LbFTbU2nF64+JF3r0Z8wVsA9Ma+PlTHQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yyrn498C2l8fmcYbxW5gfbn+B7kCKERoVfH2wEoLHvH/lEuQKQj bL2mrAF4pcYQR411o1kRW4iIX9y9EJF1hTpHQLa4Qq+fiYzEE3cPuzcyNzqmbOAyq3E= X-Gm-Gg: Acq92OFH5Glcj39JFDxhlsgMqd00+CxAGGInIJQuk1QyfgpryugMPdXNC63914dN1ta tuxt7amM0MUSj8Oz9GX7JscLVD8a8+oUO+g2nIaRJ1hNwIQlMUU1RFItRsjgTyuWf7phvtpq4hG NsWTttoDNmKtZSCx5IUcDqc0RKnj8QeYP3IcUpq5/WHaoMbz4me8k3+ZRfLJF4I9ZTz6Gc0sQJs QpsTAMibOv+8FEJVcSe/+Uh0UsfD1FBKy9szgMsTfUrMrn1S3qu11/6se5s7b4BNaHrAenoVQCr O8DvnIMw6CteptRXhGM8jPq5oRsIeKrX5IaNv2djWQJHRjdIJV8BGOjditzUzy4TAfgtid9dxJh 9ZWKLOyFaXypgIlOGGIIWnsldOP/HwPw702vzbz7jMqxJgTjrUJNa/sUVwx6DMi435L8ax+RNtX hVOGYM9uyv+zEyfOVJTaOin0hhPAswEG8IAwvKZ3u/gJy/WFoHAgDnOsYzxOlnbOHiBKxIxX5Gm RGy9TuEAqJGBx/6dZZh+mgBtJR2PdRiBHU= X-Received: by 2002:a05:600c:4453:b0:48f:e230:29f5 with SMTP id 5b1f17b1804b1-490bc50dcecmr46150515e9.16.1780571121990; Thu, 04 Jun 2026 04:05:21 -0700 (PDT) Received: from zovi.suse.cz (dynamic-2a00-1028-838d-271e-8e3b-4aff-fe4c-a100.ipv6.o2.cz. [2a00:1028:838d:271e:8e3b:4aff:fe4c:a100]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b7a273e3sm99648235e9.0.2026.06.04.04.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 04:05:21 -0700 (PDT) From: Petr Pavlu To: Chris Zankel , Max Filippov , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen Cc: Aaron Tomlin , Matthew Wood , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] xtensa/simdisk: Avoid referring to module::args Date: Thu, 4 Jun 2026 13:04:45 +0200 Message-ID: <20260604110455.1608038-2-petr.pavlu@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260604110455.1608038-1-petr.pavlu@suse.com> References: <20260604110455.1608038-1-petr.pavlu@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When simdisk support is built as a loadable module, simdisk_param_set_filename() receives a pointer into module::args and stores each filename pointer as is. In preparation for removing module::args, update the simdisk.filename parameter code to copy the provided string. This is somewhat complicated by the fact that simdisk support can also be built-in, in which case the parameters are parsed during early boot before slab is available. In that case, the command line itself is preserved for the lifetime of the kernel, so continue storing the incoming pointer directly. Signed-off-by: Petr Pavlu Reviewed-by: Max Filippov --- arch/xtensa/platforms/iss/simdisk.c | 38 +++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/is= s/simdisk.c index 7c7a2aa749f8..a2ddb49c269d 100644 --- a/arch/xtensa/platforms/iss/simdisk.c +++ b/arch/xtensa/platforms/iss/simdisk.c @@ -41,7 +41,7 @@ module_param(simdisk_count, int, S_IRUGO); MODULE_PARM_DESC(simdisk_count, "Number of simdisk units."); =20 static int n_files; -static const char *filename[MAX_SIMDISK_COUNT] =3D { +static char *filename[MAX_SIMDISK_COUNT] =3D { #ifdef CONFIG_SIMDISK0_FILENAME CONFIG_SIMDISK0_FILENAME, #ifdef CONFIG_SIMDISK1_FILENAME @@ -50,20 +50,48 @@ static const char *filename[MAX_SIMDISK_COUNT] =3D { #endif }; =20 +/* + * The simdisk code can be built either into the kernel or as a loadable m= odule. + * When built-in, CONFIG_SIMDISK{0,1}_FILENAME can be used to specify the + * initial simdisk filenames and additional filenames can be provided on t= he + * kernel command line. These arguments are parsed during early boot when = slab + * is not yet available, but the command line itself is preserved for the + * lifetime of the kernel, so the incoming pointer is stored directly. + * When built as a loadable module, each value is copied with kstrdup() an= d all + * allocated memory is freed in simdisk_param_free_filename() when the mod= ule is + * unloaded. + */ static int simdisk_param_set_filename(const char *val, const struct kernel_param *kp) { - if (n_files < ARRAY_SIZE(filename)) - filename[n_files++] =3D val; - else + char *str; + + if (n_files >=3D ARRAY_SIZE(filename)) return -EINVAL; + +#ifdef MODULE + str =3D kstrdup(val, GFP_KERNEL); + if (!str) + return -ENOMEM; +#else + str =3D (char *)val; +#endif + + filename[n_files++] =3D str; return 0; } =20 +static void simdisk_param_free_filename(void *arg) +{ + for (int i =3D 0; i < n_files; i++) + kfree(filename[i]); +} + static const struct kernel_param_ops simdisk_param_ops_filename =3D { .set =3D simdisk_param_set_filename, + .free =3D simdisk_param_free_filename, }; -module_param_cb(filename, &simdisk_param_ops_filename, &n_files, 0); +module_param_cb(filename, &simdisk_param_ops_filename, NULL, 0); MODULE_PARM_DESC(filename, "Backing storage filename."); =20 static int simdisk_major =3D SIMDISK_MAJOR; --=20 2.54.0 From nobody Mon Jun 8 09:49:30 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E119409136 for ; Thu, 4 Jun 2026 11:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780571125; cv=none; b=g95iuU/pVQsNqRxSP5AFTwMCCAVtklwLleEMdKso1dV3dK2QPIadN24fQ+Remo+kdo98u0gqg3dYgi6C3TN46VdW4VABOmlNLI6WDdy7B0aj2viq7e6Qrn4DXVbnQK6bOH2pF36yFc58ZyRJnULPPIJrcZL/6AwQybBeUXEP5d8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780571125; c=relaxed/simple; bh=1PM0LiHbncg6sP4lLs+mkgq0oy1h7NM8bUpsLT3heEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JTRl5bNWR/GH3cRJjwnjIncw9z6cGxTjkKJz8mg56q1OhCRoLhMyJ5+Hm00DKXAf+XQIXqiE11ZOEMxWTNRlIdbnRoUaGRr0z8r3RmCukLXzo6R5IB4qP2Gltz2MX+OlgaSFBmqUCheNaBAhtInOkYgyGX/Uix/FYlXqoBnUxm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=ZJLGhURz; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="ZJLGhURz" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490be29c1c5so7176695e9.2 for ; Thu, 04 Jun 2026 04:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780571123; x=1781175923; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mh9nrAO/RTKL701wijSOrz3qd8apdES1vQv9RY9vWk4=; b=ZJLGhURziZNZiTM+1U8AHlsibTkqivcmSQQFZBObl6mMv/n5o0ODtQqdlBnzyBIgrG +86zqfDTBf39063H9Sq+Hve+XUyChJUAWl2rsD6dNG+CIeuUE2q7gaKehfdS6HAfPkm8 PqZII57Bea4WlPcY+RcdPKsb4VSDu2hgIC+3m3LJijtTHq/YhNFmoMixpg6622D1MqYQ qDa8UcKPQAsvU5ukCfV9DOKCIn5ZjhS8cH8L/m7LpNNtYQA8FAGLQ91L+qHwadtf/Xr1 gA3pBsfvRxo2YbJqsDJLVycpV3/0YvGu6GUD3ntd+vKpq7dmxCvGdTE6vrezMIkgTzfQ Fneg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780571123; x=1781175923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mh9nrAO/RTKL701wijSOrz3qd8apdES1vQv9RY9vWk4=; b=hXznZ0Q3yEaSkzxw7qSarIooOUL9tJ5NoxeUl7XTYkQ9nZKCqAZz7pijqZHkCagQD2 QwfkfNPdZ7si8n0LL7G3t85/eBmOvTwg58ZALWANOBUj42LNk+FKRxFxI8Dr41evda+a K3IarJcWA3+IelbmGjlWRL0EqUF/KcYbi1d2x50acGVspbHiGDB2H95Wg9X/6JMB1mJN NDWMA5uKWy3R7uS+rRxWqZIdddDOKrHZz0roizwqybN9uyPZ1mkcS5ZkUOUCpAU3kK6N ec25djQxb36YpTXIu8N+t4Fs53eKuAaO4y9GCQNhEvb0tVtEiVtoGvEHmpjK59tU3YWc Lopg== X-Forwarded-Encrypted: i=1; AFNElJ94boSxOpEJOcOwRJQHRdkgenhjLFik5LjrbBvxdVuF96M9qa9ztWPqUytX6ta8RddOB/cP6MteFNEF5dw=@vger.kernel.org X-Gm-Message-State: AOJu0YxcIHONtFYIjuyIptjUpjnEKaydsW1Vcf4PJv2ixYNvoV8voDQP Lw/itfeYMCXR4x1UmLbtWpNTWG1ovuQen9UBPEOmoF/IwhxukP1K3417hIX1ztlG4Yc= X-Gm-Gg: Acq92OGUHuwKGIw8IZFtD7mhhnLk+yRAP/HIpqiqjbJv031lfeuuH6YA83BbzUYAPeo 99SDIWXzvNJR+ER6L7tOJBM16b7s10NzwHve1cPa2NDRnl50T4nEM090SSld/1RNH6EYbPKEsU6 zzTELT6+hS95TW6m3/9d81yaykvCwVEdsGBqlqg1Iblx8oQoyY0wLA39Ny0Kh2qoirzsudssCJL logGfK8SjVlQau2Krm44bM7FK8neYApzLD/50oFb0W9Rp1jNd61OL6DQGHS9s3tFf/vMr43L3WK Let92kGFTu/Gz6mQl/5bGvbLkr8g7UV2L6HdWTjglG689//cu/TiXT4tWDytGlYr7EglqkrZfJ4 qmBuwCYas3qI0eXbJj12nPsURoJmOcDPKHt3kS84f8TKwJNjXAlX6DeFLypod22lD8uPqz6Blz1 tDscpNvDGIfp5oqBoCYWhVgIkK8K4bgQSHgmlW8BOYMI2y9V/ikP9BA6LMth5vw9mJOxVG7+R0t V5va90tW/9qlibeHfep32n/OqQug1+bINc= X-Received: by 2002:a05:600c:458d:b0:490:469c:556b with SMTP id 5b1f17b1804b1-490b5e7577dmr126886585e9.12.1780571122853; Thu, 04 Jun 2026 04:05:22 -0700 (PDT) Received: from zovi.suse.cz (dynamic-2a00-1028-838d-271e-8e3b-4aff-fe4c-a100.ipv6.o2.cz. [2a00:1028:838d:271e:8e3b:4aff:fe4c:a100]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b7a273e3sm99648235e9.0.2026.06.04.04.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 04:05:22 -0700 (PDT) From: Petr Pavlu To: Chris Zankel , Max Filippov , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen Cc: Aaron Tomlin , Matthew Wood , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] module: Remove unnecessary module::args Date: Thu, 4 Jun 2026 13:04:46 +0200 Message-ID: <20260604110455.1608038-3-petr.pavlu@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260604110455.1608038-1-petr.pavlu@suse.com> References: <20260604110455.1608038-1-petr.pavlu@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Historically, various parameter-handling code kept pointers into module::args, most notably the charp support. However, in 2009, commit e180a6b7759a ("param: fix charp parameters set via sysfs") changed charp parameters to kstrdup() the input string as well. As a result, module::args now mostly wastes memory. The last users that still pointed into module::args have now been cleaned up, so remove this data. Signed-off-by: Petr Pavlu Reviewed-by: Aaron Tomlin --- include/linux/module.h | 4 ---- kernel/module/main.c | 15 ++++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 7566815fabbe..96cc98568eea 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -477,10 +477,6 @@ struct module { struct module_notes_attrs *notes_attrs; #endif =20 - /* The command line arguments (may be mangled). People like - keeping pointers to this stuff */ - char *args; - #ifdef CONFIG_SMP /* Per-cpu data. */ void __percpu *percpu; diff --git a/kernel/module/main.c b/kernel/module/main.c index 46dd8d25a605..528690ba160b 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -1458,7 +1458,6 @@ static void free_module(struct module *mod) =20 /* This may be empty, but that's OK */ module_arch_freeing_init(mod); - kfree(mod->args); percpu_modfree(mod); =20 free_mod_mem(mod); @@ -3425,7 +3424,7 @@ static int load_module(struct load_info *info, const = char __user *uargs, struct module *mod; bool module_allocated =3D false; long err =3D 0; - char *after_dashes; + char *args =3D NULL, *after_dashes; =20 /* * Do the signature check (if any) first. All that @@ -3523,9 +3522,9 @@ static int load_module(struct load_info *info, const = char __user *uargs, flush_module_icache(mod); =20 /* Now copy in args */ - mod->args =3D strndup_user(uargs, ~0UL >> 1); - if (IS_ERR(mod->args)) { - err =3D PTR_ERR(mod->args); + args =3D strndup_user(uargs, ~0UL >> 1); + if (IS_ERR(args)) { + err =3D PTR_ERR(args); goto free_arch_cleanup; } =20 @@ -3546,7 +3545,7 @@ static int load_module(struct load_info *info, const = char __user *uargs, mod->async_probe_requested =3D async_probe; =20 /* Module is ready to execute: parsing args may do that. */ - after_dashes =3D parse_args(mod->name, mod->args, mod->kp, mod->num_kp, + after_dashes =3D parse_args(mod->name, args, mod->kp, mod->num_kp, -32768, 32767, mod, unknown_module_param_cb); if (IS_ERR(after_dashes)) { @@ -3556,6 +3555,8 @@ static int load_module(struct load_info *info, const = char __user *uargs, pr_warn("%s: parameters '%s' after `--' ignored\n", mod->name, after_dashes); } + kfree(args); + args =3D NULL; =20 /* Link in to sysfs. */ err =3D mod_sysfs_setup(mod, info, mod->kp, mod->num_kp); @@ -3597,7 +3598,7 @@ static int load_module(struct load_info *info, const = char __user *uargs, ddebug_cleanup: ftrace_release_mod(mod); synchronize_rcu(); - kfree(mod->args); + kfree(args); free_arch_cleanup: module_arch_cleanup(mod); free_modinfo: --=20 2.54.0