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] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_607C227A96060DD8EC83C78184305D264109@qq.com>
Date: Wed, 16 Apr 2025 09:57:08 +0800
From: 1425075683@...com
To: robh@...nel.org
Cc: 1425075683@...com,
	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: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. 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)
 
 int of_reserved_mem_device_init_by_idx(struct device *dev,
---

Thanks,
-- 
Liya Huang <1425075683@...com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ