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]
Date: Mon, 31 Jul 2023 09:17:28 +0200
From: Joel Granados <joel.granados@...il.com>
To: mcgrof@...nel.org
Cc: Catalin Marinas <catalin.marinas@....com>,
	Iurii Zaikin <yzaikin@...gle.com>,
	Jozsef Kadlecsik <kadlec@...filter.org>,
	Sven Schnelle <svens@...ux.ibm.com>,
	Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
	Steffen Klassert <steffen.klassert@...unet.com>,
	Kees Cook <keescook@...omium.org>,
	"D. Wythe" <alibuda@...ux.alibaba.com>,
	mptcp@...ts.linux.dev,
	Jakub Kicinski <kuba@...nel.org>,
	Vasily Gorbik <gor@...ux.ibm.com>,
	Paolo Abeni <pabeni@...hat.com>,
	coreteam@...filter.org,
	Jan Karcher <jaka@...ux.ibm.com>,
	Alexander Aring <alex.aring@...il.com>,
	Will Deacon <will@...nel.org>,
	Stefan Schmidt <stefan@...enfreihafen.org>,
	Matthieu Baerts <matthieu.baerts@...sares.net>,
	bridge@...ts.linux-foundation.org,
	linux-arm-kernel@...ts.infradead.org,
	Joerg Reuter <jreuter@...na.de>,
	Julian Anastasov <ja@....bg>,
	David Ahern <dsahern@...nel.org>,
	netfilter-devel@...r.kernel.org,
	Wen Gu <guwen@...ux.alibaba.com>,
	linux-kernel@...r.kernel.org,
	Santosh Shilimkar <santosh.shilimkar@...cle.com>,
	linux-wpan@...r.kernel.org,
	lvs-devel@...r.kernel.org,
	Karsten Graul <kgraul@...ux.ibm.com>,
	Miquel Raynal <miquel.raynal@...tlin.com>,
	Herbert Xu <herbert@...dor.apana.org.au>,
	linux-sctp@...r.kernel.org,
	Tony Lu <tonylu@...ux.alibaba.com>,
	Pablo Neira Ayuso <pablo@...filter.org>,
	Ralf Baechle <ralf@...ux-mips.org>,
	Florian Westphal <fw@...len.de>,
	willy@...radead.org,
	Heiko Carstens <hca@...ux.ibm.com>,
	"David S. Miller" <davem@...emloft.net>,
	linux-rdma@...r.kernel.org,
	Roopa Prabhu <roopa@...dia.com>,
	Alexander Gordeev <agordeev@...ux.ibm.com>,
	Simon Horman <horms@...ge.net.au>,
	Mat Martineau <martineau@...nel.org>,
	josh@...htriplett.org,
	Christian Borntraeger <borntraeger@...ux.ibm.com>,
	Eric Dumazet <edumazet@...gle.com>,
	linux-hams@...r.kernel.org,
	Wenjia Zhang <wenjia@...ux.ibm.com>,
	linux-fsdevel@...r.kernel.org,
	linux-s390@...r.kernel.org,
	Xin Long <lucien.xin@...il.com>,
	Nikolay Aleksandrov <razor@...ckwall.org>,
	netdev@...r.kernel.org,
	rds-devel@....oracle.com,
	Joel Granados <j.granados@...sung.com>,
	Jani Nikula <jani.nikula@...ux.intel.com>
Subject: [PATCH v2 14/14] sysctl: Use ctl_table_size as stopping criteria for list macro

This is a preparation commit to make it easy to remove the sentinel
elements (empty end markers) from the ctl_table arrays. It both allows
the systematic removal of the sentinels and adds the ctl_table_size
variable to the stopping criteria of the list_for_each_table_entry macro
that traverses all ctl_table arrays. Once all the sentinels are removed
by subsequent commits, ctl_table_size will become the only stopping
criteria in the macro. We don't actually remove any elements in this
commit, but it sets things up to for the removal process to take place.

By adding header->ctl_table_size as an additional stopping criteria for
the list_for_each_table_entry macro, it will execute until it finds an
"empty" ->procname or until the size runs out. Therefore if a ctl_table
array with a sentinel is passed its size will be too big (by one
element) but it will stop on the sentinel. On the other hand, if the
ctl_table array without a sentinel is passed its size will be just write
and there will be no need for a sentinel.

Signed-off-by: Joel Granados <j.granados@...sung.com>
Suggested-by: Jani Nikula <jani.nikula@...ux.intel.com>
---
 fs/proc/proc_sysctl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 817bc51c58d8..504e847c2a3a 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -19,8 +19,9 @@
 #include <linux/kmemleak.h>
 #include "internal.h"
 
-#define list_for_each_table_entry(entry, header) \
-	for ((entry) = (header->ctl_table); (entry)->procname; (entry)++)
+#define list_for_each_table_entry(entry, header)	\
+	entry = header->ctl_table;			\
+	for (size_t i = 0 ; i < header->ctl_table_size && entry->procname; ++i, entry++)
 
 static const struct dentry_operations proc_sys_dentry_operations;
 static const struct file_operations proc_sys_file_operations;
-- 
2.30.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ