All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Kees Cook <keescook@chromium.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Iurii Zaikin <yzaikin@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Joel Granados <j.granados@samsung.com>
Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	"Thomas Weißschuh" <linux@weissschuh.net>
Subject: [PATCH v2 15/18] sysctl: allow registration of const struct ctl_table
Date: Mon, 04 Dec 2023 08:52:28 +0100	[thread overview]
Message-ID: <20231204-const-sysctl-v2-15-7a5060b11447@weissschuh.net> (raw)
In-Reply-To: <20231204-const-sysctl-v2-0-7a5060b11447@weissschuh.net>

This allows sysctl table to be put into read-only data.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 fs/proc/proc_sysctl.c  |  6 +++---
 include/linux/sysctl.h | 10 +++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index e7fd1680d479..d09107a5b43f 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1356,7 +1356,7 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)
  */
 struct ctl_table_header *__register_sysctl_table(
 	struct ctl_table_set *set,
-	const char *path, struct ctl_table *table, size_t table_size)
+	const char *path, const struct ctl_table *table, size_t table_size)
 {
 	struct ctl_table_root *root = set->dir.header.root;
 	struct ctl_table_header *header;
@@ -1417,7 +1417,7 @@ struct ctl_table_header *__register_sysctl_table(
  *
  * See __register_sysctl_table for more details.
  */
-struct ctl_table_header *register_sysctl_sz(const char *path, struct ctl_table *table,
+struct ctl_table_header *register_sysctl_sz(const char *path, const struct ctl_table *table,
 					    size_t table_size)
 {
 	return __register_sysctl_table(&sysctl_table_root.default_set,
@@ -1446,7 +1446,7 @@ EXPORT_SYMBOL(register_sysctl_sz);
  *
  * Context: if your base directory does not exist it will be created for you.
  */
-void __init __register_sysctl_init(const char *path, struct ctl_table *table,
+void __init __register_sysctl_init(const char *path, const struct ctl_table *table,
 				 const char *table_name, size_t table_size)
 {
 	struct ctl_table_header *hdr = register_sysctl_sz(path, table, table_size);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 2f4d577f2e93..7c96d5abafc7 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -229,13 +229,13 @@ extern void retire_sysctl_set(struct ctl_table_set *set);
 
 struct ctl_table_header *__register_sysctl_table(
 	struct ctl_table_set *set,
-	const char *path, struct ctl_table *table, size_t table_size);
-struct ctl_table_header *register_sysctl_sz(const char *path, struct ctl_table *table,
+	const char *path, const struct ctl_table *table, size_t table_size);
+struct ctl_table_header *register_sysctl_sz(const char *path, const struct ctl_table *table,
 					    size_t table_size);
 void unregister_sysctl_table(struct ctl_table_header * table);
 
 extern int sysctl_init_bases(void);
-extern void __register_sysctl_init(const char *path, struct ctl_table *table,
+extern void __register_sysctl_init(const char *path, const struct ctl_table *table,
 				 const char *table_name, size_t table_size);
 #define register_sysctl_init(path, table)	\
 	__register_sysctl_init(path, table, #table, ARRAY_SIZE(table))
@@ -257,7 +257,7 @@ extern int no_unaligned_warning;
 
 #else /* CONFIG_SYSCTL */
 
-static inline void register_sysctl_init(const char *path, struct ctl_table *table)
+static inline void register_sysctl_init(const char *path, const struct ctl_table *table)
 {
 }
 
@@ -267,7 +267,7 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *p
 }
 
 static inline struct ctl_table_header *register_sysctl_sz(const char *path,
-							  struct ctl_table *table,
+							  const struct ctl_table *table,
 							  size_t table_size)
 {
 	return NULL;

-- 
2.43.0


  parent reply	other threads:[~2023-12-04  7:53 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20231204075237eucas1p27966f7e7da014b5992d3eef89a8fde25@eucas1p2.samsung.com>
2023-12-04  7:52 ` [PATCH v2 00/18] sysctl: constify sysctl ctl_tables Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 01/18] watchdog/core: remove sysctl handlers from public header Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 02/18] sysctl: delete unused define SYSCTL_PERM_EMPTY_DIR Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 03/18] sysctl: drop sysctl_is_perm_empty_ctl_table Thomas Weißschuh
2023-12-07 14:09     ` Joel Granados
2023-12-04  7:52   ` [PATCH v2 04/18] cgroup: bpf: constify ctl_table arguments and fields Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 05/18] seccomp: constify ctl_table arguments of utility functions Thomas Weißschuh
2023-12-04 22:12     ` Kees Cook
2023-12-04  7:52   ` [PATCH v2 06/18] hugetlb: " Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 07/18] utsname: constify ctl_table arguments of utility function Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 08/18] stackleak: don't modify ctl_table argument Thomas Weißschuh
2023-12-04 22:14     ` Kees Cook
2023-12-04  7:52   ` [PATCH v2 09/18] sysctl: treewide: constify ctl_table_root::set_ownership Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 10/18] sysctl: treewide: constify ctl_table_root::permissions Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 11/18] sysctl: treewide: constify ctl_table_header::ctl_table_arg Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 12/18] sysctl: treewide: constify the ctl_table argument of handlers Thomas Weißschuh
2023-12-04 22:17     ` Kees Cook
2023-12-05  9:50     ` kernel test robot
2023-12-05 16:05     ` kernel test robot
2023-12-04  7:52   ` [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header Thomas Weißschuh
2023-12-05 22:33     ` Luis Chamberlain
2023-12-05 22:41       ` Thomas Weißschuh
2023-12-05 22:50         ` Luis Chamberlain
2023-12-06  5:53           ` Thomas Weißschuh
2023-12-07 12:14             ` Joel Granados
2023-12-07 19:29               ` Thomas Weißschuh
2023-12-21 12:09             ` Joel Granados
2023-12-23 13:04               ` Thomas Weißschuh
2023-12-24 18:51                 ` Joel Granados
2023-12-07 12:05           ` Joel Granados
2023-12-07 11:31     ` Joel Granados
2023-12-04  7:52   ` [PATCH v2 14/18] sysctl: move internal interfaces to const struct ctl_table Thomas Weißschuh
2023-12-04  7:52   ` Thomas Weißschuh [this message]
2023-12-04  7:52   ` [PATCH v2 16/18] const_structs.checkpatch: add ctl_table Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 17/18] sysctl: make ctl_table sysctl_mount_point const Thomas Weißschuh
2023-12-04  7:52   ` [PATCH v2 18/18] sysctl: constify standard sysctl tables Thomas Weißschuh
2023-12-05  5:50   ` [PATCH v2 00/18] sysctl: constify sysctl ctl_tables Luis Chamberlain
2023-12-05  8:04     ` Thomas Weißschuh
2023-12-05 17:16       ` Thomas Weißschuh
2023-12-05 22:27         ` Luis Chamberlain
2023-12-07 11:23           ` Joel Granados
2023-12-07 11:19         ` Joel Granados
2023-12-07 19:23           ` Thomas Weißschuh
2023-12-07 11:05       ` Joel Granados
2023-12-07 10:43   ` Joel Granados
2023-12-07 19:19     ` Thomas Weißschuh
2023-12-08  9:59       ` Joel Granados
2023-12-11 11:25         ` Thomas Weißschuh
2023-12-12  9:09           ` Joel Granados
2023-12-13  7:51             ` Luis Chamberlain
2023-12-15 16:40               ` Thomas Weißschuh
2023-12-15 17:05                 ` Julia Lawall
2023-12-17 12:02               ` Joel Granados
2023-12-17 22:10                 ` Thomas Weißschuh
2023-12-18 21:21                   ` Luis Chamberlain
2023-12-19 19:29                     ` Thomas Weißschuh
2023-12-19 20:39                       ` Julia Lawall
2023-12-19 21:09                       ` Luis Chamberlain
2023-12-19 21:21                         ` Julia Lawall
2023-12-20  0:09                           ` Luis Chamberlain
2023-12-20  7:39                             ` Julia Lawall
2023-12-20 14:34                               ` Luis Chamberlain
2023-12-19 23:04                         ` Julia Lawall
2023-12-21 12:44                       ` Joel Granados
     [not found]                     ` <CGME20231223120907eucas1p20afac63076e1e9d5aee6adaa101c0630@eucas1p2.samsung.com>
2023-12-21 12:36                       ` Joel Granados
2023-12-21 12:12                   ` Joel Granados
2023-12-13  7:47           ` Luis Chamberlain
2023-12-13 18:18             ` Eric W. Biederman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231204-const-sysctl-v2-15-7a5060b11447@weissschuh.net \
    --to=linux@weissschuh.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=j.granados@samsung.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=yzaikin@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.