diff mbox series

[3/3] tty: ldsic: fix tty_ldisc_autoload sysctl's proc_handler

Message ID 20241112131357.49582-4-nicolas.bouchinet@clip-os.org
State Superseded
Headers show
Series Fixes multiple sysctl proc_handler usage error | expand

Commit Message

Nicolas Bouchinet Nov. 12, 2024, 1:13 p.m. UTC
From: Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>

Commit 7c0cca7c847e ("tty: ldisc: add sysctl to prevent autoloading of
ldiscs") introduces the tty_ldisc_autoload sysctl with the wrong
proc_handler. .extra1 and .extra2 parameters are set to avoid other values
thant SYSCTL_ZERO or SYSCTL_ONE to be set but proc_dointvec do not uses
them.

This commit fixes this by using proc_dointvec_minmax instead of
proc_dointvec.

Fixes: 7c0cca7c847e ("tty: ldisc: add sysctl to prevent autoloading of ldiscs")
Signed-off-by: Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>
---
 drivers/tty/tty_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Lin Feng Nov. 13, 2024, 2:39 a.m. UTC | #1
Thanks!

Reviewed-by: Lin Feng <linf@wangsu.com>

On 11/12/24 21:13, nicolas.bouchinet@clip-os.org wrote:
> From: Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>
> 
> Commit 7c0cca7c847e ("tty: ldisc: add sysctl to prevent autoloading of
> ldiscs") introduces the tty_ldisc_autoload sysctl with the wrong
> proc_handler. .extra1 and .extra2 parameters are set to avoid other values
> thant SYSCTL_ZERO or SYSCTL_ONE to be set but proc_dointvec do not uses
> them.
> 
> This commit fixes this by using proc_dointvec_minmax instead of
> proc_dointvec.
> 
> Fixes: 7c0cca7c847e ("tty: ldisc: add sysctl to prevent autoloading of ldiscs")
> Signed-off-by: Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>
> ---
>  drivers/tty/tty_io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 407b0d87b7c10..f211154367420 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -3631,7 +3631,7 @@ static struct ctl_table tty_table[] = {
>  		.data		= &tty_ldisc_autoload,
>  		.maxlen		= sizeof(tty_ldisc_autoload),
>  		.mode		= 0644,
> -		.proc_handler	= proc_dointvec,
> +		.proc_handler	= proc_dointvec_minmax,
>  		.extra1		= SYSCTL_ZERO,
>  		.extra2		= SYSCTL_ONE,
>  	},
Jiri Slaby Nov. 13, 2024, 9:08 a.m. UTC | #2
On 12. 11. 24, 14:13, nicolas.bouchinet@clip-os.org wrote:
> From: Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>
> 
> Commit 7c0cca7c847e ("tty: ldisc: add sysctl to prevent autoloading of
> ldiscs") introduces the tty_ldisc_autoload sysctl with the wrong
> proc_handler. .extra1 and .extra2 parameters are set to avoid other values
> thant SYSCTL_ZERO or SYSCTL_ONE to be set but proc_dointvec do not uses
> them.
> 
> This commit fixes this by using proc_dointvec_minmax instead of
> proc_dointvec.
> 
> Fixes: 7c0cca7c847e ("tty: ldisc: add sysctl to prevent autoloading of ldiscs")
> Signed-off-by: Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

I hope noone managed to store 2+ to that sysctl yet...

thanks,
diff mbox series

Patch

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 407b0d87b7c10..f211154367420 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3631,7 +3631,7 @@  static struct ctl_table tty_table[] = {
 		.data		= &tty_ldisc_autoload,
 		.maxlen		= sizeof(tty_ldisc_autoload),
 		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
+		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
 	},