Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp517970lqt; Thu, 6 Jun 2024 10:00:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGmfIu5D6L2BvTbxieQ+obNo0JZBxCta230wUpJvsKFny9BPUTU6Ig+PgvesPPabIW0b7OYDs+0ozY3/TMQCkhbrZBn79iG4QeLCAtvA== X-Google-Smtp-Source: AGHT+IHwizqhbkhUAi6fhf2OjgzOZGumemBxt/OII/7YBTOyjw+EKTeYYzbh+QZ4RhFQ2pmLwEH0 X-Received: by 2002:a17:906:2542:b0:a5a:51dc:d12 with SMTP id a640c23a62f3a-a6cd560fa01mr13866166b.2.1717693222340; Thu, 06 Jun 2024 10:00:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717693222; cv=pass; d=google.com; s=arc-20160816; b=NszVRjClE9VE80QtKHk3sx67JE1GfvL/c+lEnbdl049+huG12REN9v2m6JCUDSVYoo j4SnGgyHkQaDiwz5yDes8zpnGvLMTjv1BfNIYih9NFxQ67geRthCGDrQYbOMGHGbJaPl juXkFcB+uJ92NZPx7bzblY9Xo2CVXlD0vXOQjtgpSHS4qFuY6ft1vycG+liUMBr/GzYW HMYQ9LAJsFaR9ItPQ+6pXZxOrQXNbZ61SFSkKRxdwF1zYQjLDyDTFOzUym4WzYw7Ou2S 6gLaivokjuk9zX1xxx3h+VtmNqAuxDOShLZWhmsU8i1ShcYLzlOG+hbdKpPPQGcyxPQx zjdg== 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=jylD5VdLotA86Z7MUVU8wz6TNgXb9980vHa3X2PNUNQ=; fh=ZdFHG1uwv0RaHzbJJ+tKXsCu36dX9WFsk+q2WKG+4sU=; b=QEdFW171nh/zTtwuKKLWji8v/PGQloKidMVWPaZQj9zC2rzSWgzKYEuO+KmlxJdnZU ZZU3LEWHj1/IPmGzyf1GVZRTuAcTNpDyDBwPbuGKGLFG5a//ixxfG8R1Imx0YVKJTNxJ CX8E2rkC8tmYcgVrK/38jkaGs16uMQb8sSodjsRrMSuxReTGWR/vYXPLa8u5i7lv+2t5 xqWNsSwdr+XXI4dyKfkOqzZQZf3rlRJSNldO0Y1ojC5FxyLsLhgBzW3FP/J2sNlR8kYx mCmdn4vHB0y7PFxhSZUtUnvmAUnn3rLxaIV99rfLpdg+ZUBAu3XGip+DGnZrQagoyk+M wovg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ymO+zb85; 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-204747-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204747-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c8070cac4si86887866b.690.2024.06.06.10.00.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 10:00:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204747-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ymO+zb85; 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-204747-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204747-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 48FE51F25021 for ; Thu, 6 Jun 2024 16:58:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2F791990C6; Thu, 6 Jun 2024 16:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ymO+zb85" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 A7F4E198A24 for ; Thu, 6 Jun 2024 16:58:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717693100; cv=none; b=P5KYS5lpsTqI8lndwnlkG+6WqFMLn/gUuaOWbK+hBWtbxxVzJzPuSc7VIFeqC09rT7Pz+HYLo8AN2krgA6Njf+SHnNqt2i9MiHqGZe2HNW+UOVgKctprcR7NUqeGGqP3x1EMCeQwxIghvEWxk0RmjeKlqW/xjOq4vo3gpC1w798= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717693100; c=relaxed/simple; bh=4LAT/qwUx+hpUWMrCfCLSnOxPPMN46bQKs4JM+ecNVs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=gLsa74cph1q0so/KkwG4QVXe+F80zNsWwGQ3bUyp3byfdR5d7+3dbMu0LymKyNh7GlyxLnwTNmn1noFpWt2MwWZFYHfRV7ajsUUt1rK7dx+zRsow1RAV/Usu1CQM0xaAcMh37yLB1Hp2uxia8T4WghT4M2N73tirGiWElsuGMdA= 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=ymO+zb85; arc=none smtp.client-ip=209.85.218.48 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-f48.google.com with SMTP id a640c23a62f3a-a68c8b90c85so156084366b.2 for ; Thu, 06 Jun 2024 09:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717693097; x=1718297897; 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=jylD5VdLotA86Z7MUVU8wz6TNgXb9980vHa3X2PNUNQ=; b=ymO+zb85cAZLDHJE/Q2j4AcadlWeBcb6wnlFVDkSgfUydQUphDuqPFEh3fzOICf5Ug S6930QhLrCEFBqOeEvijakHaPdZb4pcvdZFNyeeFn5OIxKUmLmreD+uAz4FxLtUYaT4i 8+igBhkXPEi91hwoCvk6LCC83a751kELtVORkwxyasdVO+JjZ9bJCP+8DK6PbIpkcdTA DayoEFDxalP1IemDK6Al3zp7ltoiff5/CA5SRhaQ12t6LjsFDAwWv5EjIXHW/QUYoU+s fADBKLlGmzTxFwErv1j3cfv/f94mdc6pGuUDPQBLNsyScEte5k+Kutvy5sJZYWR9Zqis Yg7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717693097; x=1718297897; 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=jylD5VdLotA86Z7MUVU8wz6TNgXb9980vHa3X2PNUNQ=; b=gvoBm5L+JcCuvRnJIH7gG5GTuJJh+C5WnEO5SobuO0Cz+EnH650sRbAY6sAaTINf7F Xs8Z0sEk/Lkjz8gD4JOwg46SjDkXWcxDtSSegP9G5MVsEHeW4r7z1A4ptBOYnidDSO5v oPw6efaz84gxaag5RRFwdfwb/usqogOZmEGaQSS/2HYIizaIW0fOtb9Bh2kRHRczggD1 ZXjq6PEsPTwcuSAvN4QpbyrgJErsXP8mGkW9aCZp7mzXCzYEJ1t+IPfP6m9bZUKBO9wQ t21DFk1zngAyu0VXW25JYNQPUdmTNmNTwZRoUClctLb52z3hNuPI8we+IQ27MXh89GFX 4TNw== X-Forwarded-Encrypted: i=1; AJvYcCWP/kqidi801ELx+JntKzeWxfy1HAAechMBu2o5/oEAwG5TYksf6OJY5t+4u6u0ewXxheZeXrYq6cSrd4k6HNZS+KCT6z1gWeo+rOYK X-Gm-Message-State: AOJu0Yz/YEvz8KnMngZDWcn8ZEzsdey3RJLxaTyhDQ5SjonfOjCxYXyJ MsElxSpGYTSheS5A2Jvy3gy0Zd2QEV2cH7+xBCZsfQU2KKOfvqybHVg9HfWtgcAi3Gsn4bjna0d uQVNJJsrc7pdhxivYhulvk1AzNAltsGfw2GlH X-Received: by 2002:a17:906:1453:b0:a68:3e32:384 with SMTP id a640c23a62f3a-a6cd7a7eb86mr10614366b.46.1717693096783; Thu, 06 Jun 2024 09:58:16 -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: From: Mina Almasry Date: Thu, 6 Jun 2024 09:58:04 -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 Thu, Jun 6, 2024 at 9:49=E2=80=AFAM Mina Almasry wrote: > > On Tue, Jun 4, 2024 at 3:46=E2=80=AFAM Paolo Abeni wr= ote: > > > > 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 *s= kb, 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_buf= f *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. > > Actually, sorry you're right. As written, d4d25dd237a61 ("net: support non paged skb frags") prevents frag0 from being a non-paged frag. I can just drop these excessive checks with no downside. Sorry for the noise! --=20 Thanks, Mina