Re: git: 895e1c6567d9 - main - sysctl(9): Booleans: Fix old value length discovery
- In reply to: Olivier Certner : "git: 895e1c6567d9 - main - sysctl(9): Booleans: Fix old value length discovery"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 03 Feb 2026 23:38:16 UTC
In message <69827a46.18880.6ee8f9c8@gitrepo.freebsd.org>, Olivier Certner
write
s:
> The branch main has been updated by olce:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=895e1c6567d9561c86f8d20b47e92491
> 1bce989e
>
> commit 895e1c6567d9561c86f8d20b47e924911bce989e
> Author: Olivier Certner <olce@FreeBSD.org>
> AuthorDate: 2026-02-03 22:25:46 +0000
> Commit: Olivier Certner <olce@FreeBSD.org>
> CommitDate: 2026-02-03 22:43:49 +0000
>
> sysctl(9): Booleans: Fix old value length discovery
>
> When calling sysctl(3) with a null 'oldp', i.e., length discovery mode,
> 'oldix' can be equal to 'oldlen', and we should not fail.
>
> More generally, let SYSCTL_OUT() and SYSCTL_IN() handle corner cases,
> simply removing the comparisons between 'oldidx' and 'oldlen' and
> 'newidx' and 'newlen' done by hand as the test just after is an equality
> that does not require to know if 'idx' is smaller than 'len'.
>
> PR: 292917
> Reported by: cy
> Fixes: 406da392ef8d ("sysctl(9): Booleans: Accept integers to ea
> se knob conversion")
> Sponsored by: The FreeBSD Foundation
> ---
> sys/kern/kern_sysctl.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
> index dbe509b3e8e2..be0acb0a4a55 100644
> --- a/sys/kern/kern_sysctl.c
> +++ b/sys/kern/kern_sysctl.c
> @@ -1637,8 +1637,6 @@ sysctl_handle_bool(SYSCTL_HANDLER_ARGS)
> * the output buffer, we assume that the caller expected an 'int'
> * instead of a 'uint8_t'.
> */
> - if (req->oldidx >= req->oldlen)
> - return (ENOMEM);
> if (req->oldlen - req->oldidx == sizeof(int)) {
> int temp_int = temp;
>
> @@ -1655,8 +1653,6 @@ sysctl_handle_bool(SYSCTL_HANDLER_ARGS)
> * Conversely, if the input buffer has exactly 4 bytes to read,
> * use them all to produce a bool.
> */
> - if (req->newidx >= req->newlen)
> - return (ENOMEM);
> if (req->newlen - req->newidx == sizeof(int)) {
> int temp_int;
>
>
Thank you.
--
Cheers,
Cy Schubert <Cy.Schubert@cschubert.com>
FreeBSD UNIX: <cy@FreeBSD.org> Web: https://FreeBSD.org
NTP: <cy@nwtime.org> Web: https://nwtime.org
e**(i*pi)+1=0