Re: [PATCH net] net: unix: reject negative max_dgram_qlen values
From: Yingjie Wang
Date: Sat Aug 29 2026 - 01:33:30 EST
On Fri, Aug 28, 2026 at 10:49 AM Kuniyuki Iwashima <kuniyu@xxxxxxxxxx> wrote:
> I'm not sure if this was intended, but passing -1 for sk_max_ack_backlog
> is known hacky config to get max, see __sys_listen_socket().
I checked this. In __sys_listen_socket(), a negative backlog is cast to
unsigned and capped to somaxconn; there are also in-tree tests using
listen(..., -1).
I could not find the same convention for max_dgram_qlen. It is not
documented or special-cased, and I found no in-tree user or test relying
on -1. The sysctl value is copied directly to the u32 sk_max_ack_backlog,
so -1 becomes UINT_MAX without the somaxconn cap.
> At least, this effectively limits the upper bound to half,
> sk_buff_head.qlen is also u32.
Good point. I'll change sysctl_max_dgram_qlen to unsigned int and use
proc_douintvec_minmax in v2, so negative writes are rejected while keeping
the full u32 range.
Thanks,
Yingjie