Thread (10 messages) flat view 10 messages, 4 authors, 2d ago

Re: [PATCH net-next 1/2] net: add sockopt_expand_out()

From: David Laight <hidden>
Date: 2026-09-11 18:10:15
Also in: lkml

On Fri, 11 Sep 2026 09:09:22 -0700
Breno Leitao [off-list ref] wrote:
On Fri, Sep 11, 2026 at 08:56:23AM -0700, Stanislav Fomichev wrote:
quoted
On 09/10, Breno Leitao wrote:  
quoted
+	if (size <= iov_iter_count(&opt->iter_out))
+		return 0;
+
+	if (WARN_ON_ONCE(!iter_is_ubuf(&opt->iter_out)))
+		return -EINVAL;  
nit: if you end up re-spinning for some reason, maybe swap these two?  
I am not sure we want to swap these two. This is the reason:

1) The first check (size <= iov_iter_count(&opt->iter_out)), check if we
   need the "hack" or not.

   a) If we don't need the tack, then we are fine and this could be called
      from user or kernel.
   
   b) for the hack (which happens in the next line -- iov_iter_ubuf()), it
      needs to be ubuf.

So, this force kernel callers to use the right optlen, avoiding hitting
the same issue as userspace.
kernel users might need to specify both lengths.
That is the value of optlen and the length of the buffer.
For 99.9% of the calls they will be the same.

David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help