From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796419396; b=QIG6Q8Ri9xvW5KD/NMp+UFFxJeN/pem81TANA1YW3rv5YPnAe4w5J3mpkIduV07uNgAC ym6n9SdoIdBHKdlF5QfqswJJkNAu3KXqcfcRl0nbOHnjcrXbe4hvf2+lIRYjWPeo1BS+a LY6SVa/3fE4ifZ0S6RxAK3kZvFEjzexfVlPa0BL5yU60T0sGh++JqAnQwYEWG++U2dVZz AoQ4D0Oc1UHQ7Q8wlK5puKWbaK3ykU8pE48lp6reJXo+ZwC2zNmFczei7m8q4CvqtfI1t wBSmmXYzxUALosUIzaopkvPrcpdDsbWTN5+0SmcmBExJRKuN7TMuCJEoc/Wj1fZ0WdQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796419396; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=/xDSB4a6OVN7MA1jUOAUsREdRok+Z/Dikmcd3dUg+f8=; b=KtB6D1NZFmjj2zjzGP4dMfjZJeKiIwkOaCwR/Jvdanx4TpZzgS2B70VW8sfQy18FjNeY geJ0KKDjP2ImuRM44r3fGVmF+MH/QQZ7dWRS6vKocjo2VKNPSN/yYviAu3fgvneY64YhI khtjmiqsu6Lcb5ckNkjDkDn1Tc6pqdUcOI47wJeElaFAyj+1/wgNYEFg84ft4bXv2AdEI M48WXmThWu6fQVQDGfjfVaiRZ/sc4N3hHX9voz6CO08Iadp2X8ipQ5iW44c2Sm6N5kO4c jczuUok+xyhOOugvqGof/x3X04pfo6kCCSEcDF/rZSkp5W5BuFbcsjatX/pyUEfnCsg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=JfnfcA3J; arc=none smtp.remote-ip=209.85.221.53 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 08F34606A680 for ; Fri, 4 Dec 2026 21:23:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 08F34606A680 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=JfnfcA3J Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-48e3b22e971so730447f8f.0 for ; Fri, 04 Dec 2026 13:23:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796419393; x=1797024193; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=/xDSB4a6OVN7MA1jUOAUsREdRok+Z/Dikmcd3dUg+f8=; b=JfnfcA3JUyAFiyiycte9aIQQTWv0fqqudB6kE6ax5os3leBS/ak5frH3+k+qul4Tv2 ARV0yLH74/5/S0jNQvwS8KL/hIBuXW76quSVVGmUXFkDC1bIXXppynHPqgJmHTJqbAQW 98EXCTlJrC3YqAOTwNeqtoquotsNfE/RPhUmNWj32LrmC4p6LM16jg8KJJhDZJjVlvSm 8SscH5ciPOGqv7/9Uc9CFpFgWQh0zpVDp2HnCM5KGNu93ZdbNk7CD9ICe7UjGStUxjaH eHlTIvSZSB25vUXV0YE/o0pS2DUtLm3UEj2Fv5ZYSyPyeBRarQV6/m5/nc/hVKHN5tjw Cx/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796419393; x=1797024193; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/xDSB4a6OVN7MA1jUOAUsREdRok+Z/Dikmcd3dUg+f8=; b=wO0gOmuF8YtwcZbWHjlKUJuQ0AG0Lu8+U/cuCjEG9zFT81SfHxPrhIsIPX96Wk9W9G Y5ixizzBsTMsACoMMhFLOdBwT8F7sJTdKz0AxB5lJTXmVP/S41T5pPn5ogLsDvnXlDK3 YEnjiyXCoVFNxmnxiaiV7z0vG8FmXoDNf/b8LQutCh/0A32egeS1sMZKXOBvXuzDQ8Uv GV+19K+8vgt28Kj74fhMTdAdQPeBfmNIaKRYCjyiIMxCaes3kFY+IuLgtetpJt11fiZr jlwUWJeJ4chOkfWaX1pF57wD0a1qJi0UxAzF79ETwDSY8BaZULxDKFUv4YFuJLgagN1v VKyg== X-Forwarded-Encrypted: i=1; AL+hErEueHTQgCdd+axAr1wSuwGao1qCmD4v9Ah8zYcut70gqJUlonupkO2EN9bO1XoM37ilkDw=@vger.kernel.org X-Gm-Message-State: APuU4Z+3yTN4jr5jnaNLWyTP8hFvwpP5Idd2Fm2FeI/P7aCC/EuMmieZ cNNRiLZ/iW8xD+/yh7EDGKxN7yFALmt3CnPF/7BwJPX+MKIfz2/czlrr X-Gm-Gg: AZFdTZekNSLnA6FPjZRdndZxcS1RCO2XTgCFC7vDNE5+LOcVAbDrYKj1Fef5E9/FpQN CYeDf+P4v0unyGwZlPs8hLS73XHajiVRY1LgVUPY9FgvkudnBdIYVi6XmZMJUz+Mmv9jg5koXsZ ZSY4xsR3/sNZgO+umIuNsU2j+kqH6JJUtgxmgiUnPAbpSrS+Z3EPftQ1C4QkH/zba5tmz3agsmV 48uUr/hAykvAVlLnCV8EiRHmmGTInOjN/WQ265KoclHaBgTQ8mjghUo97Ys8cxVeH2bcJfjn7wF 1XJxkM7Zbu7ByvETQKdDS3AunKufLG/8R8wTlsq1wDzbdeCc0scN8WIXOIYqnQoJy2NwzSghSvl jy5E3lR9rC9h9KFx2w3+Rq1yC7cZqY/84u6oyP7m47b4Ce+VWBRTWPcMrcZI4mSq/Lz4ZTBg61z FVR3461gDn293bLWJb/q1RrJHMGtqjY6ufwPOmuxvEmCHUj2apgClwMJj3T8PHplblG32ZTnOdE 7Ersqod9pZhCXdfQTqtD5ldlyKhW2jq7OMEZwUHoBg29EOQG8NY+A4qIcDEL40HbBS8AWO0jhRZ 4maMDFZlHhosQazxtrJNRZsWslOHqGwwU7l2tPzoOMkwPx0G/9f7pqy5nH5YoAIt X-Received: by 2002:a05:600c:628b:b0:4bb:8711:fee8 with SMTP id 5b1f17b1804b1-4bbeb8d43f9mr58103275e9.20.1796419393201; Fri, 04 Dec 2026 13:23:13 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbf1690444sm7457795e9.0.2026.12.04.13.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 13:23:12 -0800 (PST) Date: Fri, 4 Dec 2026 21:23:10 +0000 From: David Laight To: Simon Horman Cc: Xuanqiang Luo , netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , Matthieu Baerts , Mat Martineau , Geliang Tang , David Ahern , Ido Schimmel , Stanislav Fomichev , Neal Cardwell , Kuniyuki Iwashima , Pablo Neira Ayuso , Florian Westphal , Phil Sutter , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, mptcp@lists.linux.dev, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, Xuanqiang Luo Subject: Re: [PATCH net-next v1 0/6] net: avoid stack canaries in TCP/IPv4 fast paths Message-ID: <20261204212310.6be06d4e@pumpkin> In-Reply-To: <20261204170246.GA192805@horms.kernel.org> References: <20261124130631.1886963-1-xuanqiang.luo@linux.dev> <20261126102058.1fecf50f@pumpkin> <20261127104100.3c915088@pumpkin> <20261204170246.GA192805@horms.kernel.org> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 4 Dec 2026 17:02:46 +0000 Simon Horman wrote: > On Fri, Nov 27, 2026 at 10:41:00AM +0000, David Laight wrote: > > On Fri, 27 Nov 2026 15:33:15 +0900 > > Xuanqiang Luo wrote: > > > > > On 2026/11/26 at 19:20 David Laight wrote: > > > > On Tue, 24 Nov 2026 22:06:25 +0900 > > > > Xuanqiang Luo wrote: > > > > > > > >> From: Xuanqiang Luo > > > >> > > > >> With CONFIG_STACKPROTECTOR_STRONG=y, a function that has a local array or > > > >> passes the address of one of its locals to another function needs a stack > > > >> canary. The canary is set up and checked on every call, also when the > > > >> local is only used on a path that almost never runs. > > > >> > > > >> This series removes the canary from functions of the TCP/IPv4 fast paths, > > > >> by returning results by value, by using storage that is not on the stack, > > > >> or by not calling a function that has nothing to do. > > > >> > > > >> Patch 1 returns the two mptcp_space() values in a structure, so that > > > >> __tcp_select_window() no longer needs a canary. > > > > > > > > While all (I think) architectures can return a big integer in two > > > > registers (dx:ax on x86), not all ABI do the same for small structures. > > > > For those architectures returning a struct by value is implemented by > > > > passing the address of a hidden on stack structure. > > > > So code generation may be worse than passing the values by reference. > > > > I can't remember the list of architectures, mostly old ones - but not > > > > 32bit x86 because the compiler option was set when regparm=3 was added > > > > for 2.6. > > > > (Note that this is different from passing small structures by value.) > > > > > > > > David > > > > > > Hi David, > > > > > > Good point! thanks for bringing that up. > > > > > > The small-struct-by-value pattern in patches 1 and 4 follows the same > > > approach Eric used in commit 7a4cd71fa451 ("net: add > > > vlan_get_protocol_offset_inline() helper"), which returns a 2-field > > > struct vlan_type_depth to avoid stack canaries in callers. > > > > > > I did note the 8-byte struct ABI distinction you mentioned: > > > - On the main 64-bit targets (x86_64, arm64, riscv64, ppc64le, loongarch64) > > > as well as 32-bit x86 (with -mregparm=3 / reg-struct-return), both > > > 8-byte structs (struct mptcp_space_info and struct skb_coalesce_res) are > > > returned in registers and the stack canaries are dropped cleanly. > > > - On ABIs that return structs (> 4 bytes on 32-bit ARM EABI, or any struct > > > on s390x) via a hidden stack buffer, it indeed falls back to a hidden > > > pointer. Even there, the callers previously passed *two* pointers to > > > locals (&space/&full_space in patch 1, &fragstolen/&delta_truesize in > > > patch 4), so passing one hidden 8-byte return slot should not be worse > > > than before, while keeping the code cleaner and type-safe. > > > > There might be a subtle difference in the function itself. > > I think the result structure gets allocated on stack and then a memcpy() > > used to copy that to the caller's buffer during the function return. > > That may, or may not, be faster. > > > > > > > > That said, if maintainers prefer packing the two fields into a u64 so that > > > even 32-bit ARM / s390x return them in registers, I'd be happy to change > > > patches 1 and 4 to do that in v2. > > > > That is horrid ... and you'd need to use a u128 on 64bit. > > It really is a shame that C doesn't have a syntax for returning 2 integers > > even though pretty much all ABI have always supported it. > > I think this patch-set takes the right approach. Quite likely - but it ought to have been mentioned. David > > For the series: > > Reviewed-by: Simon Horman >