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: <CAL_JsqK733Q9bbxC0Wz5uxyZ9m7bs+bci5kUJF9GJMv73-dO4w@mail.gmail.com>
Date: Wed, 16 Apr 2025 14:25:37 -0500
From: Rob Herring <robh@...nel.org>
To: 1425075683@...com
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, 
	m.szyprowski@...sung.com, saravanak@...gle.com
Subject: Re: [PATCH] of: reserved-mem: Warn for missing initfn in __reservedmem_of_table

On Tue, Apr 15, 2025 at 9:02 PM <1425075683@...com> wrote:
>
> > On Tue, Apr 15, 2025 at 9:16 AM Liya Huang <1425075683@...com> wrote:
> > >
> > > For the data in __reservedmem_of_table, its function pointer initfn might
> > > be NULL. However, __reserved_mem_init_node() only considers non-NULL cases
> > > and ignores NULL function pointers.
> >
> > If initfn is NULL, there's no point to the entry and that's a bug.
> > Unless you have a build time check, there's no point to add this.
> >
> > Rob
>
> Thank you for your response. Based on your suggestion, I have made the
> modifications and used static_assert() to perform the check at compile
> time. The specific code is as follows. Could you please review whether
> this modification is reasonable? If it is acceptable, I will proceed with
> submitting the patch.
>
> I did not find any usage of static_assert() for null pointer checks in the
> kernel code.

That's a bit strange, but the use of static_assert() is a bit new.

> Additionally, BUILD_BUG_ON() cannot be used globally.
>
> ---
> diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
> index e338282da652..87446ad2deb2 100644
> --- a/include/linux/of_reserved_mem.h
> +++ b/include/linux/of_reserved_mem.h
> @@ -29,6 +29,7 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem);
>  #ifdef CONFIG_OF_RESERVED_MEM
>
>  #define RESERVEDMEM_OF_DECLARE(name, compat, init)                     \
> +       static_assert((init) != NULL);  \
>         _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn)

I'm pretty sure we can apply this globally in _OF_DECLARE() as any
NULL init function would be useless. The special case is
CLK_OF_DECLARE which wraps the init function.

Rob

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ