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: <20230731071728.3493794-5-j.granados@samsung.com>
Date:   Mon, 31 Jul 2023 09:17:18 +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>
Subject: [PATCH v2 04/14] sysctl: Add size argument to init_header

In this commit, we add a table_size argument to the init_header function
in order to initialize the ctl_table_size variable in ctl_table_header.
Even though the size is not yet used, it is now initialized within the
sysctl subsys. We need this commit for when we start adding the
table_size arguments to the sysctl functions (e.g. register_sysctl,
__register_sysctl_table and __register_sysctl_init).

Note that in __register_sysctl_table we temporarily use a calculated
size until we add the size argument to that function in subsequent
commits.

Signed-off-by: Joel Granados <j.granados@...sung.com>
---
 fs/proc/proc_sysctl.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 884460b0385b..fa1438f1a355 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -188,9 +188,10 @@ static void erase_entry(struct ctl_table_header *head, struct ctl_table *entry)
 
 static void init_header(struct ctl_table_header *head,
 	struct ctl_table_root *root, struct ctl_table_set *set,
-	struct ctl_node *node, struct ctl_table *table)
+	struct ctl_node *node, struct ctl_table *table, size_t table_size)
 {
 	head->ctl_table = table;
+	head->ctl_table_size = table_size;
 	head->ctl_table_arg = table;
 	head->used = 0;
 	head->count = 1;
@@ -973,7 +974,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
 	memcpy(new_name, name, namelen);
 	table[0].procname = new_name;
 	table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO;
-	init_header(&new->header, set->dir.header.root, set, node, table);
+	init_header(&new->header, set->dir.header.root, set, node, table, 1);
 
 	return new;
 }
@@ -1197,7 +1198,8 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
 		link_name += len;
 		link++;
 	}
-	init_header(links, dir->header.root, dir->header.set, node, link_table);
+	init_header(links, dir->header.root, dir->header.set, node, link_table,
+		    head->ctl_table_size);
 	links->nreg = nr_entries;
 
 	return links;
@@ -1372,7 +1374,7 @@ struct ctl_table_header *__register_sysctl_table(
 		return NULL;
 
 	node = (struct ctl_node *)(header + 1);
-	init_header(header, root, set, node, table);
+	init_header(header, root, set, node, table, nr_entries);
 	if (sysctl_check_table(path, header))
 		goto fail;
 
@@ -1537,7 +1539,7 @@ void setup_sysctl_set(struct ctl_table_set *set,
 {
 	memset(set, 0, sizeof(*set));
 	set->is_seen = is_seen;
-	init_header(&set->dir.header, root, set, NULL, root_table);
+	init_header(&set->dir.header, root, set, NULL, root_table, 1);
 }
 
 void retire_sysctl_set(struct ctl_table_set *set)
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ