From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793772457; b=O34aN6KpZPIPhNvVtQQuhz9xRPfKdpHaT91qSqP76MCgx0JN6EsgAXSrBzRG6NhXB1QO dfSjdOZZFD67OHGirnZ0XXznrcDM0lhQ+fN6aKI40Qco3FIaRIlMs9PRaiT8CA3+Q8vvM NxGX1dr4yUgo4N+H19snCLr0y3i181fYA/3VbFzmjSD00D1+U7Sc8/TiJTREJMxsqiEyh uDkEWtjh1t4kqWbIvq+j6z/Ww3ldMvpT6ilRtBjg9NLpIQMKac04HUzgomWMhKgXL78mH E6cCyKQ2yzazaEFXkRMVXbi1V3B1Vm1dj3JCBRIYT3GPEzT6Av4pQoBVGP5Wzko/3vw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793772457; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=9kJziegiXF9ceVnU6QWNYLm7UZNmpZIr3z6LjOuG5MM=; b=x32we0yZh/8bdFEDYZQVZ41kRTrU/fxRSuqlD7Xq667mSY9CTyBBZSC0P5fnkinCDb2p LA8JbIl/79m8Onr6y5X3i/Xiah14vOd7uFtItJNfC9QI8oXaPncSYZgQImb043txVV202 ElF8yKsqrf8tkGqMAUCug+c8Fvu+e06wQx/W1mfhxn09nC2N3VOJ5kdqi/sVed9jTHvHw CXmzsIDC7ncemVsd6V/5DiLhsRui8PfBUvQTwt2S0HgIktMuQPHKo7ByjMfcYQdKzJLir S7w7WEObHZCMeoT+bnffIcvZe/9RRgdmWs1GUIfx/EnhmDfenNfVvRMfVVxSYPltflA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Ra+S0X9A; arc=none smtp.remote-ip=95.215.58.45 Received: from mta1.migadu.com (out-45.mta1.migadu.com [95.215.58.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09506606A31B for ; Wed, 4 Nov 2026 06:07:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 09506606A31B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Ra+S0X9A X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=9kJziegiXF9ceVnU6QWNYLm7UZNmpZIr3z6LjOuG5MM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793772455; v=1; x=1794377255; b=Ra+S0X9AvaQgofhcyfdRzvUXZFwcBv0tWagajL6DnS/XiOPR1F3E1x7N/DIIVW+GZe8Y23rq wbF9jWwFTXwV1Ips5dT+ljSs7OY+IJlz2xSmSa6TSeJcYuC6cg/oRM2dQP3ots/CByWG0reyDgv NoQQMZtGs+TkH7JLIcUnNQRc= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id a8b4b12a133bf9ce; Wed, 04 Nov 2026 06:07:34 +0000 X-Mizu-Trace-ID: a8b4b12a133bf9ce X-Migadu-Flow: FLOW_OUT Message-ID: <3f0c43dd-532f-4bef-afec-76b2ca6df0a3@linux.dev> Date: Wed, 4 Nov 2026 14:07:11 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v4 3/7] ipv6: mcast: convert ip6_mc_msfget() to sockopt_t To: Breno Leitao , David Ahern , Ido Schimmel , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , John Fastabend , Stanislav Fomichev , Shuah Khan , Eric Dumazet Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, david.laight.linux@gmail.com, kernel-team@meta.com References: <20261103-sockopt_expand_out_v2-v4-0-2d36da923578@debian.org> <20261103-sockopt_expand_out_v2-v4-3-2d36da923578@debian.org> From: Jiayuan Chen In-Reply-To: <20261103-sockopt_expand_out_v2-v4-3-2d36da923578@debian.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/3/26 7:01 PM, Breno Leitao wrote: > MCAST_MSFILTER reads its reply through ip6_mc_msfget(), reached from > do_ipv6_getsockopt() and from nowhere else. Convert it, and build the > sockopt_t at the call site for as long as the caller still carries a > sockptr_t pair. > > optlen only has to cover the fixed part, and the real reply size comes > from the gf_numsrc field inside it. Userspace relies on that, so > sockopt_expand_out() grows optval past optlen, for a user address only > and only far enough for the sources the socket has. > > ip6_mc_msfget() now advances over the fixed part and writes the source > list through iter_out. Its callers rewind by the reply length they > already compute, which is exactly what the callee consumed, and land > back where they used to write: offset 0 for the native reply, gf_fmode > for the compat one. > > ipv6_get_msfilter() and compat_ipv6_get_msfilter() only store *optlen > after their own copy succeeds, so a copy failure can't report a > changed length: -EINVAL, -EADDRNOTAVAIL and -EFAULT all leave the > caller's optlen word unchanged. > > The old code stored *optlen before writing the fixed part, so an > unwritable optlen word stopped the fixed part from being written. Now > the fixed part is written first. > > Acked-by: Stanislav Fomichev > Acked-by: Ido Schimmel > Signed-off-by: Breno Leitao Reviewed-by: Jiayuan Chen