On 10/09, Breno Leitao wrote:
> This series continues the migration to sockopt_t, as described in [1].
> do_ip_getsockopt() and do_ipv6_getsockopt() are the last two switches
> still taking a sockptr_t pair, and everything they forward to now takes
> a sockopt_t, so convert them both.
> 
> Patch 1 settles what a negative optlen means on SOL_IPV6 before the
> conversion makes it matter. do_ip_getsockopt() rejects it, but
> do_ipv6_getsockopt() never has, and the int options answer it as 4.
> Treat it as 4, as David Laight suggested, instead of failing callers
> that rely on it.
> 
> Patch 2 fixes a latent bug in sockopt_expand_out() [2] itself: it caps
> the expansion at INT_MAX, but iov_iter_revert() refuses to unroll past
> the smaller MAX_RW_COUNT.
> 
> MCAST_MSFILTER has to move before the switches above it. It is the last
> option with the quirk sockopt_expand_out() was added for [2]: optlen only
> covers the fixed part, and the real reply size comes from the gf_numsrc
> field inside it. Patches 3 and 4 convert it on both families, and store
> the reply length only after the final copy succeeds, so a copy failure
> can't report a changed optlen.
> 
> Patches 5 and 6 convert the switches themselves. Each wrapper keeps its
> __user prototype and builds the sockopt_t, so the proto layer is
> untouched. ipv6_getsockopt() cannot use sockopt_init_user(), which
> rejects a negative optlen, so patch 6 moves the clamp of patch 1 up
> there and builds the sockopt_t after it.
> 
> Patch 7 grows the selftest with an ip and an ipv6 fixture, pinning the
> returned length, errno and reply bytes.
> 
> The temporary sockptr_t-to-sockopt_t glue can go away once the higher
> level callers take sockopt_t too. For now, the series keeps the proto
> callbacks unchanged and converts only the leaf helpers.
> 
> Link: 
> https://lore.kernel.org/all/[email protected]/ 
> [1]
> Link: 
> https://lore.kernel.org/all/[email protected]/
>  [2]
> 
> To: David Ahern <[email protected]>
> To: Ido Schimmel <[email protected]>
> To: David S. Miller <[email protected]>
> To: Eric Dumazet <[email protected]>
> To: Jakub Kicinski <[email protected]>
> To: Paolo Abeni <[email protected]>
> To: Simon Horman <[email protected]>
> To: Alexei Starovoitov <[email protected]>
> To: Daniel Borkmann <[email protected]>
> To: Andrii Nakryiko <[email protected]>
> To: Eduard Zingerman <[email protected]>
> To: Kumar Kartikeya Dwivedi <[email protected]>
> To: Martin KaFai Lau <[email protected]>
> To: Song Liu <[email protected]>
> To: Yonghong Song <[email protected]>
> To: Jiri Olsa <[email protected]>
> To: Emil Tsalapatis <[email protected]>
> To: Ihor Solodrai <[email protected]>
> To: John Fastabend <[email protected]>
> To: Stanislav Fomichev <[email protected]>
> To: Shuah Khan <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> To: Stanislav Fomichev <[email protected]>
> Cc: [email protected]
> 
> Signed-off-by: Breno Leitao <[email protected]>
> ---
> Changes in v2:
> - Treat a negative optlen as 4 instead of rejecting it with
>   -EINVAL as v1 did, per David Laight and Stanislav Fomichev. 
> - Fix sashiko findings
> - Link to v1: 
> https://patch.msgid.link/[email protected]

Acked-by: Stanislav Fomichev <[email protected]>

Reply via email to