lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <n4b3usqvtxp34aq5q4veuvc6n6oqjnxa5pwci5wbt5j6s3hugm@3zqpwun6j233>
Date: Thu, 20 Nov 2025 03:03:24 -0800
From: Breno Leitao <leitao@...ian.org>
To: Gustavo Luiz Duarte <gustavold@...il.com>
Cc: Andre Carvalho <asantostc@...il.com>, Simon Horman <horms@...nel.org>, 
	Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller" <davem@...emloft.net>, 
	Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, 
	Paolo Abeni <pabeni@...hat.com>, Shuah Khan <shuah@...nel.org>, netdev@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH net-next v3 3/4] netconsole: Dynamic allocation of
 userdata buffer

On Wed, Nov 19, 2025 at 04:14:51PM -0800, Gustavo Luiz Duarte wrote:
> The userdata buffer in struct netconsole_target is currently statically
> allocated with a size of MAX_USERDATA_ITEMS * MAX_EXTRADATA_ENTRY_LEN
> (16 * 256 = 4096 bytes). This wastes memory when userdata entries are
> not used or when only a few entries are configured, which is common in
> typical usage scenarios. It also forces us to keep MAX_USERDATA_ITEMS
> small to limit the memory wasted.
> 
> Change the userdata buffer from a static array to a dynamically
> allocated pointer. The buffer is now allocated on-demand in
> update_userdata() whenever userdata entries are added, modified, or
> removed via configfs. The implementation calculates the exact size
> needed for all current userdata entries, allocates a new buffer of that
> size, formats the entries into it, and atomically swaps it with the old
> buffer.
> 
> This approach provides several benefits:
> - Memory efficiency: Targets with no userdata use zero bytes instead of
>   4KB, and targets with userdata only allocate what they need;
> - Scalability: Makes it practical to increase MAX_USERDATA_ITEMS to a
>   much larger value without imposing a fixed memory cost on every
>   target;
> - No hot-path overhead: Allocation occurs during configuration (write to
>   configfs), not during message transmission
> 
> If memory allocation fails during userdata update, -ENOMEM is returned
> to userspace through the configfs attribute write operation.
> 
> The sysdata buffer remains statically allocated since it has a smaller
> fixed size (MAX_SYSDATA_ITEMS * MAX_EXTRADATA_ENTRY_LEN = 4 * 256 = 1024
> bytes) and its content length is less predictable.
> 
> Signed-off-by: Gustavo Luiz Duarte <gustavold@...il.com>

Reviewed-by: Breno Leitao <leitao@...ian.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ