From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796419395; b=OhdGrszzswLFmWX9wYcxpSUBrafxSmzzVtDxnuMyZbrNNSjOaDmPf+GshaR2OKOYPDTH S5xpf2qonWyYc1oBmQSXzM1ofV6CDoBa1UVw7HfWfyf/ELot4lFTr+zP0BiyAxu8Gxn9z coy9HyNHE/Ox1NfyraLtDuqbtQR+74AUtd1SpMLOJVQd9a8+azFupSjq8IIuOZKUA48lf G+Sn+9/Y+zntignK+IEMwcOc6kj3KaQzjRzib+hUhHNckAw+M4cApX2uScFEPsDKJlliV w182+osdBwQ9okZPIaROlKA94MTnROEML0fs4crhRvBQmgkq758ApanblkqWJznpDUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796419395; 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=MGMIIqk0PKDD9kqkxRcd2iydV6X08JSEWVS31HuC+UpqLlhZDD+TsOfMWqfijhu7vQnA B5h042JDwT01unFQAL7XgSRKhJAdfRJ+ciSCSm2J4e2/TAHBo8fAcmaTwad/47R4EKavS /PYdCiVdCT7yfNUhnx/NJiD6lZ9kLlIj5tNONZCR39JeVXHG6CZeXsyb9J+WgGzBlrOdF TZskJNx3YmAaXF6Rrc3VSy78bpsDniarGhsVpp5BT6D4eQTG3AJg03s5N6dZrIO0YRxAB +rEDCzVUFvuQYJPap31WvNYEhOx8qnOM7jT/sdN+Y7dh60OzYhf8iJ/duppUcny3WKg== 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.128.43 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 10297606A335 for ; Fri, 4 Dec 2026 21:23:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 10297606A335 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-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4b79502c27aso12685455e9.1 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=sn/ENZIQXJwbQNrssviCW2ORGCtDIXn8rdZRZyL9CTecCNTdtvEUSPMfZKrhwFocbG +jMPpyoPRdIzXTuaGWdXLQAcA1l7aLAltR/nCLR7xUXgtHEiBycwSwhoXNGs3ihcISuN n+haaZnO8HwW6fQ+zckzvdlfPad8AqKTgj6mFmNP/5O6kQJFQq673//oTSPyRhisU9oJ QyYYBh3mToLaWXZlcSpVcgkFFOVqrJwfA8mFnR+xAmkF6SUCtc4OP4zZbZiWNInfuDQn FCoF3hK+iY05BFcGOVP+UIVrgrGY+n6ls+6nxiqhJPXOxmltua8yw2fokG905xvf7Mgn 1CJw== X-Forwarded-Encrypted: i=1; AL+hErH3RqdcXZksjdKNpp+rWO+dkq7E99wudheW2sd2OZs+SpDP7/CiO3ecWRMsEUpKSF5Lz/PctRs=@vger.kernel.org X-Gm-Message-State: APuU4Z8FschO6GySHN3dZCgo+M1e6Evn1NGWUNAUgn32QxH/8XSplC5g wTSimKMPlY+Bz/cn/5ShSyB1JpRi0znDUjhlZ7av0Vynj0CWdNeOtZsj X-Gm-Gg: AZFdTZcZWtDKnQeUVTG0OvA8jG5tW7MsP/Y07QfsXaPoX+hu/iAJRXT6Ovq8whpOVHK gtVO4qZWgVuxpBqvTpoCvNTyBeOIr2bD5W7G2Oszipz4o3Qw8P9pBcqOZgFKjeTJRg00j5Gxzey z4lioX2uO7cAg1u0bFD+wClHSVez1Er1WDGI/FH9FzBAWmtjHs8l2ev/L5HE44Z6gUBbAVSzxvx NtNST7FkNu1Q0KDRiXHG/oHCfoBz0+Ze0d3jzj8SebpAmSRfbI7TOyA3ZkjMGk0X8n+VCFQgJXf ObgH7PTlJ09bPKItd1US8b1fglt1W2hcshss+bk7iipLhaiWKNVntaNTE+NClcCNZiBFoFtuhcV KM/CwQOPPrmkiQGVOJcUVlpfWLPV6VQIJdUSILQesTyff3f9zN3gBWx8lsNPCu5NScqmMmvyWUt SI28io2pEOalZsmpSMb71zn1aC2bZWRSPPbP7vDQ8lnIn8uHwHsatNjxFlvgKBlxFZYYO8yCytN ZQbJKIbAsgNmbUXbUHXzPO7/P1XIBhQkyTOwtiZ2/G9MHorBPTHwEyCLg9AlsOb2QZvk2EMc4Jf nWLZtf7XtSeO1XeeLW9Gg87oHpT44ywk5+8UJsZ+PqQgsfmA+VMOPtfzf4wWDlz/ 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: netdev@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 >