Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Jan 2026 11:42:17 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Enji Cooper <ngie@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org, Anagh Verma <go4av05.pvtx@gmail.com>
Subject:   Re: git: f384784289db - main - kern_syscall_deregister: document syscall 0 no-op logic
Message-ID:  <aVzY-Tf5YRs4F_nP@kib.kiev.ua>
In-Reply-To: <695cbe7e.3daf1.20a5a762@gitrepo.freebsd.org>

index | next in thread | previous in thread | raw e-mail

On Tue, Jan 06, 2026 at 07:49:18AM +0000, Enji Cooper wrote:
> The branch main has been updated by ngie:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=f384784289dba13b90138a89d3df3a8ea063aff9
> 
> commit f384784289dba13b90138a89d3df3a8ea063aff9
> Author:     Anagh Verma <go4av05.pvtx@gmail.com>
> AuthorDate: 2026-01-06 07:42:56 +0000
> Commit:     Enji Cooper <ngie@FreeBSD.org>
> CommitDate: 2026-01-06 07:48:54 +0000
> 
>     kern_syscall_deregister: document syscall 0 no-op logic
>     
>     Document syscall #0 being handled specially in
>     `kern_syscall_deregister(..)`: it's a reserved syscall and not
>     dynamically registered, and hence does not need to be deregistered in
>     the function.
>     
>     Co-authored-by: ngie@
>     MFC after:      2 weeks
>     Differential Revision:  https://reviews.freebsd.org/D54326
> ---
>  sys/kern/kern_syscalls.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/sys/kern/kern_syscalls.c b/sys/kern/kern_syscalls.c
> index a93d711e7597..7ddc28ed4e26 100644
> --- a/sys/kern/kern_syscalls.c
> +++ b/sys/kern/kern_syscalls.c
> @@ -161,8 +161,14 @@ kern_syscall_deregister(struct sysent *sysents, int offset,
>  {
>  	struct sysent *se;
>  
> -	if (offset == 0)
> -		return (0); /* XXX? */
> +	if (offset == 0) {
> +		/*
> +		 * Syscall #0 is reserved and is not dynamically registered.
Syscall number zero is not reserved, it is the mux syscall.
It is indeed not dynamic, it is marked with the SY_THR_STATIC flag.

> +		 * Treat deregistration as a no-op to simplify module unload
> +		 * paths.
> +		 */
> +		return (0);
> +	}
>  
>  	se = &sysents[offset];
>  	if ((se->sy_thrcnt & SY_THR_STATIC) != 0)
This check for SY_THR_STATIC would catch it.

That said, what is the use of silencing the error from an erronous
attempt to deregister syscall handler not owned by caller?


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aVzY-Tf5YRs4F_nP>