Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp538259lqt; Thu, 6 Jun 2024 10:30:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtMMHF1YyNIyPyg83N4tTgp7pIZQDDi3U0KoQONOsrv4KwqK2F3ijqACtj2QgOSF0lZ5zYwVW7+pljIRzPIUpayqTJXoh9M/HZM8UIBw== X-Google-Smtp-Source: AGHT+IGY+ezFMgK6MWoztkBCiQo+zfkMTBvLUJQfQ8xf4oB700e7LWzS50wX0a53wi6p38t4/HPM X-Received: by 2002:a05:6a00:982:b0:6f3:e9bc:7ed5 with SMTP id d2e1a72fcca58-7040c5fee9fmr130482b3a.4.1717695046764; Thu, 06 Jun 2024 10:30:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717695046; cv=pass; d=google.com; s=arc-20160816; b=NtGSQwYqkiQ7y/XhFjb5FoMX8KLOSUU0Lgk96pATuI/IIaEEM+N1jQOokyIYV2Vpgd cgqZ40BRLMTCtD9ZjHUNagy6R4BsfPekeuNhsLqvYIiS7Blgpwjq6Ntfxje2p7cIqS4l QPq+EzELYe8q0bdg91nZsYg+1QyvTiQ8mNBlA5y2mSQvl3WmRK/1yWxmDZOGF36I9RRn +038WcD37tesGi23uvZ2DhB+XSDP5QVns/oPM2JxWzrF3XZ3sKaQ0o7AGLYhjGbkCFHz 0SMgCCHztBA8RcyNn0tv+jlHE48EqG8I3Yo+Momp+d67xExu7eSAw09b5I9j0cJvtd4O wSjg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=kXklq3VgB30R+o4fq7okdZC1G76cerOH8ymTCu7s03o=; fh=49zp9cLZ2xEsW+Ki7W1Ooo4v0OUuFkzEwp2Zhkzn4HM=; b=ERR+5eJm13fMuioSL2uEyfbdSYGo0nRWjE7tcfWeGnxd7CrS6rx5/gdWqDAdQ8S7di dnfhxWQLKhhi0usMIpG/s2aGPAiM9VsI9S42iSfhTuTIeimyuVBXZAf2AZZ5S+jubk/W nveldlshSe9mbmBVgVUUlViqgFSn8lU3eTzjIam6zu4ifaUiF9+KJK1X4D/Q8OM3Rnyh DWI5DVsRxusprwH5BeKQPtsu14slmjva4rtImpc4EwxYabS26ko5xHbzsoDKcLCTKVqY 6nELGQeIxfcpUkeX+VUjQ1fzmnmdU06zeqCfNGrWb5v3GsbleRta2Hss9Qjx7S6fqfAN xNlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FJhdTGIx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-204730-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204730-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-703fd4c5c5asi1427851b3a.168.2024.06.06.10.30.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 10:30:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204730-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FJhdTGIx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-204730-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204730-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B387FB28C5D for ; Thu, 6 Jun 2024 16:50:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E9C11990C6; Thu, 6 Jun 2024 16:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FJhdTGIx" Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2ED3C198A3E for ; Thu, 6 Jun 2024 16:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717692594; cv=none; b=mYQXGkDV2Q53AxGRaXYemMhZ+d/hch6zVdc2Y4ozaIv76MpfcpkT5A6IFTEG2v89AQQmCokiw4OhHdyUOxBywSWFMgHyNFqxhAZVUGeHJ1q9d6uc4yuod8ktU0a8HriuklZ68x2OPiw2JUtWfGSmn/8pysBqPyCRjtRi/wxynIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717692594; c=relaxed/simple; bh=QlINFaI4LTvEN0VfK5cNmlEbpI0ZCm9ojcKkqo+H+CY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=necRZ4Itlq/fWWQAWQR3s4PJI4B58aLTZyb+pUBIHvUTwSbZkrJuDIgJQ2u4eLcF/ptHoRE0mjf1fCBgXTLaC4hCV9EVUY0EkoGO41/KkhU0gGJ4tWKL5txmtBRO9xen3/x1vu/917bYAk+zRJO6wlyn8+h/kOVljn9ND5Wu+zo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FJhdTGIx; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a68b54577aaso149647566b.3 for ; Thu, 06 Jun 2024 09:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717692590; x=1718297390; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kXklq3VgB30R+o4fq7okdZC1G76cerOH8ymTCu7s03o=; b=FJhdTGIxctQIk6xOF7Zd1CW+slog1vE6ixCwSs90XTWdHvLrBkGDpnZvoFXFyz1T1o V4F8vhBb8Z9pLu4Hey3uN7SpOw98HEw5zZfZg9nMeeIq15SzcDrkfc3yFfMIQ7cGDLhS uzuog7ycVldhDgR/tnY8wgKRLn4ZW48PynK4NO30CtEOjuoJprXwbn/n4AAzAzVSv1eV YT0AOV+hEMO0OE5fYOn1IKcOU5GzjY3ixs74XLG4XOqY9urvq4k+mtpko+C7uMZ+/mT5 RJdnLuvYqSwOku/GHAfZY23nQtqTtYRUtFX7oZeCPiXA05AnDfx9g6sPjP2AepkKYJom UYfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717692590; x=1718297390; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kXklq3VgB30R+o4fq7okdZC1G76cerOH8ymTCu7s03o=; b=tP4ILXhJHRACb7lfJMhxAoHl91eenMM7pfoOnDgTISvU4VI8y3/I+PJ3+gvLVEsr9/ dCLMDemaIT8iNp5capnap/FHKy53C8isRuZlNbhOI1IeYQ3q9Peane6YcF3dvWriimtS ZqYr8fNCKU4d5IjpfsI9BzaTvmrnzjKIpzuVrUPSLnImtj6CFxkLNJLue9tCImHuW3Jc zDD3kZRc0vBye7aMVtxCmoMsEdLeNnqI4RDIsfQoisOI4cPWGFZ9WGQL3q/g3jo8EfAP +B6V9zcZN1GOiXyvGPrpUxQb+GN0gPwObNC9wAjmyScjJvbgSm+8ke+uEf7Q87184gmw MOhQ== X-Forwarded-Encrypted: i=1; AJvYcCUnI6rHRbUjFNs1QvvLlgvdVlJTZxAVG49RgfoAHvOw8OaeNkbYVcRqUrI0aAt5mAH7LxMNxFtLekN92rz6DUnfpM7XRwX864IJdTCz X-Gm-Message-State: AOJu0YzhH66NO/cnh91asWTyRkAl++IolrR+tomlOYwikQ6B/J1Z+HqJ gtYmqEWX3fFUBfJ9Sk7vwXdF4Dbi2dCAzP05kgEKgRLcgEY4QJ5Q4g31WKeWJXPMQGm5gZbX04+ UPlGP+PtF8AbiLtFpW1S975YkqyVRDgpIdyx2CkRto8Pe3THiEiKI4jg9tA== X-Received: by 2002:a17:907:7786:b0:a68:c9fa:f19f with SMTP id a640c23a62f3a-a6cdb0f542cmr7959966b.53.1717692590194; Thu, 06 Jun 2024 09:49:50 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240530201616.1316526-1-almasrymina@google.com> <20240530201616.1316526-11-almasrymina@google.com> <84162ef4c695cb764454087ca0bc81082d4fac8d.camel@redhat.com> In-Reply-To: <84162ef4c695cb764454087ca0bc81082d4fac8d.camel@redhat.com> From: Mina Almasry Date: Thu, 6 Jun 2024 09:49:38 -0700 Message-ID: Subject: Re: [PATCH net-next v10 10/14] net: add support for skbs with unreadable frags To: Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Donald Hunter , Jonathan Corbet , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Andreas Larsson , Jesper Dangaard Brouer , Ilias Apalodimas , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Arnd Bergmann , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Steffen Klassert , Herbert Xu , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Pavel Begunkov , David Wei , Jason Gunthorpe , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi , Willem de Bruijn , Kaiyuan Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jun 4, 2024 at 3:46=E2=80=AFAM Paolo Abeni wrot= e: > > On Thu, 2024-05-30 at 20:16 +0000, Mina Almasry wrote: > > diff --git a/net/core/gro.c b/net/core/gro.c > > index 26f09c3e830b7..7b9d018f552bd 100644 > > --- a/net/core/gro.c > > +++ b/net/core/gro.c > > @@ -422,6 +422,9 @@ static void gro_pull_from_frag0(struct sk_buff *skb= , int grow) > > { > > struct skb_shared_info *pinfo =3D skb_shinfo(skb); > > > > + if (WARN_ON_ONCE(!skb_frags_readable(skb))) > > + return; > > + > > BUG_ON(skb->end - skb->tail < grow); > > > > memcpy(skb_tail_pointer(skb), NAPI_GRO_CB(skb)->frag0, grow); > > @@ -443,7 +446,7 @@ static void gro_try_pull_from_frag0(struct sk_buff = *skb) > > { > > int grow =3D skb_gro_offset(skb) - skb_headlen(skb); > > > > - if (grow > 0) > > + if (grow > 0 && skb_frags_readable(skb)) > > gro_pull_from_frag0(skb, grow); > > } > > I'm unsure if this was already mentioned, so please pardon the eventual > duplicate... > > The above code is quite critical performance wise, and the previous > patch already prevent frag0 from being set to a non paged frag, Hi Paolo! The last patch, d4d25dd237a61 ("net: support non paged skb frags"), AFAICT doesn't prevent frag0 from being a non-paged frag. What we do is set ->frag0=3Dskb->data, then prevent it from being reset to skb_frag_address() for non-paged skbs. ->frag0 will likely actually be a bad value for non-paged frags, so we need to check in gro_pul_from_frag0() so that we don't accidentally pull from a bad ->frag0 value. What I think I should do here is what you said. I should make sure frag0 and frag0_len is not set if it's a non-paged frag. Then, we don't need special checks in gro_pull_from_frag0 I think, because skb_gro_may_pull() should detect that frag0_len is 0 and should prevent a pull. I will apply this fix to the next iteration for your review. Let me know if I missed something. > so what > about dropping the above additional checks? > -- Thanks, Mina