Re: [PATCH net-next v3 0/4] net: move .getsockopt away from __user buffers
From: Stanislav Fomichev
Date: Fri Apr 10 2026 - 11:19:15 EST
On 04/10, Breno Leitao wrote:
> Hello Stanislav,
>
> On Wed, Apr 08, 2026 at 10:02:36AM -0700, Stanislav Fomichev wrote:
> > On 04/08, Breno Leitao wrote:
> >
> > LGTM! Not sure what's your plan for the selftest? You wanna keep it
> > outside or maybe repost v4 with it?
>
> I'd be glad to include a selftest. I've already developed one covering both
> protocols in this series and can respin with it if you'd like.
>
> Test available at:
> https://github.com/leitao/linux/commit/2d9311947061f1baa43858f597dd6c54d7ccc5d2
>
> > Acked-by: Stanislav Fomichev <sdf@xxxxxxxxxxx>
>
> Thanks for the review and guidance.
Yes, yes, I did see the test, so let's add it? I'm thinking that we should
already have a lot of coverage from packetdrill tests, but things like
you convert (packet/can) are probably less covered.
> > I'm also not sure your unconditional 'copy-optlen-back' will work for every
> > proto, but I think we can put something into sockopt_t to make it avoid
> > the copy if needed in the future.
>
> Good point. I'd prefer not to over-engineer this now, but keep it
> straightforward to add later if needed. This could be easily achieved with
> something like:
>
> typedef struct sockopt {
> struct iov_iter iter_in;
> struct iov_iter iter_out;
> int optlen;
> + bool optlen_dirty; /* set by callback when optlen should be written back */
> } sockopt_t;
>
> Wrapper becomes:
>
> if (opt.optlen_dirty &&
> copy_to_sockptr(optlen, &opt.optlen, sizeof(int)))
> return -EFAULT;
>
> and the protocol callback would need to set
>
> opt->optlen_dirty = true;
>
> I don't think this is needed yet, and if we do need it, it would be better
> to review and commit them together, making the rationale clearer for
> future developers/LLM agents.
>
> What do you think?
Agreed, I was thinking along the same lines. We can add it when/if
needed. Since you wrap everything in sockopt_t it should be really
easy to extend later.