net/socket.c | 2 -- 1 file changed, 2 deletions(-)
do_sock_setsockopt() and do_sock_getsockopt() have been exported since
they were split out of the syscall handlers for io_uring to reuse.
io_uring is the only caller outside net/socket.c, and it is never
modular: cmd_net.o is built under obj-$(CONFIG_NET), and both CONFIG_NET
and CONFIG_IO_URING are bool. The declarations in <net/sock.h> are all
it needs, so no module has ever been able to use these exports.
Drop the symbol exports.
Fixes: 1406245c2945 ("net/socket: Break down __sys_setsockopt")
Fixes: 0b05b0cd78c9 ("net/socket: Break down __sys_getsockopt")
Suggested-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/all/20260819090439.GB9267@lst.de/
Signed-off-by: Breno Leitao <leitao@debian.org>
---
Changes in v2:
- s/export/exports/ in the commit message (hch)
- Link to v1: https://patch.msgid.link/20260819-hch_not_export-v1-1-af4b0de70e13@debian.org
---
net/socket.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index 63c69a0fa74e1..ba3eca4324e7b 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2371,7 +2371,6 @@ int do_sock_setsockopt(struct socket *sock, bool compat, int level,
out_put:
return err;
}
-EXPORT_SYMBOL(do_sock_setsockopt);
/* Set a socket option. Because we don't know the option lengths we have
* to pass the user mode parameter for the protocols to sort out.
@@ -2484,7 +2483,6 @@ int do_sock_getsockopt(struct socket *sock, bool compat, int level,
return err;
}
-EXPORT_SYMBOL(do_sock_getsockopt);
/*
* Get a socket option. Because we don't know the option lengths we have
---
base-commit: 564973a259ec76f2dad0853420e7034cc43994c4
change-id: 20260819-hch_not_export-908dcceab01f
Best regards,
--
Breno Leitao <leitao@debian.org>
On Fri, 21 Aug 2026 01:28:32 -0700 Breno Leitao wrote: > do_sock_setsockopt() and do_sock_getsockopt() have been exported since > they were split out of the syscall handlers for io_uring to reuse. > > io_uring is the only caller outside net/socket.c, and it is never > modular: cmd_net.o is built under obj-$(CONFIG_NET), and both CONFIG_NET > and CONFIG_IO_URING are bool. The declarations in <net/sock.h> are all > it needs, so no module has ever been able to use these exports. FTR I'd prefer this export (or something along these lines) to having to add individual helpers for every sockopt for in-kernel networking socket users. Maybe other maintainers disagree.
On Sat, Aug 22, 2026 at 12:39:57PM -0700, Jakub Kicinski wrote: > On Fri, 21 Aug 2026 01:28:32 -0700 Breno Leitao wrote: > > do_sock_setsockopt() and do_sock_getsockopt() have been exported since > > they were split out of the syscall handlers for io_uring to reuse. > > > > io_uring is the only caller outside net/socket.c, and it is never > > modular: cmd_net.o is built under obj-$(CONFIG_NET), and both CONFIG_NET > > and CONFIG_IO_URING are bool. The declarations in <net/sock.h> are all > > it needs, so no module has ever been able to use these exports. > > FTR I'd prefer this export (or something along these lines) to having > to add individual helpers for every sockopt for in-kernel networking > socket users. Maybe other maintainers disagree. Fair — you and Christoph disagree here, and the nvme-tcp series needs it modular. I'll park this until that settles. If we decide to keep it, I would suggest we change it to EXPORT_SYMBOL_GPL, at least. -- pw-bot: rejected
On Sat, 22 Aug 2026 12:39:57 -0700
Jakub Kicinski <kuba@kernel.org> wrote:
> On Fri, 21 Aug 2026 01:28:32 -0700 Breno Leitao wrote:
> > do_sock_setsockopt() and do_sock_getsockopt() have been exported since
> > they were split out of the syscall handlers for io_uring to reuse.
> >
> > io_uring is the only caller outside net/socket.c, and it is never
> > modular: cmd_net.o is built under obj-$(CONFIG_NET), and both CONFIG_NET
> > and CONFIG_IO_URING are bool. The declarations in <net/sock.h> are all
> > it needs, so no module has ever been able to use these exports.
>
> FTR I'd prefer this export (or something along these lines) to having
> to add individual helpers for every sockopt for in-kernel networking
> socket users. Maybe other maintainers disagree.
>
As a 'user' I'd re-instate the kernel_setsockopt() that was removed in 5.7
before sockptr_t was added in 5.8.
Before I retired I supported some code that contains:
int xxx_setsockopt(struct socket *sock, int level, int optname,
void *optval, unsigned int optlen)
{
sockptr_t koptval = KERNEL_SOCKPTR(optval);
if (level == SOL_SOCKET)
return sock_setsockopt(sock, level, optname, koptval, optlen);
else
return sock->ops->setsockopt(sock, level, optname, koptval, optlen);
}
I suspect both bpf and io_uring have to do the same.
The code does need one getsockopt() - SCTP_STATUS to get the negotiated
number of output streams, any code using SCTP needs to do that.
However that returns the wrong value for kernels 5.1 to 5.8 so the driver
digs the value out of the sctp internal data structures.
(Not exporting functions doesn't make much difference!)
David
On Fri, Aug 21, 2026 at 10:29 AM Breno Leitao <leitao@debian.org> wrote:
>
> do_sock_setsockopt() and do_sock_getsockopt() have been exported since
> they were split out of the syscall handlers for io_uring to reuse.
>
> io_uring is the only caller outside net/socket.c, and it is never
> modular: cmd_net.o is built under obj-$(CONFIG_NET), and both CONFIG_NET
> and CONFIG_IO_URING are bool. The declarations in <net/sock.h> are all
> it needs, so no module has ever been able to use these exports.
>
> Drop the symbol exports.
>
> Fixes: 1406245c2945 ("net/socket: Break down __sys_setsockopt")
> Fixes: 0b05b0cd78c9 ("net/socket: Break down __sys_getsockopt")
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Link: https://lore.kernel.org/all/20260819090439.GB9267@lst.de/
> Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
© 2016 - 2026 Red Hat, Inc.