From mboxrd@z Thu Jan 1 00:00:00 1970 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 91FC83859CC for ; Mon, 25 May 2026 13:27:18 +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=1779715641; cv=none; b=MUymlqsqQihPMerJafmN09FXw+NLrwK4SSqu3iMhbcvyJ4A+AGSsJqau63FpaazTpFyJsEfVDuJHvVNTur2Op/thBK70ZmasHJ1dlryf44x+znfdErdzYhJFYev6ytS/m113IyPlvIHnNMKElln/qmcVXOLrJaKySz7wwjDiL44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779715641; c=relaxed/simple; bh=C94U0R51pf0+NwK55ZN6EU/K9cssUS28krlgs1NAXvo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tSQPE9cBpZ+Y7oaAuUAOE+zD9ROydr1d8P2bfM4h8JTNkJCM0ysXIQsCe4DgNhrj9eL6V9ghbmgKq+XK5LfAEcgBPEaeCxQvmtYEsGzJrjxbHcZPuwJ+6Y7JqRY41f1j7ChZTSS4LPibiSsfcH5IMio0aESM6vfs+VS7/CzrgKc= 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=YiMsSREI; 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="YiMsSREI" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-49050bfe053so23453975e9.3 for ; Mon, 25 May 2026 06:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1779715637; x=1780320437; darn=lists.linux.dev; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Ij+l12dR+ISDUAaA9eJOw0SDQ47xwS4UQDqlRXMB76c=; b=YiMsSREIYiDwWVwS5+FV1m5T1GU+lM54vLzHoE0tcgiHMXruqZKiEfTWpmOEEtpj/W 1DQsyeJ0GYBOO8hWocKox5b00FE1mLIUm7egrzUpWvMwAarohupq8cH1+EFmvSULMVjZ r1BVobG/TSzsPzVI4pbjwbAc1F+1yT9bVl768EuL4RVRgi8MJAiMa7X0WjRXPgKgjArR KnuyYSYZXWmxsm38zXktrcHG7kE42uh6WMJD42QSohzs9OJ2xWTW7wHOGyFU3No+7NkA ERhBfVpvHLK/jSdGoiegAdjcoimfTo5bkL9CylLjNH8B/ggDAPesAlrwisyhc0S5QFhV NNRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779715637; x=1780320437; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ij+l12dR+ISDUAaA9eJOw0SDQ47xwS4UQDqlRXMB76c=; b=LWnkG0en6WOrU9Nnmd6jiseUDcvHlQloW31edWqAvDMSuYfUjd/lk4DRex9aL+guhI L3766byyLqxNnw6U2aoPpOqyANOIBPHmj9TC4Sr8J32zBHJ9iXK03Twrwj8VYLFkuVvE YT1m6ZLmv+oUSSkUtoBfOgN29oXhTzfY3nAA/1ca3cbOJYQNxXPsaAThR+ir7xEp/8SR JPfbZQ/cSjt0PAU0H8/vnwXjkgA9iumhOrDnAT0LgfbUZwaXfPVbaRDeaurf8ndnHU+F yPxPcG6P56rjaqRitejqOGuy/CuboRl0ra6nBo9nvgNiEFrkzE67K7WIQuUl0gjIlGBN JIhg== X-Forwarded-Encrypted: i=1; AFNElJ/P9AEwv3tGbSn/b31hoUskV3umVnhRj2Ieq2dN5cJNJTsgmbGAr1Bh/Cdit5D3D3kNNVBltIYHjagdpzK7pQ==@lists.linux.dev X-Gm-Message-State: AOJu0YyTZTRA7JMM2yzAB07ekzACOwhmf7d7s0u/4fIFfR1EdVSxqirG D5DhUqmmM9uAfPAtrVf7/V5uxBW0zhgEbkYbriGtMlNrVxyJkdaIvJx37oyLw/dA5TE= X-Gm-Gg: Acq92OG1I7050dTexfX7Zo/6ln0Bmuadk6Loj8nEKr5EiiS16CmnoYRPwlOtIpspP0e tfTyJuCaJtnMGWxmo8e7t4H273nJuqpGcHUYLQFBjb37oMgqDLOpbbPTpWI7QiHypTeCLG0C1WG Ia0k7WW/H/NMIgzux7iTMx4FHnpmjJNTjduMJSGVDypQPAQocA2ScTyG/Hym5BXdacu+CJJqWsO F7eQi/zm71Uul+y6+y2MmqyeHp/UNolQ4U/6yWXKrXarIB9f8dx1VuuKAgVp+QLSeWESA/aijfm UFoT2ba02hAIk4Jy96W1avL2w07/gtCrzBO6ZdLy5xlgCAEEC7IPg3VDgLK5yd0QJ3shU81N8KZ ow3SGg6A8qWaBsnSBOsI7WW7KaLCUGsx3vYRQkD6B92KXHZS2Z6wmUPL1YIrM51cm9bCVf6iei3 vGoJeP6QTg168NkBShSDoU1s6rXVlqMvWw1EfL8PnGxasBRQfZm2kKZqzS1R/HqTAxus18PO2mc TWJy2MWBFZXM9bpH7Vs6AFW7AA5HAwzh7s7dVNwTz4oXgbsjZYoRTKOQMetZ739DYOL7TSA9fsH oXEb X-Received: by 2002:a05:600c:3b02:b0:48f:e1ac:c94f with SMTP id 5b1f17b1804b1-490424b3938mr247672645e9.10.1779715636631; Mon, 25 May 2026 06:27:16 -0700 (PDT) Received: from ?IPV6:2a00:1028:838d:271e:8e3b:4aff:fe4c:a100? (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-490454b1ab3sm284841905e9.14.2026.05.25.06.27.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 May 2026 06:27:16 -0700 (PDT) Message-ID: <1c21f66f-0d0f-4a8b-835b-23408242cff1@suse.com> Date: Mon, 25 May 2026 15:27:13 +0200 Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 03/11] moduleparam: Add DEFINE_KERNEL_PARAM_OPS macro family To: Kees Cook Cc: Luis Chamberlain , Pengpeng Hou , Richard Weinberger , Anton Ivanov , Johannes Berg , "Rafael J. Wysocki" , Len Brown , Corey Minyard , Gabriel Somlo , "Michael S. Tsirkin" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Bart Van Assche , Jason Gunthorpe , Leon Romanovsky , Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Bjorn Helgaas , Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Jason Wang , Xuan Zhuo , =?UTF-8?Q?Eugenio_P=C3=A9rez?= , Jason Baron , Jim Cromie , Tiwei Bie , Benjamin Berg , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , "David E. Box" , "Maciej W. Rozycki" , Srinivas Pandruvada , Peter Zijlstra , Heiko Carstens , Vasily Gorbik , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Vinod Koul , Frank Li , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Alexander Potapenko , Marco Elver , Dmitry Vyukov , Andrew Morton , John Johansen , Paul Moore , James Morris , "Serge E. Hallyn" , Andy Shevchenko , Georgia Garcia , kvm@vger.kernel.org, dmaengine@vger.kernel.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, linux-um@lists.infradead.org, linux-acpi@vger.kernel.org, openipmi-developer@lists.sourceforge.net, qemu-devel@nongnu.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20260521133315.work.845-kees@kernel.org> <20260521133326.2465264-3-kees@kernel.org> Content-Language: en-US From: Petr Pavlu In-Reply-To: <20260521133326.2465264-3-kees@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/21/26 3:33 PM, Kees Cook wrote: > Add macros that define a struct kernel_param_ops initializer through a > macro so the underlying field layout can evolve without touching every > call site. Three variants cover the three cases: > > DEFINE_KERNEL_PARAM_OPS(name, set, get) // basic > DEFINE_KERNEL_PARAM_OPS_NOARG(name, set, get) // set KERNEL_PARAM_OPS_FL_NOARG > DEFINE_KERNEL_PARAM_OPS_FREE(name, set, get, free) // also set .free > > Callers prefix their own visibility qualifiers, e.g.: > > static DEFINE_KERNEL_PARAM_OPS(my_ops, my_set, my_get); > > Also update module_param_call() and STANDARD_PARAM_DEF() to use > DEFINE_KERNEL_PARAM_OPS internally so the generated ops table will go > through the same macro as everything else. > > Subsequent commits convert all open-coded struct kernel_param_ops > definitions to use these macros, in preparation for migrating to a > seq_buf .get API. > > Signed-off-by: Kees Cook > --- > include/linux/moduleparam.h | 36 ++++++++++++++++++++++++++++++++++-- > kernel/params.c | 6 ++---- > 2 files changed, 36 insertions(+), 6 deletions(-) > > diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h > index 075f28585074..26bf45b36d02 100644 > --- a/include/linux/moduleparam.h > +++ b/include/linux/moduleparam.h > @@ -68,6 +68,39 @@ struct kernel_param_ops { > void (*free)(void *arg); > }; > > +/* > + * Define a const struct kernel_param_ops initializer. Callers prefix with > + * any required visibility qualifiers (typically "static"): > + * > + * static DEFINE_KERNEL_PARAM_OPS(my_ops, my_set, my_get); > + * > + * Routing the @_set and @_get function pointers through the macro > + * (rather than naming the struct fields at every call site) lets the > + * field layout change in one place when callbacks are migrated to a > + * new signature. > + */ Nit: The newly introduced DEFINE_KERNEL_PARAM_OPS*() macros remain in place at the end of the series after the migration is complete and this comment is removed in patch 7. It would be helpful to describe in the commit message why these macros are generally preferable to defining kernel_param_ops instances directly. I assume the motivation is that the structure is simple enough and using macros then makes defining kernel_param_ops instances a bit more concise. A minor disadvantage is that some analysis tools, such as ctags, may no longer see the generated definition, but that is also the case for DEFINE_MUTEX() and other similar macros. -- Thanks, Petr