Thread (28 messages) 28 messages, 7 authors, 20m ago

Re: [PATCH 06/11] moduleparam: Add seq_buf-based .get callback alongside .get_str

From: Petr Pavlu <petr.pavlu@suse.com>
Date: 2026-05-25 16:19:24
Also in: dmaengine, dri-devel, intel-gfx, kvm, linux-acpi, linux-arch, linux-fsdevel, linux-hardening, linux-media, linux-mm, linux-modules, linux-pci, linux-pm, linux-rdma, linux-scsi, linux-security-module, linux-serial, linux-um, linux-usb, lkml, netdev, qemu-devel, virtualization

On 5/21/26 3:33 PM, Kees Cook wrote:
Add a new struct kernel_param_ops::get callback whose signature
takes a struct seq_buf instead of a raw char buffer:

  int (*get)(struct seq_buf *sb, const struct kernel_param *kp);

The previously-legacy .get field is now .get_str (char *buffer);
.get is the new seq_buf-aware form.  param_attr_show() prefers .get
when set, otherwise falls back to .get_str.  WARN_ON_ONCE() if both
are set.  Return contract for .get:

  < 0 : errno propagated to userspace; seq_buf contents discarded
  = 0 : success; length derived from seq_buf_used()
  > 0 : forbidden; the dispatcher WARN_ON_ONCE()s and treats as 0

The default policy on seq_buf_has_overflowed() is silent truncation,
matching scnprintf()/sysfs_emit() behaviour.  Callbacks that want a
specific overflow errno can check seq_buf_has_overflowed() and
return their preferred error.

No callbacks use .get yet; the legacy path is still the only one in use
after this commit. A subsequent commit teaches DEFINE_KERNEL_PARAM_OPS
to route initializers by type.

Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>

-- Petr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help