Re: [PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers

2024-05-11 Thread Thomas Weißschuh
Hi Kees,

On 2024-05-08 10:11:35+, Kees Cook wrote:
> On Wed, Apr 24, 2024 at 08:12:34PM -0700, Jakub Kicinski wrote:
> > On Tue, 23 Apr 2024 09:54:35 +0200 Thomas Weißschuh wrote:
> > > The series was split from my larger series sysctl-const series [0].
> > > It only focusses on the proc_handlers but is an important step to be
> > > able to move all static definitions of ctl_table into .rodata.
> > 
> > Split this per subsystem, please.
> 
> I've done a few painful API transitions before, and I don't think the
> complexity of these changes needs a per-subsystem constification pass. I
> think this series is the right approach, but that patch 11 will need
> coordination with Linus. We regularly do system-wide prototype changes
> like this right at the end of the merge window before -rc1 comes out.

That sounds good.

> The requirements are pretty simple: it needs to be a obvious changes
> (this certainly is) and as close to 100% mechanical as possible. I think
> patch 11 easily qualifies. Linus should be able to run the same Coccinelle
> script and get nearly the same results, etc. And all the other changes
> need to have landed. This change also has no "silent failure" conditions:
> anything mismatched will immediately stand out.

Unfortunately coccinelle alone is not sufficient, as some helpers with
different prototypes are called by handlers and themselves are calling
handler and therefore need to change in the same commit.
But if I add a diff for those on top of the coccinelle script to the
changelog it should be obvious.

> So, have patches 1-10 go via their respective subsystems, and once all
> of those are in Linus's tree, send patch 11 as a stand-alone PR.

Ack, I'll do that with the cover letter information requested by Joel.

> (From patch 11, it looks like the seccomp read/write function changes
> could be split out? I'll do that now...)

Thanks!

Thomas


Re: [PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers

2024-05-03 Thread Thomas Weißschuh
Hey Joel,

On 2024-05-03 11:03:32+, Joel Granados wrote:
> Here is my feedback for your outstanding constification patches [1] and [2].

Thanks!

> # You need to split the patch
> The answer that you got from Jakub in the network subsystem is very clear and
> baring a change of heart from the network folks, this will go in as but as a
> split patchset. Please split it considering the following:
> 1. Create a different patchset for drivers/,  fs/, kernel/, net, and a
>miscellaneous that includes whatever does not fit into the others.
> 2. Consider that this might take several releases.
> 3. Consider the following sufix for the interim function name "_const". Like 
> in
>kfree_const. Please not "_new".

Ack. "_new" was an intentionally unacceptable placeholder.

> 4. Please publish the final result somewhere. This is important so someone can
>take over in case you need to stop.

Will do. Both for each single series and a combination of all of them.

> 5. Consistently mention the motivation in your cover letters. I specify more
>further down in "#Motivation".
> 6. Also mention that this is part of a bigger effort (like you did in your
>original cover letters). I would include [3,4,5,6]
> 7. Include a way to show what made it into .rodata. I specify more further 
> down
>in "#Show the move".
> 
> # Motivation
> As I read it, the motivation for these constification efforts are:
> 1. It provides increased safety: Having things in .rodata section reduces the
>attack surface. This is especially relevant for structures that have 
> function
>pointers (like ctl_table); having these in .rodata means that these 
> pointers
>always point to the "intended" function and cannot be changed.
> 2. Compiler optimizations: This was just a comment in the patchsets that I 
> have
>mentioned ([3,4,5]). Do you know what optimizations specifically? Does it
>have to do with enhancing locality for the data in .rodata? Do you have 
> other
>specific optimizations in mind?

I don't know about anything that would make it faster.
It's more about safety and transmission of intent to API users,
especially callback implementers.

> 3. Readability: because it is easier to know up-front that data is not 
> supposed
>to change or its obvious that a function is re-entrant. Actually a lot of 
> the
>readability reasons is about knowing things "up-front".
> As we move forward with the constification in sysctl, please include a more
> detailed motivation in all your cover letters. This helps maintainers (that
> don't have the context) understand what you are trying to do. It does not need
> to be my three points, but it should be more than just "put things into
> .rodata". Please tell me if I have missed anything in the motivation.

Will do.

> # Show the move
> I created [8] because there is no easy way to validate which objects made it
> into .rodata. I ran [8] for your Dec 2nd patcheset [7] and there are less in
> .rodata than I expected (the results are in [9]) Why is that? Is it something
> that has not been posted to the lists yet? 

Constifying the APIs only *allows* the actual table to be constified
themselves.
Then each table definition will have to be touched and "const" added.

See patches 17 and 18 in [7] for two examples.

Some tables in net/ are already "const" as the static definitions are
never registered themselves but only their copies are.

This seems to explain your findings.

> Best

Thanks!

> [1] 
> https://lore.kernel.org/all/20240423-sysctl-const-handler-v3-0-e0beccb83...@weissschuh.net/
> [2] 
> https://lore.kernel.org/all/20240418-sysctl-const-table-arg-v2-1-4012abc31...@weissschuh.net
> [3] [PATCH v2 00/14] ASoC: Constify local snd_sof_dsp_ops
> 
> https://lore.kernel.org/all/20240426-n-const-ops-var-v2-0-e553fe67a...@kernel.org
> [4] [PATCH v2 00/19] backlight: Constify lcd_ops
> 
> https://lore.kernel.org/all/20240424-video-backlight-lcd-ops-v2-0-1aaa82b07...@kernel.org
> [5] [PATCH 1/4] iommu: constify pointer to bus_type
> 
> https://lore.kernel.org/all/20240216144027.185959-1-krzysztof.kozlow...@linaro.org
> [6] [PATCH 00/29] const xattr tables
> https://lore.kernel.org/all/20230930050033.41174-1-wedso...@gmail.com
> [7] 
> https://lore.kernel.org/all/20231204-const-sysctl-v2-0-7a5060b11...@weissschuh.net/
> 
> [8]

[snip]

> [9]
> section: .rodataobj_name : kern_table
> section: .rodataobj_name : sysctl_mount_point
> section: .rodataobj_name : addrconf_sysctl
> section: .rodataobj_name : ax25_param_table
> section: .rodataobj_name : mpls_table
> section: .rodataobj_name : mpls_dev_table
> section: .data  obj_name : sld_sysctls
> section: .data  obj_name : kern_panic_table
> section: .data  obj_name : kern_exit_table
> section: .data  obj_name : vm_table
> section: .data 

Re: [PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers

2024-04-27 Thread Thomas Weißschuh
On 2024-04-25 09:10:27+, Thomas Weißschuh wrote:
> On 2024-04-24 20:12:34+, Jakub Kicinski wrote:
> > On Tue, 23 Apr 2024 09:54:35 +0200 Thomas Weißschuh wrote:
> > > The series was split from my larger series sysctl-const series [0].
> > > It only focusses on the proc_handlers but is an important step to be
> > > able to move all static definitions of ctl_table into .rodata.
> > 
> > Split this per subsystem, please.
> 
> Unfortunately this would introduce an enormous amount of code churn.
> 
> The function prototypes for each callback have to stay consistent.
> So a another callback member ("proc_handler_new") is needed and users
> would be migrated to it gradually.
> 
> But then *all* definitions of "struct ctl_table" throughout the tree need to
> be touched.
> In contrast, the proposed series only needs to change the handler
> implementations, not their usage sites.
> 
> There are many, many more usage sites than handler implementations.
> 
> Especially, as the majority of sysctl tables use the standard handlers
> (proc_dostring, proc_dobool, ...) and are not affected by the proposed
> aproach at all.
> 
> And then we would have introduced a new handler name "proc_handler_new"
> and maybe have to do the whole thing again to rename it back to
> the original and well-known "proc_handler".

This aproach could be optimized by only migrating the usages of the
custom handler implementations to "proc_handler_new".
After this we could move over the core handlers and "proc_handler" in
one small patch that does not need to touch the usages sites.

Afterwards all non-core usages would be migrated back from
"proc_handler_new" to "proc_handler" and the _new variant could be
dropped again.

It would still be more than twice the churn of my current patch.
And these patches would be more complex than the current
"just add a bunch of consts, nothing else".

Personally I still prefer the original aproach.


Thomas


Re: [PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers

2024-04-25 Thread Thomas Weißschuh
Hi Joel,

On 2024-04-25 13:04:12+, Joel Granados wrote:
> On Wed, Apr 24, 2024 at 08:12:34PM -0700, Jakub Kicinski wrote:
> > On Tue, 23 Apr 2024 09:54:35 +0200 Thomas Weißschuh wrote:
> > > The series was split from my larger series sysctl-const series [0].
> > > It only focusses on the proc_handlers but is an important step to be
> > > able to move all static definitions of ctl_table into .rodata.
> > 
> > Split this per subsystem, please.
> It is tricky to do that because it changes the first argument (ctl*) to
> const in the proc_handler function type defined in sysclt.h:
> "
> -typedef int proc_handler(struct ctl_table *ctl, int write, void *buffer,
> +typedef int proc_handler(const struct ctl_table *ctl, int write, void 
> *buffer,
> size_t *lenp, loff_t *ppos);
> "
> This means that all the proc_handlers need to change at the same time.
> 
> However, there is an alternative way to do this that allows chunking. We
> first define the proc_handler as a void pointer (casting it where it is
> being used) [1]. Then we could do the constification by subsystem (like
> Jakub proposes). Finally we can "revert the void pointer change so we
> don't have one size fit all pointer as our proc_handler [2].
> 
> Here are some comments about the alternative:
> 1. We would need to make the first argument const in all the derived
>proc_handlers [3] 
> 2. There would be no undefined behavior for two reasons:
>2.1. There is no case where we change the first argument. We know
> this because there are no compile errors after we make it const.
>2.2. We would always go from non-const to const. This is the case
> because all the stuff that is unchanged in non-const.
> 3. If the idea sticks, it should go into mainline as one patchset. I
>would not like to have a void* proc_handler in a kernel release.
> 4. I think this is a "win/win" solution were the constification goes
>through and it is divided in such a way that it is reviewable.
> 
> I would really like to hear what ppl think about this "heretic"
> alternative. @Thomas, @Luis, @Kees @Jakub?

Thanks for that alternative, I'm not a big fan though.

Besides the wonky syntax, Control Flow Integrity should trap on
this construct. Functions are called through different pointers than
their actual types which is exactly what CFI is meant to prevent.

Maybe people find it easier to review when using
"--word-diff" and/or "-U0" with git diff/show.
There is really nothing going an besides adding a few "const"s.

But if the consensus prefers this solution, I'll be happy to adopt it.

> [1] 
> https://git.kernel.org/pub/scm/linux/kernel/git/joel.granados/linux.git/commit/?h=jag/constfy_treewide_alternative=4a383503b1ea650d4e12c1f5838974e879f5aa6f
> [2] 
> https://git.kernel.org/pub/scm/linux/kernel/git/joel.granados/linux.git/commit/?h=jag/constfy_treewide_alternative=a3be65973d27ec2933b9e81e1bec60be3a9b460d
> [3] proc_dostring, proc_dobool, proc_dointvec


Thomas


Re: [PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers

2024-04-25 Thread Thomas Weißschuh
On 2024-04-24 20:12:34+, Jakub Kicinski wrote:
> On Tue, 23 Apr 2024 09:54:35 +0200 Thomas Weißschuh wrote:
> > The series was split from my larger series sysctl-const series [0].
> > It only focusses on the proc_handlers but is an important step to be
> > able to move all static definitions of ctl_table into .rodata.
> 
> Split this per subsystem, please.

Unfortunately this would introduce an enormous amount of code churn.

The function prototypes for each callback have to stay consistent.
So a another callback member ("proc_handler_new") is needed and users
would be migrated to it gradually.

But then *all* definitions of "struct ctl_table" throughout the tree need to
be touched.
In contrast, the proposed series only needs to change the handler
implementations, not their usage sites.

There are many, many more usage sites than handler implementations.

Especially, as the majority of sysctl tables use the standard handlers
(proc_dostring, proc_dobool, ...) and are not affected by the proposed
aproach at all.

And then we would have introduced a new handler name "proc_handler_new"
and maybe have to do the whole thing again to rename it back to
the original and well-known "proc_handler".


Of course if somebody has a better aproach, I'm all ears.


Thomas


[PATCH v3 01/11] stackleak: don't modify ctl_table argument

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers will change to
"const struct ctl_table".
As a preparation for that adapt the logic to work with a temporary
variable, similar to how it is done in other parts of the kernel.

Fixes: 964c9dff0091 ("stackleak: Allow runtime disabling of kernel stack 
erasing")
Acked-by: Kees Cook 
Signed-off-by: Thomas Weißschuh 
---
 kernel/stackleak.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/stackleak.c b/kernel/stackleak.c
index d099f3affcf1..558b9d6d28d3 100644
--- a/kernel/stackleak.c
+++ b/kernel/stackleak.c
@@ -27,10 +27,11 @@ static int stack_erasing_sysctl(struct ctl_table *table, 
int write,
int ret = 0;
int state = !static_branch_unlikely(_erasing_bypass);
int prev_state = state;
+   struct ctl_table tmp = *table;
 
-   table->data = 
-   table->maxlen = sizeof(int);
-   ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+   tmp.data = 
+   tmp.maxlen = sizeof(int);
+   ret = proc_dointvec_minmax(, write, buffer, lenp, ppos);
state = !!state;
if (ret || !write || state == prev_state)
return ret;

-- 
2.44.0



[PATCH v3 02/11] cgroup: bpf: constify ctl_table arguments and fields

2024-04-23 Thread Thomas Weißschuh
In a future commit the sysctl core will only use
"const struct ctl_table". As a preparation for that adapt the cgroup-bpf
code.

Signed-off-by: Thomas Weißschuh 
---
 include/linux/filter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/filter.h b/include/linux/filter.h
index 7a27f19bf44d..4eada55a2df8 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1404,7 +1404,7 @@ struct bpf_sock_ops_kern {
 
 struct bpf_sysctl_kern {
struct ctl_table_header *head;
-   struct ctl_table *table;
+   const struct ctl_table *table;
void *cur_val;
size_t cur_len;
void *new_val;

-- 
2.44.0



[PATCH v3 10/11] sysctl: constify ctl_table arguments of utility function

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 include/linux/sysctl.h |  2 +-
 kernel/sysctl.c| 21 +++--
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 09db2f2e6488..54fbec062772 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -237,7 +237,7 @@ extern struct ctl_table_header 
*register_sysctl_mount_point(const char *path);
 
 void do_sysctl_args(void);
 bool sysctl_is_alias(char *param);
-int do_proc_douintvec(struct ctl_table *table, int write,
+int do_proc_douintvec(const struct ctl_table *table, int write,
  void *buffer, size_t *lenp, loff_t *ppos,
  int (*conv)(unsigned long *lvalp,
  unsigned int *valp,
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index e0b917328cf9..62dd27752960 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -205,7 +205,7 @@ static int _proc_do_string(char *data, int maxlen, int 
write,
return 0;
 }
 
-static void warn_sysctl_write(struct ctl_table *table)
+static void warn_sysctl_write(const struct ctl_table *table)
 {
pr_warn_once("%s wrote to %s when file position was not 0!\n"
"This will not be supported in the future. To silence this\n"
@@ -223,7 +223,7 @@ static void warn_sysctl_write(struct ctl_table *table)
  * handlers can ignore the return value.
  */
 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
-  struct ctl_table *table)
+  const struct ctl_table *table)
 {
if (!*ppos)
return false;
@@ -468,7 +468,7 @@ static int do_proc_douintvec_conv(unsigned long *lvalp,
 
 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
 
-static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
+static int __do_proc_dointvec(void *tbl_data, const struct ctl_table *table,
  int write, void *buffer,
  size_t *lenp, loff_t *ppos,
  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
@@ -541,7 +541,7 @@ static int __do_proc_dointvec(void *tbl_data, struct 
ctl_table *table,
return err;
 }
 
-static int do_proc_dointvec(struct ctl_table *table, int write,
+static int do_proc_dointvec(const struct ctl_table *table, int write,
  void *buffer, size_t *lenp, loff_t *ppos,
  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
  int write, void *data),
@@ -552,7 +552,7 @@ static int do_proc_dointvec(struct ctl_table *table, int 
write,
 }
 
 static int do_proc_douintvec_w(unsigned int *tbl_data,
-  struct ctl_table *table,
+  const struct ctl_table *table,
   void *buffer,
   size_t *lenp, loff_t *ppos,
   int (*conv)(unsigned long *lvalp,
@@ -639,7 +639,7 @@ static int do_proc_douintvec_r(unsigned int *tbl_data, void 
*buffer,
return err;
 }
 
-static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
+static int __do_proc_douintvec(void *tbl_data, const struct ctl_table *table,
   int write, void *buffer,
   size_t *lenp, loff_t *ppos,
   int (*conv)(unsigned long *lvalp,
@@ -675,7 +675,7 @@ static int __do_proc_douintvec(void *tbl_data, struct 
ctl_table *table,
return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
 }
 
-int do_proc_douintvec(struct ctl_table *table, int write,
+int do_proc_douintvec(const struct ctl_table *table, int write,
  void *buffer, size_t *lenp, loff_t *ppos,
  int (*conv)(unsigned long *lvalp,
  unsigned int *valp,
@@ -1023,8 +1023,9 @@ static int sysrq_sysctl_handler(struct ctl_table *table, 
int write,
 }
 #endif
 
-static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
-   int write, void *buffer, size_t *lenp, loff_t *ppos,
+static int __do_proc_doulongvec_minmax(void *data,
+   const struct ctl_table *table, int write,
+   void *buffer, size_t *lenp, loff_t *ppos,
unsigned long convmul, unsigned long convdiv)
 {
unsigned long *i, *min, *max;
@@ -1096,7 +1097,7 @@ static int __do_proc_doulongvec_minmax(void *data, struct 
ctl_table *table,
return err;
 }
 
-static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
+static int do_proc_doulongvec_minmax(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
unsigned long convdiv)
 {

-- 
2.44.0



[PATCH v3 08/11] ipv6/ndisc: constify ctl_table arguments of utility function

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 net/ipv6/ndisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index ae134634c323..945d5f5ca039 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1936,7 +1936,7 @@ static struct notifier_block ndisc_netdev_notifier = {
 };
 
 #ifdef CONFIG_SYSCTL
-static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
+static void ndisc_warn_deprecated_sysctl(const struct ctl_table *ctl,
 const char *func, const char *dev_name)
 {
static char warncomm[TASK_COMM_LEN];

-- 
2.44.0



[PATCH v3 07/11] ipv6/addrconf: constify ctl_table arguments of utility functions

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 net/ipv6/addrconf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 9aa0900abfa1..96ab349e8ba4 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -863,7 +863,7 @@ static void addrconf_forward_change(struct net *net, __s32 
newf)
}
 }
 
-static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int newf)
+static int addrconf_fixup_forwarding(const struct ctl_table *table, int *p, 
int newf)
 {
struct net *net;
int old;
@@ -931,7 +931,7 @@ static void addrconf_linkdown_change(struct net *net, __s32 
newf)
}
 }
 
-static int addrconf_fixup_linkdown(struct ctl_table *table, int *p, int newf)
+static int addrconf_fixup_linkdown(const struct ctl_table *table, int *p, int 
newf)
 {
struct net *net;
int old;
@@ -6378,7 +6378,7 @@ static void addrconf_disable_change(struct net *net, 
__s32 newf)
}
 }
 
-static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)
+static int addrconf_disable_ipv6(const struct ctl_table *table, int *p, int 
newf)
 {
struct net *net = (struct net *)table->extra2;
int old;
@@ -6669,7 +6669,7 @@ void addrconf_disable_policy_idev(struct inet6_dev *idev, 
int val)
 }
 
 static
-int addrconf_disable_policy(struct ctl_table *ctl, int *valp, int val)
+int addrconf_disable_policy(const struct ctl_table *ctl, int *valp, int val)
 {
struct net *net = (struct net *)ctl->extra2;
struct inet6_dev *idev;

-- 
2.44.0



[PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers

2024-04-23 Thread Thomas Weißschuh
* Patch 1 is a bugfix for the stack_erasing sysctl handler
* Patches 2-10 change various helper functions throughout the kernel to
  be able to handle 'const ctl_table'.
* Patch 11 changes the signatures of all proc handlers through the tree.
  Some other signatures are also adapted, for details see the commit
  message.

Only patch 1 changes any code at all.

The series was compile-tested on top of next-20230423 for
i386, x86_64, arm, arm64, riscv, loongarch, s390 and m68k.

The series was split from my larger series sysctl-const series [0].
It only focusses on the proc_handlers but is an important step to be
able to move all static definitions of ctl_table into .rodata.

[0] 
https://lore.kernel.org/lkml/20231204-const-sysctl-v2-0-7a5060b11...@weissschuh.net/

Signed-off-by: Thomas Weißschuh 
---
Changes in v3:
- Rebase on current -next
- Cc affected mailing lists again to gather feedback
- Link to v2: 
https://lore.kernel.org/r/20240323-sysctl-const-handler-v2-0-e80b178f1...@weissschuh.net

Changes in v2:
- Reduce recipient list
- Fix source formatting
- Rebase onto next-20240322
- Link to v1: 
https://lore.kernel.org/r/20240315-sysctl-const-handler-v1-0-1322ac7cb...@weissschuh.net

---
Thomas Weißschuh (11):
  stackleak: don't modify ctl_table argument
  cgroup: bpf: constify ctl_table arguments and fields
  hugetlb: constify ctl_table arguments of utility functions
  utsname: constify ctl_table arguments of utility function
  neighbour: constify ctl_table arguments of utility function
  ipv4/sysctl: constify ctl_table arguments of utility functions
  ipv6/addrconf: constify ctl_table arguments of utility functions
  ipv6/ndisc: constify ctl_table arguments of utility function
  ipvs: constify ctl_table arguments of utility functions
  sysctl: constify ctl_table arguments of utility function
  sysctl: treewide: constify the ctl_table argument of handlers

 arch/arm64/kernel/armv8_deprecated.c  |  2 +-
 arch/arm64/kernel/fpsimd.c|  2 +-
 arch/s390/appldata/appldata_base.c| 10 ++--
 arch/s390/kernel/debug.c  |  2 +-
 arch/s390/kernel/topology.c   |  2 +-
 arch/s390/mm/cmm.c|  6 +--
 arch/x86/kernel/itmt.c|  2 +-
 drivers/cdrom/cdrom.c |  4 +-
 drivers/char/random.c |  6 +--
 drivers/macintosh/mac_hid.c   |  2 +-
 drivers/net/vrf.c |  2 +-
 drivers/parport/procfs.c  | 12 ++---
 drivers/perf/arm_pmuv3.c  |  4 +-
 drivers/perf/riscv_pmu_sbi.c  |  2 +-
 fs/coredump.c |  2 +-
 fs/dcache.c   |  4 +-
 fs/drop_caches.c  |  2 +-
 fs/exec.c |  4 +-
 fs/file_table.c   |  4 +-
 fs/fs-writeback.c |  2 +-
 fs/inode.c|  4 +-
 fs/pipe.c |  2 +-
 fs/quota/dquot.c  |  2 +-
 fs/xfs/xfs_sysctl.c   |  6 +--
 include/linux/filter.h|  2 +-
 include/linux/ftrace.h|  4 +-
 include/linux/mm.h|  8 +--
 include/linux/perf_event.h|  6 +--
 include/linux/security.h  |  2 +-
 include/linux/sysctl.h| 36 ++---
 include/linux/vmstat.h|  6 +--
 include/linux/writeback.h |  2 +-
 include/net/ndisc.h   |  2 +-
 include/net/neighbour.h   |  6 +--
 include/net/netfilter/nf_hooks_lwtunnel.h |  2 +-
 ipc/ipc_sysctl.c  |  8 +--
 kernel/bpf/syscall.c  |  4 +-
 kernel/delayacct.c|  4 +-
 kernel/events/callchain.c |  2 +-
 kernel/events/core.c  |  4 +-
 kernel/fork.c |  2 +-
 kernel/hung_task.c|  6 +--
 kernel/kexec_core.c   |  2 +-
 kernel/kprobes.c  |  2 +-
 kernel/latencytop.c   |  4 +-
 kernel/pid_namespace.c|  2 +-
 kernel/pid_sysctl.h   |  2 +-
 kernel/printk/internal.h  |  2 +-
 kernel/printk/printk.c|  2 +-
 kernel/printk/sysctl.c|  5 +-
 kernel/sched/core.c   |  8 +--
 kernel/sched/rt.c | 16 +++---
 kernel/sched/topology.c   |  2 +-
 kernel/seccomp.c  | 10 ++--
 kernel/stackleak.c|  9 ++--
 kernel/sysctl.c   | 89 ---
 kernel/time/timer.c   |  2 +-
 kernel/trace/ftrace.c |  2 +-
 kernel/trace/trace.c

[PATCH v3 06/11] ipv4/sysctl: constify ctl_table arguments of utility functions

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 net/ipv4/sysctl_net_ipv4.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index ce5d19978a26..fc4c001bf72a 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -130,7 +130,8 @@ static int ipv4_privileged_ports(struct ctl_table *table, 
int write,
return ret;
 }
 
-static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t 
*low, kgid_t *high)
+static void inet_get_ping_group_range_table(const struct ctl_table *table,
+   kgid_t *low, kgid_t *high)
 {
kgid_t *data = table->data;
struct net *net =
@@ -145,7 +146,8 @@ static void inet_get_ping_group_range_table(struct 
ctl_table *table, kgid_t *low
 }
 
 /* Update system visible IP port range */
-static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t 
high)
+static void set_ping_group_range(const struct ctl_table *table,
+kgid_t low, kgid_t high)
 {
kgid_t *data = table->data;
struct net *net =

-- 
2.44.0



[PATCH v3 09/11] ipvs: constify ctl_table arguments of utility functions

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 net/netfilter/ipvs/ip_vs_ctl.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 143a341bbc0a..689ac521ea2d 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -1924,7 +1924,8 @@ proc_do_sync_ports(struct ctl_table *table, int write,
return rc;
 }
 
-static int ipvs_proc_est_cpumask_set(struct ctl_table *table, void *buffer)
+static int ipvs_proc_est_cpumask_set(const struct ctl_table *table,
+void *buffer)
 {
struct netns_ipvs *ipvs = table->extra2;
cpumask_var_t *valp = table->data;
@@ -1962,8 +1963,8 @@ static int ipvs_proc_est_cpumask_set(struct ctl_table 
*table, void *buffer)
return ret;
 }
 
-static int ipvs_proc_est_cpumask_get(struct ctl_table *table, void *buffer,
-size_t size)
+static int ipvs_proc_est_cpumask_get(const struct ctl_table *table,
+void *buffer, size_t size)
 {
struct netns_ipvs *ipvs = table->extra2;
cpumask_var_t *valp = table->data;

-- 
2.44.0



[PATCH v3 11/11] sysctl: treewide: constify the ctl_table argument of handlers

2024-04-23 Thread Thomas Weißschuh
Adapt the proc_hander function signature to make it clear that handlers
are not supposed to modify their ctl_table argument.

This is a prerequisite to moving the static ctl_table structs into
.rodata.
By migrating all handlers at once a lengthy transition can be avoided.

The patch was mostly generated by coccinelle with the following script:

@@
identifier func, ctl, write, buffer, lenp, ppos;
@@

int func(
- struct ctl_table *ctl,
+ const struct ctl_table *ctl,
  int write, void *buffer, size_t *lenp, loff_t *ppos)
{ ... }

In addition to the scripted changes some other changes are done:

* the typedef proc_handler is adapted

* the prototypes of non-static handler are adapted

* kernel/seccomp.c:{read,write}_actions_logged() and
  kernel/watchdog.c:proc_watchdog_common() are adapted as they need to
  adapted together with the handlers for type-consistency reasons

Signed-off-by: Thomas Weißschuh 
---
 arch/arm64/kernel/armv8_deprecated.c  |  2 +-
 arch/arm64/kernel/fpsimd.c|  2 +-
 arch/s390/appldata/appldata_base.c| 10 ++---
 arch/s390/kernel/debug.c  |  2 +-
 arch/s390/kernel/topology.c   |  2 +-
 arch/s390/mm/cmm.c|  6 +--
 arch/x86/kernel/itmt.c|  2 +-
 drivers/cdrom/cdrom.c |  4 +-
 drivers/char/random.c |  6 +--
 drivers/macintosh/mac_hid.c   |  2 +-
 drivers/net/vrf.c |  2 +-
 drivers/parport/procfs.c  | 12 +++---
 drivers/perf/arm_pmuv3.c  |  4 +-
 drivers/perf/riscv_pmu_sbi.c  |  2 +-
 fs/coredump.c |  2 +-
 fs/dcache.c   |  4 +-
 fs/drop_caches.c  |  2 +-
 fs/exec.c |  4 +-
 fs/file_table.c   |  4 +-
 fs/fs-writeback.c |  2 +-
 fs/inode.c|  4 +-
 fs/pipe.c |  2 +-
 fs/quota/dquot.c  |  2 +-
 fs/xfs/xfs_sysctl.c   |  6 +--
 include/linux/ftrace.h|  4 +-
 include/linux/mm.h|  8 ++--
 include/linux/perf_event.h|  6 +--
 include/linux/security.h  |  2 +-
 include/linux/sysctl.h| 34 
 include/linux/vmstat.h|  6 +--
 include/linux/writeback.h |  2 +-
 include/net/ndisc.h   |  2 +-
 include/net/neighbour.h   |  6 +--
 include/net/netfilter/nf_hooks_lwtunnel.h |  2 +-
 ipc/ipc_sysctl.c  |  8 ++--
 kernel/bpf/syscall.c  |  4 +-
 kernel/delayacct.c|  4 +-
 kernel/events/callchain.c |  2 +-
 kernel/events/core.c  |  4 +-
 kernel/fork.c |  2 +-
 kernel/hung_task.c|  6 +--
 kernel/kexec_core.c   |  2 +-
 kernel/kprobes.c  |  2 +-
 kernel/latencytop.c   |  4 +-
 kernel/pid_namespace.c|  2 +-
 kernel/pid_sysctl.h   |  2 +-
 kernel/printk/internal.h  |  2 +-
 kernel/printk/printk.c|  2 +-
 kernel/printk/sysctl.c|  5 ++-
 kernel/sched/core.c   |  8 ++--
 kernel/sched/rt.c | 16 
 kernel/sched/topology.c   |  2 +-
 kernel/seccomp.c  | 10 ++---
 kernel/stackleak.c|  2 +-
 kernel/sysctl.c   | 68 +++
 kernel/time/timer.c   |  2 +-
 kernel/trace/ftrace.c |  2 +-
 kernel/trace/trace.c  |  2 +-
 kernel/trace/trace_events_user.c  |  2 +-
 kernel/trace/trace_stack.c|  2 +-
 kernel/umh.c  |  2 +-
 kernel/utsname_sysctl.c   |  2 +-
 kernel/watchdog.c | 12 +++---
 mm/compaction.c   |  6 +--
 mm/hugetlb.c  |  8 ++--
 mm/page-writeback.c   | 18 
 mm/page_alloc.c   | 14 +++
 mm/util.c | 12 +++---
 mm/vmstat.c   |  4 +-
 net/bridge/br_netfilter_hooks.c   |  2 +-
 net/core/neighbour.c  | 18 
 net/core/sysctl_net_core.c| 20 -
 net/ipv4/devinet.c|  6 +--
 net/ipv4/route.c  |  2 +-
 net/ipv4/sysctl_net_ipv4.c| 32 +++
 net/ipv6/addrconf.c   | 19 +
 net/ipv6/ndisc.c

[PATCH v3 04/11] utsname: constify ctl_table arguments of utility function

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 kernel/utsname_sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
index 76a772072557..04e4513f2985 100644
--- a/kernel/utsname_sysctl.c
+++ b/kernel/utsname_sysctl.c
@@ -15,7 +15,7 @@
 
 #ifdef CONFIG_PROC_SYSCTL
 
-static void *get_uts(struct ctl_table *table)
+static void *get_uts(const struct ctl_table *table)
 {
char *which = table->data;
struct uts_namespace *uts_ns;

-- 
2.44.0



[PATCH v3 05/11] neighbour: constify ctl_table arguments of utility function

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 net/core/neighbour.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 0805c00c63d4..92a01664a723 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -3578,7 +3578,7 @@ static void neigh_copy_dflt_parms(struct net *net, struct 
neigh_parms *p,
rcu_read_unlock();
 }
 
-static void neigh_proc_update(struct ctl_table *ctl, int write)
+static void neigh_proc_update(const struct ctl_table *ctl, int write)
 {
struct net_device *dev = ctl->extra1;
struct neigh_parms *p = ctl->extra2;

-- 
2.44.0



[PATCH v3 03/11] hugetlb: constify ctl_table arguments of utility functions

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 mm/hugetlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 3b7d5ddc32ad..8d12ce63a439 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4911,7 +4911,7 @@ static unsigned int allowed_mems_nr(struct hstate *h)
 }
 
 #ifdef CONFIG_SYSCTL
-static int proc_hugetlb_doulongvec_minmax(struct ctl_table *table, int write,
+static int proc_hugetlb_doulongvec_minmax(const struct ctl_table *table, int 
write,
  void *buffer, size_t *length,
  loff_t *ppos, unsigned long *out)
 {
@@ -4928,7 +4928,7 @@ static int proc_hugetlb_doulongvec_minmax(struct 
ctl_table *table, int write,
 }
 
 static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
-struct ctl_table *table, int write,
+const struct ctl_table *table, int write,
 void *buffer, size_t *length, loff_t *ppos)
 {
struct hstate *h = _hstate;

-- 
2.44.0



[PATCH 11/11] sysctl: treewide: constify the ctl_table argument of handlers

2024-03-15 Thread Thomas Weißschuh
Adapt the proc_hander function signature to make it clear that handlers
are not supposed to modify their ctl_table argument.

This is a prerequisite to moving the static ctl_table structs into
.rodata.
By migrating all handlers at once a lengthy transition can be avoided.

The patch was mostly generated by coccinelle with the following script:

@@
identifier func, ctl, write, buffer, lenp, ppos;
@@

int func(
- struct ctl_table *ctl,
+ const struct ctl_table *ctl,
  int write, void *buffer, size_t *lenp, loff_t *ppos)
{ ... }

In addition to the scripted changes some other changes are done:

* the typedef proc_handler is adapted

* the prototypes of non-static handler are adapted

* kernel/seccomp.c:{read,write}_actions_logged() and
  kernel/watchdog.c:proc_watchdog_common() are adapted as they need to
  adapted together with the handlers for type-consistency reasons

Signed-off-by: Thomas Weißschuh 
---
 arch/arm64/kernel/armv8_deprecated.c  |  2 +-
 arch/arm64/kernel/fpsimd.c|  2 +-
 arch/s390/appldata/appldata_base.c| 10 ++--
 arch/s390/kernel/debug.c  |  2 +-
 arch/s390/kernel/topology.c   |  2 +-
 arch/s390/mm/cmm.c|  6 +--
 arch/x86/kernel/itmt.c|  2 +-
 drivers/cdrom/cdrom.c |  6 +--
 drivers/char/random.c |  5 +-
 drivers/macintosh/mac_hid.c   |  2 +-
 drivers/net/vrf.c |  2 +-
 drivers/parport/procfs.c  | 14 ++---
 drivers/perf/arm_pmuv3.c  |  6 ++-
 drivers/perf/riscv_pmu_sbi.c  |  2 +-
 fs/coredump.c |  4 +-
 fs/dcache.c   |  3 +-
 fs/drop_caches.c  |  4 +-
 fs/exec.c |  6 ++-
 fs/file_table.c   |  3 +-
 fs/fs-writeback.c |  2 +-
 fs/inode.c|  3 +-
 fs/pipe.c |  2 +-
 fs/quota/dquot.c  |  4 +-
 fs/xfs/xfs_sysctl.c   | 33 ++--
 include/linux/ftrace.h|  4 +-
 include/linux/mm.h|  8 +--
 include/linux/perf_event.h|  6 +--
 include/linux/security.h  |  2 +-
 include/linux/sysctl.h| 34 ++--
 include/linux/vmstat.h|  6 +--
 include/linux/writeback.h |  2 +-
 include/net/ndisc.h   |  2 +-
 include/net/neighbour.h   |  6 +--
 include/net/netfilter/nf_hooks_lwtunnel.h |  2 +-
 ipc/ipc_sysctl.c  | 14 ++---
 kernel/bpf/syscall.c  |  4 +-
 kernel/delayacct.c|  5 +-
 kernel/events/callchain.c |  2 +-
 kernel/events/core.c  |  9 ++--
 kernel/fork.c |  2 +-
 kernel/hung_task.c|  7 +--
 kernel/kexec_core.c   |  2 +-
 kernel/kprobes.c  |  2 +-
 kernel/latencytop.c   |  5 +-
 kernel/pid_namespace.c|  4 +-
 kernel/pid_sysctl.h   |  2 +-
 kernel/printk/internal.h  |  2 +-
 kernel/printk/printk.c|  2 +-
 kernel/printk/sysctl.c|  6 ++-
 kernel/sched/core.c   | 15 +++---
 kernel/sched/rt.c | 20 ---
 kernel/sched/topology.c   |  6 ++-
 kernel/seccomp.c  |  7 +--
 kernel/stackleak.c|  5 +-
 kernel/sysctl.c   | 88 ---
 kernel/time/timer.c   |  4 +-
 kernel/trace/ftrace.c |  2 +-
 kernel/trace/trace.c  |  2 +-
 kernel/trace/trace_events_user.c  |  3 +-
 kernel/trace/trace_stack.c|  2 +-
 kernel/umh.c  |  4 +-
 kernel/utsname_sysctl.c   |  4 +-
 kernel/watchdog.c | 15 +++---
 mm/compaction.c   | 17 +++---
 mm/hugetlb.c  | 16 +++---
 mm/page-writeback.c   | 27 ++
 mm/page_alloc.c   | 43 ++-
 mm/util.c | 15 +++---
 mm/vmstat.c   |  6 +--
 net/bridge/br_netfilter_hooks.c   |  2 +-
 net/core/neighbour.c  | 24 +
 net/core/sysctl_net_core.c| 24 +
 net/ipv4/devinet.c|  6 +--
 net/ipv4/route.c  |  4 +-
 net/ipv4/sysctl_net_ipv4.c| 34 ++--
 net/ipv6/addrconf.c   | 30 ++-
 net/ipv6/ndisc.c

[PATCH 02/11] cgroup: bpf: constify ctl_table arguments and fields

2024-03-15 Thread Thomas Weißschuh
In a future commit the sysctl core will only use
"const struct ctl_table". As a preparation for that adapt the cgroup-bpf
code.

Signed-off-by: Thomas Weißschuh 
---
 include/linux/filter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/filter.h b/include/linux/filter.h
index c99bc3df2d28..3238dcff5703 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1366,7 +1366,7 @@ struct bpf_sock_ops_kern {
 
 struct bpf_sysctl_kern {
struct ctl_table_header *head;
-   struct ctl_table *table;
+   const struct ctl_table *table;
void *cur_val;
size_t cur_len;
void *new_val;

-- 
2.44.0



[PATCH 01/11] stackleak: don't modify ctl_table argument

2024-03-15 Thread Thomas Weißschuh
In a future commit the proc_handlers will change to
"const struct ctl_table".
As a preparation for that adapt the logic to work with a temporary
variable, similar to how it is done in other parts of the kernel.

Fixes: 964c9dff0091 ("stackleak: Allow runtime disabling of kernel stack 
erasing")
Acked-by: Kees Cook 
Signed-off-by: Thomas Weißschuh 
---
 kernel/stackleak.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/stackleak.c b/kernel/stackleak.c
index 34c9d81eea94..b292e5ca0b7d 100644
--- a/kernel/stackleak.c
+++ b/kernel/stackleak.c
@@ -27,10 +27,11 @@ static int stack_erasing_sysctl(struct ctl_table *table, 
int write,
int ret = 0;
int state = !static_branch_unlikely(_erasing_bypass);
int prev_state = state;
+   struct ctl_table tmp = *table;
 
-   table->data = 
-   table->maxlen = sizeof(int);
-   ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+   tmp.data = 
+   tmp.maxlen = sizeof(int);
+   ret = proc_dointvec_minmax(, write, buffer, lenp, ppos);
state = !!state;
if (ret || !write || state == prev_state)
return ret;

-- 
2.44.0



[PATCH 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers

2024-03-15 Thread Thomas Weißschuh
* Patch 1 is a bugfix for the stack_erasing sysctl handler
* Patches 2-10 change various helper functions throughout the kernel to
  be able to handle 'const ctl_table'.
* Patch 11 changes the signatures of all proc handlers through the tree.
  Some other signatures are also adapted, for details see the commit
  message.

Only patch 1 changes any code at all.

The series was compile-tested on top of next-20230315 for
i386, x86_64, arm, arm64, riscv, loongarch and s390.

This series was split from my larger series sysctl-const series [0].
It only focusses on the proc_handlers but is an important step to be
able to move all static definitions of ctl_table into .rodata.

[0] 
https://lore.kernel.org/lkml/20231204-const-sysctl-v2-0-7a5060b11...@weissschuh.net/

Signed-off-by: Thomas Weißschuh 
---
Thomas Weißschuh (11):
  stackleak: don't modify ctl_table argument
  cgroup: bpf: constify ctl_table arguments and fields
  hugetlb: constify ctl_table arguments of utility functions
  utsname: constify ctl_table arguments of utility function
  neighbour: constify ctl_table arguments of utility function
  ipv4/sysctl: constify ctl_table arguments of utility functions
  ipv6/addrconf: constify ctl_table arguments of utility functions
  ipv6/ndisc: constify ctl_table arguments of utility function
  ipvs: constify ctl_table arguments of utility functions
  sysctl: constify ctl_table arguments of utility function
  sysctl: treewide: constify the ctl_table argument of handlers

 arch/arm64/kernel/armv8_deprecated.c  |   2 +-
 arch/arm64/kernel/fpsimd.c|   2 +-
 arch/s390/appldata/appldata_base.c|  10 +--
 arch/s390/kernel/debug.c  |   2 +-
 arch/s390/kernel/topology.c   |   2 +-
 arch/s390/mm/cmm.c|   6 +-
 arch/x86/kernel/itmt.c|   2 +-
 drivers/cdrom/cdrom.c |   6 +-
 drivers/char/random.c |   5 +-
 drivers/macintosh/mac_hid.c   |   2 +-
 drivers/net/vrf.c |   2 +-
 drivers/parport/procfs.c  |  14 ++--
 drivers/perf/arm_pmuv3.c  |   6 +-
 drivers/perf/riscv_pmu_sbi.c  |   2 +-
 fs/coredump.c |   4 +-
 fs/dcache.c   |   3 +-
 fs/drop_caches.c  |   4 +-
 fs/exec.c |   6 +-
 fs/file_table.c   |   3 +-
 fs/fs-writeback.c |   2 +-
 fs/inode.c|   3 +-
 fs/pipe.c |   2 +-
 fs/quota/dquot.c  |   4 +-
 fs/xfs/xfs_sysctl.c   |  33 -
 include/linux/filter.h|   2 +-
 include/linux/ftrace.h|   4 +-
 include/linux/mm.h|   8 +--
 include/linux/perf_event.h|   6 +-
 include/linux/security.h  |   2 +-
 include/linux/sysctl.h|  36 +-
 include/linux/vmstat.h|   6 +-
 include/linux/writeback.h |   2 +-
 include/net/ndisc.h   |   2 +-
 include/net/neighbour.h   |   6 +-
 include/net/netfilter/nf_hooks_lwtunnel.h |   2 +-
 ipc/ipc_sysctl.c  |  14 ++--
 kernel/bpf/syscall.c  |   4 +-
 kernel/delayacct.c|   5 +-
 kernel/events/callchain.c |   2 +-
 kernel/events/core.c  |   9 ++-
 kernel/fork.c |   2 +-
 kernel/hung_task.c|   7 +-
 kernel/kexec_core.c   |   2 +-
 kernel/kprobes.c  |   2 +-
 kernel/latencytop.c   |   5 +-
 kernel/pid_namespace.c|   4 +-
 kernel/pid_sysctl.h   |   2 +-
 kernel/printk/internal.h  |   2 +-
 kernel/printk/printk.c|   2 +-
 kernel/printk/sysctl.c|   6 +-
 kernel/sched/core.c   |  15 ++--
 kernel/sched/rt.c |  20 +++---
 kernel/sched/topology.c   |   6 +-
 kernel/seccomp.c  |   7 +-
 kernel/stackleak.c|  12 ++--
 kernel/sysctl.c   | 109 --
 kernel/time/timer.c   |   4 +-
 kernel/trace/ftrace.c |   2 +-
 kernel/trace/trace.c  |   2 +-
 kernel/trace/trace_events_user.c  |   3 +-
 kernel/trace/trace_stack.c|   2 +-
 kernel/umh.c  |   4 +-
 kernel/utsname_sysctl.c   |   6 +-
 kernel/watchdog.c |  15 ++--
 mm/compaction.c   |  17 +++--
 mm/hugetlb.c

[PATCH 07/11] ipv6/addrconf: constify ctl_table arguments of utility functions

2024-03-15 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 net/ipv6/addrconf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 247bd4d8ee45..c72f3b63e41d 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -862,7 +862,7 @@ static void addrconf_forward_change(struct net *net, __s32 
newf)
}
 }
 
-static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int newf)
+static int addrconf_fixup_forwarding(const struct ctl_table *table, int *p, 
int newf)
 {
struct net *net;
int old;
@@ -930,7 +930,7 @@ static void addrconf_linkdown_change(struct net *net, __s32 
newf)
}
 }
 
-static int addrconf_fixup_linkdown(struct ctl_table *table, int *p, int newf)
+static int addrconf_fixup_linkdown(const struct ctl_table *table, int *p, int 
newf)
 {
struct net *net;
int old;
@@ -6375,7 +6375,7 @@ static void addrconf_disable_change(struct net *net, 
__s32 newf)
}
 }
 
-static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)
+static int addrconf_disable_ipv6(const struct ctl_table *table, int *p, int 
newf)
 {
struct net *net = (struct net *)table->extra2;
int old;
@@ -,7 +,7 @@ void addrconf_disable_policy_idev(struct inet6_dev *idev, 
int val)
 }
 
 static
-int addrconf_disable_policy(struct ctl_table *ctl, int *valp, int val)
+int addrconf_disable_policy(const struct ctl_table *ctl, int *valp, int val)
 {
struct net *net = (struct net *)ctl->extra2;
struct inet6_dev *idev;

-- 
2.44.0



[PATCH 06/11] ipv4/sysctl: constify ctl_table arguments of utility functions

2024-03-15 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 net/ipv4/sysctl_net_ipv4.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 7e4f16a7dcc1..363dc2a487ac 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -130,7 +130,8 @@ static int ipv4_privileged_ports(struct ctl_table *table, 
int write,
return ret;
 }
 
-static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t 
*low, kgid_t *high)
+static void inet_get_ping_group_range_table(const struct ctl_table *table,
+   kgid_t *low, kgid_t *high)
 {
kgid_t *data = table->data;
struct net *net =
@@ -145,7 +146,8 @@ static void inet_get_ping_group_range_table(struct 
ctl_table *table, kgid_t *low
 }
 
 /* Update system visible IP port range */
-static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t 
high)
+static void set_ping_group_range(const struct ctl_table *table,
+kgid_t low, kgid_t high)
 {
kgid_t *data = table->data;
struct net *net =

-- 
2.44.0



[PATCH 03/11] hugetlb: constify ctl_table arguments of utility functions

2024-03-15 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 mm/hugetlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 23ef240ba48a..b0d89ab98eaa 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4929,7 +4929,7 @@ static unsigned int allowed_mems_nr(struct hstate *h)
 }
 
 #ifdef CONFIG_SYSCTL
-static int proc_hugetlb_doulongvec_minmax(struct ctl_table *table, int write,
+static int proc_hugetlb_doulongvec_minmax(const struct ctl_table *table, int 
write,
  void *buffer, size_t *length,
  loff_t *ppos, unsigned long *out)
 {
@@ -4946,7 +4946,7 @@ static int proc_hugetlb_doulongvec_minmax(struct 
ctl_table *table, int write,
 }
 
 static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
-struct ctl_table *table, int write,
+const struct ctl_table *table, int write,
 void *buffer, size_t *length, loff_t *ppos)
 {
struct hstate *h = _hstate;

-- 
2.44.0



[PATCH 08/11] ipv6/ndisc: constify ctl_table arguments of utility function

2024-03-15 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 net/ipv6/ndisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index ae134634c323..945d5f5ca039 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1936,7 +1936,7 @@ static struct notifier_block ndisc_netdev_notifier = {
 };
 
 #ifdef CONFIG_SYSCTL
-static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
+static void ndisc_warn_deprecated_sysctl(const struct ctl_table *ctl,
 const char *func, const char *dev_name)
 {
static char warncomm[TASK_COMM_LEN];

-- 
2.44.0



[PATCH 04/11] utsname: constify ctl_table arguments of utility function

2024-03-15 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 kernel/utsname_sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
index 019e3a1566cf..46590d4addc8 100644
--- a/kernel/utsname_sysctl.c
+++ b/kernel/utsname_sysctl.c
@@ -15,7 +15,7 @@
 
 #ifdef CONFIG_PROC_SYSCTL
 
-static void *get_uts(struct ctl_table *table)
+static void *get_uts(const struct ctl_table *table)
 {
char *which = table->data;
struct uts_namespace *uts_ns;

-- 
2.44.0



[PATCH 05/11] neighbour: constify ctl_table arguments of utility function

2024-03-15 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 net/core/neighbour.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 552719c3bbc3..1fb71107accf 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -3573,7 +3573,7 @@ static void neigh_copy_dflt_parms(struct net *net, struct 
neigh_parms *p,
rcu_read_unlock();
 }
 
-static void neigh_proc_update(struct ctl_table *ctl, int write)
+static void neigh_proc_update(const struct ctl_table *ctl, int write)
 {
struct net_device *dev = ctl->extra1;
struct neigh_parms *p = ctl->extra2;

-- 
2.44.0



[PATCH 09/11] ipvs: constify ctl_table arguments of utility functions

2024-03-15 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 net/netfilter/ipvs/ip_vs_ctl.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 143a341bbc0a..689ac521ea2d 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -1924,7 +1924,8 @@ proc_do_sync_ports(struct ctl_table *table, int write,
return rc;
 }
 
-static int ipvs_proc_est_cpumask_set(struct ctl_table *table, void *buffer)
+static int ipvs_proc_est_cpumask_set(const struct ctl_table *table,
+void *buffer)
 {
struct netns_ipvs *ipvs = table->extra2;
cpumask_var_t *valp = table->data;
@@ -1962,8 +1963,8 @@ static int ipvs_proc_est_cpumask_set(struct ctl_table 
*table, void *buffer)
return ret;
 }
 
-static int ipvs_proc_est_cpumask_get(struct ctl_table *table, void *buffer,
-size_t size)
+static int ipvs_proc_est_cpumask_get(const struct ctl_table *table,
+void *buffer, size_t size)
 {
struct netns_ipvs *ipvs = table->extra2;
cpumask_var_t *valp = table->data;

-- 
2.44.0



[PATCH 10/11] sysctl: constify ctl_table arguments of utility function

2024-03-15 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 include/linux/sysctl.h |  2 +-
 kernel/sysctl.c| 21 +++--
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index ee7d33b89e9e..99ea26b16c0d 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -238,7 +238,7 @@ extern struct ctl_table_header 
*register_sysctl_mount_point(const char *path);
 
 void do_sysctl_args(void);
 bool sysctl_is_alias(char *param);
-int do_proc_douintvec(struct ctl_table *table, int write,
+int do_proc_douintvec(const struct ctl_table *table, int write,
  void *buffer, size_t *lenp, loff_t *ppos,
  int (*conv)(unsigned long *lvalp,
  unsigned int *valp,
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 157f7ce2942d..93824d8a3636 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -205,7 +205,7 @@ static int _proc_do_string(char *data, int maxlen, int 
write,
return 0;
 }
 
-static void warn_sysctl_write(struct ctl_table *table)
+static void warn_sysctl_write(const struct ctl_table *table)
 {
pr_warn_once("%s wrote to %s when file position was not 0!\n"
"This will not be supported in the future. To silence this\n"
@@ -223,7 +223,7 @@ static void warn_sysctl_write(struct ctl_table *table)
  * handlers can ignore the return value.
  */
 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
-  struct ctl_table *table)
+  const struct ctl_table *table)
 {
if (!*ppos)
return false;
@@ -468,7 +468,7 @@ static int do_proc_douintvec_conv(unsigned long *lvalp,
 
 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
 
-static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
+static int __do_proc_dointvec(void *tbl_data, const struct ctl_table *table,
  int write, void *buffer,
  size_t *lenp, loff_t *ppos,
  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
@@ -541,7 +541,7 @@ static int __do_proc_dointvec(void *tbl_data, struct 
ctl_table *table,
return err;
 }
 
-static int do_proc_dointvec(struct ctl_table *table, int write,
+static int do_proc_dointvec(const struct ctl_table *table, int write,
  void *buffer, size_t *lenp, loff_t *ppos,
  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
  int write, void *data),
@@ -552,7 +552,7 @@ static int do_proc_dointvec(struct ctl_table *table, int 
write,
 }
 
 static int do_proc_douintvec_w(unsigned int *tbl_data,
-  struct ctl_table *table,
+  const struct ctl_table *table,
   void *buffer,
   size_t *lenp, loff_t *ppos,
   int (*conv)(unsigned long *lvalp,
@@ -639,7 +639,7 @@ static int do_proc_douintvec_r(unsigned int *tbl_data, void 
*buffer,
return err;
 }
 
-static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
+static int __do_proc_douintvec(void *tbl_data, const struct ctl_table *table,
   int write, void *buffer,
   size_t *lenp, loff_t *ppos,
   int (*conv)(unsigned long *lvalp,
@@ -675,7 +675,7 @@ static int __do_proc_douintvec(void *tbl_data, struct 
ctl_table *table,
return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
 }
 
-int do_proc_douintvec(struct ctl_table *table, int write,
+int do_proc_douintvec(const struct ctl_table *table, int write,
  void *buffer, size_t *lenp, loff_t *ppos,
  int (*conv)(unsigned long *lvalp,
  unsigned int *valp,
@@ -1023,8 +1023,9 @@ static int sysrq_sysctl_handler(struct ctl_table *table, 
int write,
 }
 #endif
 
-static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
-   int write, void *buffer, size_t *lenp, loff_t *ppos,
+static int __do_proc_doulongvec_minmax(void *data,
+   const struct ctl_table *table, int write,
+   void *buffer, size_t *lenp, loff_t *ppos,
unsigned long convmul, unsigned long convdiv)
 {
unsigned long *i, *min, *max;
@@ -1096,7 +1097,7 @@ static int __do_proc_doulongvec_minmax(void *data, struct 
ctl_table *table,
return err;
 }
 
-static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
+static int do_proc_doulongvec_minmax(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
unsigned long convdiv)
 {

-- 
2.44.0



Re: [next-20230705] kernel BUG mm/memcontrol.c:3715! (ltp/madvise06)

2023-07-06 Thread Thomas Weißschuh
On 2023-07-06 11:41:38+0530, Sachin Sant wrote:
> While running LTP tests (madvise06) on IBM Power9 LPAR booted with
> 6.4.0-next-20230705 following crash is seen
> 
> Injecting memory failure for pfn 0x3f79 at process virtual address 
> 0x7fff9b74
> Memory failure: 0x3f79: recovery action for clean LRU page: Recovered
> madvise06 (133636): drop_caches: 3
> [ cut here ]
> kernel BUG at mm/memcontrol.c:3715!
> Oops: Exception in kernel mode, sig: 5 [#1]
> LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=8192 NUMA pSeries
> Modules linked in: brd overlay exfat vfat fat xfs loop sctp ip6_udp_tunnel 
> udp_tunnel dm_mod nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib 
> nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat 
> nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 bonding ip_set tls rfkill 
> nf_tables libcrc32c nfnetlink sunrpc pseries_rng vmx_crypto ext4 mbcache jbd2 
> sd_mod t10_pi crc64_rocksoft crc64 sg ibmvscsi scsi_transport_srp ibmveth 
> fuse [last unloaded: init_module(O)]
> CPU: 10 PID: 133636 Comm: madvise06 Tainted: G O 6.4.0-next-20230705 #1
> Hardware name: IBM,8375-42A POWER9 (raw) 0x4e0202 0xf05 of:IBM,FW950.80 
> (VL950_131) hv:phyp pSeries
> NIP: c054ea88 LR: c028b2a8 CTR: c054e8d0
> REGS: c0029dd7b890 TRAP: 0700 Tainted: G O (6.4.0-next-20230705)
> MSR: 80029033  CR: 28008288 XER: 
> CFAR: c054e904 IRQMASK: 0 
> GPR00: c028b2a8 c0029dd7bb30 c1431600 c002bc978000 
> GPR04: c2b3b288 00010192  0001 
> GPR08: c000f9abb180 0002 c002bc978580  
> GPR12: c054e8d0 c0001ec53f00   
> GPR16:     
> GPR20: c0001b2e6578 00400cc0 7fff f000 
> GPR24: c0029dd7bd30  c0029dd7bd58 c0001b2e6568 
> GPR28: c0029dd7bde0 0001 0001 c0001b2e6540 
> NIP [c054ea88] mem_cgroup_read_u64+0x1b8/0x1d0
> LR [c028b2a8] cgroup_seqfile_show+0xb8/0x160
> Call Trace:
> [c0029dd7bb50] [c028b2a8] cgroup_seqfile_show+0xb8/0x160
> [c0029dd7bbc0] [c0673ba4] kernfs_seq_show+0x44/0x60
> [c0029dd7bbe0] [c05c4238] seq_read_iter+0x238/0x620
> [c0029dd7bcb0] [c0675064] kernfs_fop_read_iter+0x1d4/0x2c0
> [c0029dd7bd00] [c057fbac] vfs_read+0x26c/0x350
> [c0029dd7bdc0] [c058077c] ksys_read+0x7c/0x140
> [c0029dd7be10] [c0036900] system_call_exception+0x140/0x350
> [c0029dd7be50] [c000d6a0] system_call_common+0x160/0x2e4
> --- interrupt: c00 at 0x7fff9eb41484
> NIP: 7fff9eb41484 LR: 10008540 CTR: 
> REGS: c0029dd7be80 TRAP: 0c00 Tainted: G O (6.4.0-next-20230705)
> MSR: 8280f033  CR: 28002282 XER: 
> 
> IRQMASK: 0 
> GPR00: 0003 7fffc33de7d0 7fff9ec27300 0013 
> GPR04: 7fffc33e0aa0 1fff  0013 
> GPR08: 7fffc33e0aa0    
> GPR12:  7fff9ecca3a0   
> GPR16:  10035520 10035b90 100347a8 
> GPR20: 1002fb68 10063900 2000 1002fb68 
> GPR24:  004c 1002fa78 7fffc33e0aa0 
> GPR28: 0013  1fff 1fff 
> NIP [7fff9eb41484] 0x7fff9eb41484
> LR [10008540] 0x10008540
> --- interrupt: c00
> Code: 7fa34800 409effc4 7c0802a6 3861 f8010030 4bfffdfd e8010030 786383e4 
> 7c0803a6 4b6c 7c0802a6 f8010030 <0fe0> 7c0802a6 f8010030 0fe0 
> ---[ end trace  ]---
> pstore: backend (nvram) writing error (-1)
> 
> Kernel panic - not syncing: Fatal exception
> Rebooting in 10 seconds..
> 
> Git bisect points to following patch:
> 
> commit 29bf1eb7d2abbdfc24c4ef7acf7a51b72dc43d2b
> memcg: drop kmem.limit_in_bytes
> 
> Does the testcase madvise06 need an update?
> 
> 90 tst_res(TINFO, "\tCached: %ld Kb",
> 91 SAFE_READ_MEMINFO("Cached:") - init_cached);
> 92   
> 93 print_cgmem("memory.current");
> 94 print_cgmem("memory.swap.current");
> 95 print_cgmem("memory.kmem.usage_in_bytes”);  <<== this line. 
> 96 }
> 
> If I comment line 95 from the testcase, it completes successfully.

The handling for _KMEM was removed from mem_cgroup_read_u64()
incorrectly.
It is used by the still existing kmem.*usage*_in_bytes in addition to
the now removed kmem.*limit*_in_bytes.
(And kmem.max_usage_in_bytes, kmem.failcnt)

The testcase seems to be fine, it actually did its job.


Re: [PATCH 2/3] powerpc/book3e: remove #include

2022-11-26 Thread Thomas Weißschuh
On 2022-11-26 07:36+, Christophe Leroy wrote:
> Le 26/11/2022 à 06:10, Thomas Weißschuh a écrit :
>> Commit 7ad4bd887d27 ("powerpc/book3e: get rid of #include 
>> ")
>> removed the usage of the define UTS_VERSION but forgot to drop the
>> include.
> 
> What about:
> arch/powerpc/platforms/52xx/efika.c
> arch/powerpc/platforms/amigaone/setup.c
> arch/powerpc/platforms/chrp/setup.c
> arch/powerpc/platforms/powermac/bootx_init.c
> 
> I believe you can do a lot more than what you did in your series.

The commit messages are wrong.
They should have said UTS_RELEASE instead of UTS_VERSION.

Could the maintainers fix this up when applying?
I also changed it locally so it will be fixed for v2.

> List of files using UTS_VERSION :
> 
> $ git grep -l UTS_VERSION
> [..]

Thomas


[PATCH 1/3] firmware_loader: remove #include

2022-11-25 Thread Thomas Weißschuh
utsrelease.h is potentially generated on each build.
By removing this unused include we can get rid of some spurious
recompilations.

Signed-off-by: Thomas Weißschuh 
---
 drivers/base/firmware_loader/firmware.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/base/firmware_loader/firmware.h 
b/drivers/base/firmware_loader/firmware.h
index fe77e91c38a2..bf549d6500d7 100644
--- a/drivers/base/firmware_loader/firmware.h
+++ b/drivers/base/firmware_loader/firmware.h
@@ -9,8 +9,6 @@
 #include 
 #include 
 
-#include 
-
 /**
  * enum fw_opt - options to control firmware loading behaviour
  *

base-commit: 0b1dcc2cf55ae6523c6fbd0d741b3ac28c9f4536
-- 
2.38.1



[PATCH 2/3] powerpc/book3e: remove #include

2022-11-25 Thread Thomas Weißschuh
Commit 7ad4bd887d27 ("powerpc/book3e: get rid of #include 
")
removed the usage of the define UTS_VERSION but forgot to drop the
include.

Fixes: 7ad4bd887d27 ("powerpc/book3e: get rid of #include 
")
Signed-off-by: Thomas Weißschuh 
---
 arch/powerpc/mm/nohash/kaslr_booke.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/mm/nohash/kaslr_booke.c 
b/arch/powerpc/mm/nohash/kaslr_booke.c
index 0d04f9d5da8d..2fb3edafe9ab 100644
--- a/arch/powerpc/mm/nohash/kaslr_booke.c
+++ b/arch/powerpc/mm/nohash/kaslr_booke.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 
 struct regions {
unsigned long pa_start;
-- 
2.38.1



[PATCH 3/3] init/version.c: remove #include

2022-11-25 Thread Thomas Weißschuh
Commit 2df8220cc511 ("kbuild: build init/built-in.a just once") moved
the usage of the define UTS_VERSION to the file version-timestamp.c.

version-timestamp.c in turn is included from version.c but already
includes utsversion.h itself properly.

The unneeded include of utsversion.h from version.c can be dropped.

Fixes: 2df8220cc511 ("kbuild: build init/built-in.a just once")
Signed-off-by: Thomas Weißschuh 
---
 init/version.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/init/version.c b/init/version.c
index 01d4ab05f0ba..f117921811b4 100644
--- a/init/version.c
+++ b/init/version.c
@@ -15,7 +15,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 static int __init early_hostname(char *arg)
-- 
2.38.1



Re: [PATCH] macintosh/mac_hid.c: don't load by default

2022-11-14 Thread Thomas Weißschuh
On 2022-11-14 16:16-0800, Dmitry Torokhov wrote:
> On Tue, Nov 15, 2022 at 12:54:41AM +0100, Thomas Weißschuh wrote:
>> Cc Franz who wrote the driver originally.
>> (I hope I got the correct one)
>> 
>> Hi Dmitry,
>> 
>> On 2022-11-14 10:33-0800, Dmitry Torokhov wrote:
>>> On Sun, Nov 13, 2022 at 04:30:22AM +0100, Thomas Weißschuh wrote:
>>>> There should be no need to automatically load this driver on *all*
>>>> machines with a keyboard.
>>>> 
>>>> This driver is of very limited utility and has to be enabled by the user
>>>> explicitly anyway.
>>>> Furthermore its own header comment has deprecated it for 17 years.
>>> 
>>> I think if someone does not need a driver they can either not enable it
>>> or blacklist it in /etc/modprobe.d/... There is no need to break
>>> module loading in the kernel.
>> 
>> But nobody needs the driver as it is autoloaded in its current state.
>> Without manual configuration after loading the driver does not provide any
>> functionality.
>> 
>> Furthermore the autoloading should load the driver for a specific
>> hardware/resource that it can provide additional functionality for.
>> Right now the driver loads automatically for any system that has an input
>> device with a key and then just does nothing.
>> 
>> It only wastes memory and confuses users why it is loaded.
>> 
>> If somebody really needs this (fringe) driver it should be on them to load it
>> it instead of everybody else having to disable it.
> 
> The driver is not enabled by default, so somebody has to enable it in
> the first place. How did you end up with it?

My distro kernel configured it to be enabled as module.
So people who want to use it can do so. It would be nice if the rest of us
wouldn't have to care about it.

>> Furthermore the file has the following comment since the beginning of the git
>> history in 2005:
>> 
>> Copyright (C) 2000 Franz Sirl
>> 
>> This file will soon be removed in favor of an uinput userspace tool.
> 
> OK, that is a separate topic, if there are no users we can remove the
> driver. Do we know if this tool ever came into existence?

One interpretation of it is attached as "mac_hid_userspace.c".

> What I do not want is to break the autoload for one single driver
> because somebody enabled it without intending to use and now tries to
> implement a one-off.

Is an autoloaded driver that then does not (ever) automatically provide any
functionality not broken by definition?
It was enabled by the distro. Which seems correct, because maybe somebody will
use it.

Taken to an illogical extreme: If it is fine for modules to load automatically
even if they are not useful, why not just always load all available modules?


Maybe we can take the removal of the autoload as a first step of deprecation
and finally removal of the module.
To quote you:

"I'd rather we did not promote from drivers/macintosh to other platforms,
 but rather removed it. The same functionality can be done from
 userspace." [0]

>>>> Fixes: 99b089c3c38a ("Input: Mac button emulation - implement as an input 
>>>> filter")
>>>> Signed-off-by: Thomas Weißschuh 
>>>> ---
>>>>  drivers/macintosh/mac_hid.c | 2 --
>>>>  1 file changed, 2 deletions(-)
>>>> 
>>>> diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
>>>> index d8c4d5664145..d01d28890db4 100644
>>>> --- a/drivers/macintosh/mac_hid.c
>>>> +++ b/drivers/macintosh/mac_hid.c
>>>> @@ -149,8 +149,6 @@ static const struct input_device_id 
>>>> mac_hid_emumouse_ids[] = {
>>>>{ },
>>>>  };
>>>>  
>>>> -MODULE_DEVICE_TABLE(input, mac_hid_emumouse_ids);
>>>> -
>>>>  static struct input_handler mac_hid_emumouse_handler = {
>>>>.filter = mac_hid_emumouse_filter,
>>>>.connect= mac_hid_emumouse_connect,
>>>> 
>>>> base-commit: fef7fd48922d11b22620e19f9c9101647bfe943d
>>>> -- 
>>>> 2.38.1

Thanks,
Thomas

[0] https://lore.kernel.org/all/20170510004327.GA32584@dtor-ws/
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Userspace replacement for mac_hid.c from Linux.
 *
 * Copyright (C) 2022 Thomas Weißschuh
 */

/* cc $(pkg-config --cflags libevdev) $(pkg-config --libs libevdev) 
mac_hid_userspace.c -o mac_hid_userspace */

#define _GNU_SOURCE

#include 
#include 
#include 
#include 

#include 
#include 
#include 

static void update_name(struct libevdev *dev)
{
char *name;

Re: [PATCH] macintosh/mac_hid.c: don't load by default

2022-11-14 Thread Thomas Weißschuh
Cc Franz who wrote the driver originally.
(I hope I got the correct one)

Hi Dmitry,

On 2022-11-14 10:33-0800, Dmitry Torokhov wrote:
> On Sun, Nov 13, 2022 at 04:30:22AM +0100, Thomas Weißschuh wrote:
>> There should be no need to automatically load this driver on *all*
>> machines with a keyboard.
>> 
>> This driver is of very limited utility and has to be enabled by the user
>> explicitly anyway.
>> Furthermore its own header comment has deprecated it for 17 years.
> 
> I think if someone does not need a driver they can either not enable it
> or blacklist it in /etc/modprobe.d/... There is no need to break
> module loading in the kernel.

But nobody needs the driver as it is autoloaded in its current state.
Without manual configuration after loading the driver does not provide any
functionality.

Furthermore the autoloading should load the driver for a specific
hardware/resource that it can provide additional functionality for.
Right now the driver loads automatically for any system that has an input
device with a key and then just does nothing.

It only wastes memory and confuses users why it is loaded.

If somebody really needs this (fringe) driver it should be on them to load it
it instead of everybody else having to disable it.

Furthermore the file has the following comment since the beginning of the git
history in 2005:

Copyright (C) 2000 Franz Sirl

This file will soon be removed in favor of an uinput userspace tool.

>> Fixes: 99b089c3c38a ("Input: Mac button emulation - implement as an input 
>> filter")
>> Signed-off-by: Thomas Weißschuh 
>> ---
>>  drivers/macintosh/mac_hid.c | 2 --
>>  1 file changed, 2 deletions(-)
>> 
>> diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
>> index d8c4d5664145..d01d28890db4 100644
>> --- a/drivers/macintosh/mac_hid.c
>> +++ b/drivers/macintosh/mac_hid.c
>> @@ -149,8 +149,6 @@ static const struct input_device_id 
>> mac_hid_emumouse_ids[] = {
>>  { },
>>  };
>>  
>> -MODULE_DEVICE_TABLE(input, mac_hid_emumouse_ids);
>> -
>>  static struct input_handler mac_hid_emumouse_handler = {
>>  .filter = mac_hid_emumouse_filter,
>>  .connect= mac_hid_emumouse_connect,
>> 
>> base-commit: fef7fd48922d11b22620e19f9c9101647bfe943d
>> -- 
>> 2.38.1


[PATCH] macintosh/mac_hid.c: don't load by default

2022-11-13 Thread Thomas Weißschuh
There should be no need to automatically load this driver on *all*
machines with a keyboard.

This driver is of very limited utility and has to be enabled by the user
explicitly anyway.
Furthermore its own header comment has deprecated it for 17 years.

Fixes: 99b089c3c38a ("Input: Mac button emulation - implement as an input 
filter")
Signed-off-by: Thomas Weißschuh 
---
 drivers/macintosh/mac_hid.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index d8c4d5664145..d01d28890db4 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -149,8 +149,6 @@ static const struct input_device_id mac_hid_emumouse_ids[] 
= {
{ },
 };
 
-MODULE_DEVICE_TABLE(input, mac_hid_emumouse_ids);
-
 static struct input_handler mac_hid_emumouse_handler = {
.filter = mac_hid_emumouse_filter,
.connect= mac_hid_emumouse_connect,

base-commit: fef7fd48922d11b22620e19f9c9101647bfe943d
-- 
2.38.1