From 59f9d8c4bf6485a1143e2df514dea5060551a3ee Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Fri, 31 Jan 2025 17:02:17 -0800 Subject: [PATCH] nlm: set vnet(9) context in the NLM syscall With the kernel RPC binding moving to Netlink transport all clients need to have proper vnet(9) context set. This change will unlikely make NLM properly virtualized, but at least it will not panic on the default VNET when kernel is compiled with VIMAGE. Reviewed by: rmacklem Differential Revision: https://reviews.freebsd.org/D48555 --- sys/nlm/nlm_prot_impl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/nlm/nlm_prot_impl.c b/sys/nlm/nlm_prot_impl.c index 5275f4362a7..02b7383cd64 100644 --- a/sys/nlm/nlm_prot_impl.c +++ b/sys/nlm/nlm_prot_impl.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -1711,7 +1712,11 @@ sys_nlm_syscall(struct thread *td, struct nlm_syscall_args *uap) nlm_grace_threshold = time_uptime + uap->grace_period; nlm_next_idle_check = time_uptime + NLM_IDLE_PERIOD; - return nlm_server_main(uap->addr_count, uap->addrs); + CURVNET_SET(TD_TO_VNET(td)); + error = nlm_server_main(uap->addr_count, uap->addrs); + CURVNET_RESTORE(); + + return (error); } /**********************************************************************/