-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linux 6.11: avoid passing "end" sentinel to register_sysctl()
Signed-off-by: Rob Norris <[email protected]> Sponsored-by: https://despairlabs.com/sponsor/
- Loading branch information
Showing
3 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ | |
* | ||
* Solaris Porting Layer (SPL) Proc Implementation. | ||
*/ | ||
/* | ||
* Copyright (c) 2024, Rob Norris <[email protected]> | ||
*/ | ||
|
||
#include <sys/systeminfo.h> | ||
#include <sys/kstat.h> | ||
|
@@ -694,6 +697,37 @@ static void spl_proc_cleanup(void) | |
} | ||
} | ||
|
||
#ifndef HAVE_REGISTER_SYSCTL_TABLE | ||
|
||
/* | ||
* Traditionally, struct ctl_table arrays have been terminated by an "empty" | ||
* sentinel element (specifically, one with .procname == NULL). | ||
* | ||
* Linux 6.6 began migrating away from this, adding register_sysctl_sz() so | ||
* that callers could provide the size directly, and redefining | ||
* register_sysctl() to just call register_sysctl_sz() with the array size. It | ||
* retained support for the terminating element so that existing callers would | ||
* continue to work. | ||
* | ||
* Linux 6.11 removed support for the terminating element, instead interpreting | ||
* it as a real malformed element, and rejecting it. | ||
* | ||
* In order to continue support older kernels, we retain the terminating | ||
* sentinel element for our sysctl tables, but instead detect availability of | ||
* register_sysctl_sz(). If it exists, we pass it the array size -1, stopping | ||
* the kernel from trying to process the terminator. For pre-6.6 kernels that | ||
* don't have register_sysctl_sz(), we just use register_sysctl(), which can | ||
* handle the terminating element as it always has. | ||
*/ | ||
#ifdef HAVE_REGISTER_SYSCTL_SZ | ||
#define spl_proc_register_sysctl(p, t) \ | ||
register_sysctl_sz(p, t, ARRAY_SIZE(t)-1) | ||
#else | ||
#define spl_proc_register_sysctl(p, t) \ | ||
register_sysctl(p, t) | ||
#endif | ||
#endif | ||
|
||
int | ||
spl_proc_init(void) | ||
{ | ||
|
@@ -704,16 +738,17 @@ spl_proc_init(void) | |
if (spl_header == NULL) | ||
return (-EUNATCH); | ||
#else | ||
spl_header = register_sysctl("kernel/spl", spl_table); | ||
spl_header = spl_proc_register_sysctl("kernel/spl", spl_table); | ||
if (spl_header == NULL) | ||
return (-EUNATCH); | ||
|
||
spl_kmem = register_sysctl("kernel/spl/kmem", spl_kmem_table); | ||
spl_kmem = spl_proc_register_sysctl("kernel/spl/kmem", spl_kmem_table); | ||
if (spl_kmem == NULL) { | ||
rc = -EUNATCH; | ||
goto out; | ||
} | ||
spl_kstat = register_sysctl("kernel/spl/kstat", spl_kstat_table); | ||
spl_kstat = spl_proc_register_sysctl("kernel/spl/kstat", | ||
spl_kstat_table); | ||
if (spl_kstat == NULL) { | ||
rc = -EUNATCH; | ||
goto out; | ||
|