net: unix: reject negative max_dgram_qlen values
Subsystems (6)
PATCH v3 1/1 net: unix: reject negative max_dgram_qlen values
net.unix.max_dgram_qlen is parsed as a signed int and copied to the u32 sock::sk_max_ack_backlog when an AF_UNIX socket is created. Consequently, a negative value such as -1 is accepted and converted to UINT_MAX. Since the receive queue length is also u32, its fullness check cannot become true for that limit.
max_dgram_qlen has no documented negative sentinel. Its existing signed interface represents nonnegative values only through INT_MAX; negative bit patterns are not a supported encoding for the upper half of the u32 consumer range.
Switch to proc_dointvec_minmax and make the established 0..INT_MAX input range explicit. This rejects negative values without adding new accepted values or changing the default and zero-value behavior. Very large valid values can still make the queue limit impractical to reach; this change corrects the input domain rather than imposing a new resource ceiling.
---
v3:
- Keep the signed backing type and preserve the established 0..INT_MAX userspace range instead of extending the interface to the full u32 range.
- Add an explicit INT_MAX upper bound and document the accepted range.
- Clarify that the change validates the input domain rather than imposing a practical resource ceiling.
v2: https://lore.kernel.org/netdev/[email protected]/
- Change the backing value and handler to unsigned.
v1: https://lore.kernel.org/netdev/[email protected]/
Documentation/networking/ip-sysctl.rst | 3 ++- net/unix/sysctl_net_unix.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)
Documentation/networking/ip-sysctl.rst +2 -1
@@ -3821,5 +3821,6 @@ l3mdev_accept - BOOLEAN max_dgram_qlen - INTEGER The maximum length of dgram socket receive queue - Default: 10 + Possible values: 0 - INT_MAX + Default: 10
net/unix/sysctl_net_unix.c +3 -1
@@ -19,7 +19,9 @@ static const struct ctl_table unix_table[] = { .data = &init_net.unx.sysctl_max_dgram_qlen, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_INT_MAX, }, };
Signature · 1 line
2.43.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Quoted 17 lines · Yingjie Wang
net.unix.max_dgram_qlen is parsed as a signed int and copied to the u32
sock::sk_max_ack_backlogwhen anAF_UNIXsocket is created. Consequently, a negative value such as -1 is accepted and converted toUINT_MAX. Since the receive queue length is also u32, its fullness check cannot become true for that limit.
max_dgram_qlenhas no documented negative sentinel. Its existing signed interface represents nonnegative values only throughINT_MAX; negative bit patterns are not a supported encoding for the upper half of the u32 consumer range.Switch to
proc_dointvec_minmaxand make the established 0..INT_MAX input range explicit. This rejects negative values without adding new accepted values or changing the default and zero-value behavior. Very large valid values can still make the queue limit impractical to reach; this change corrects the input domain rather than imposing a new resource ceiling.
Quoted 4 lines
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Assisted-by Codex:gpt-5Signed-off-by Yingjie Wang <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Fri, 16 Oct 2026 11:02:58 +0800 you wrote:
net.unix.max_dgram_qlen is parsed as a signed int and copied to the u32
sock::sk_max_ack_backlogwhen anAF_UNIXsocket is created. Consequently, a negative value such as -1 is accepted and converted toUINT_MAX. Since the receive queue length is also u32, its fullness check cannot become true for that limit.
Quoted 6 lines
max_dgram_qlenhas no documented negative sentinel. Its existing signed interface represents nonnegative values only throughINT_MAX; negative bit patterns are not a supported encoding for the upper half of the u32 consumer range.[...]
Here is the summary with links:
- [net,v3] net: unix: reject negative max_dgram_qlen values
https://git.kernel.org/netdev/net/c/1a4e7bc6e345
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html