Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2485014rdf; Mon, 6 Nov 2023 16:16:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgr1I7hxPBxFCsgh3Oey/X0JSclV+ST47bZXjjWqHwhVVvftLvRaObWOR4CrFpe9/y6lr/ X-Received: by 2002:a05:6a20:4406:b0:151:35ad:f331 with SMTP id ce6-20020a056a20440600b0015135adf331mr1338159pzb.14.1699316199835; Mon, 06 Nov 2023 16:16:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699316199; cv=none; d=google.com; s=arc-20160816; b=ZYTsJRkwsgAZ9sjdqtufKBXu+QMwb5XQkLoinYYhhRTubT+bQeGVZfJuXVmmS9MNev /hDdTPIEska5AUF1tMdQSACYEv+kk6FIyXE5kIicGQ0z2tlx9EQSiSQlEukC0IgzzApo I491lCyU8FdwEWpu50J4Q3sUw19hak8Zk4fodNfOE/jwtPNl5/i+8tQ8SyPlKnY7Mu74 PBpVu0fcv0vmiv7E50my9JwRB8ggIFNNLbz4w7CaUSdi2IGB8sWxi8uTTHcK/xMc2AzJ GXduwT0srbqZ0hBVV7Nt15p2hcH6qSOW9hXRvd/u7E6Yb7v9j66Xji8HA1IkNap1ngFB 1kog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=tEQEV38mXQhVbhTb8FZeGW7zjdnzDXyHhvwU+g1R1n8=; fh=7DwqMgxHc+5SclBl+86gKseU0BLLzQGyUA0S3/ee6uU=; b=uJOwWQmj6zh5/TiWZApW3Y2gtmZ5aC1XdVi3fBGXgEski5B6QgMjYGX+GYQ25wxbhd e704WWuVIbjg2wu4UmRfM1iGLqAs1gKcPb7EO7sqvSaVtK5qAFG6yPi1IZprd+oiB2Jm w700KEngY3s7xbKmpPTxN4zTfqOMmsDn8tygNzrktaw3oVDQMQ0jd1xMM5GoQlugkl66 bVUVeMWmAeeG+nwjDkgyDhDsBD/2CengUt//6p6nKgjPkFx0+Fp+5T2rH+H3RsHaoWxm 3QDLrv5zL7i9QduRNROTF2gJ+rKQLRAYsciJfsJBcDMrtxeEt7h/mERUa4GE8RKpTRBE 28nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LHFJpRRp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id t20-20020a056a00139400b006c33988ea3esi9317315pfg.402.2023.11.06.16.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 16:16:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LHFJpRRp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E30C9802EE52; Mon, 6 Nov 2023 16:16:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233494AbjKGAQZ (ORCPT + 99 others); Mon, 6 Nov 2023 19:16:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbjKGAQY (ORCPT ); Mon, 6 Nov 2023 19:16:24 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A941C0; Mon, 6 Nov 2023 16:16:22 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0EF7C433C8; Tue, 7 Nov 2023 00:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699316181; bh=rdCTl+4hQmLubYiMS/p2QV8xEsJXv+ZSM2pgQqPjLVQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=LHFJpRRpE9spIepJHWhKG3x06BG5ePCOBuH4QJZkUidEwERp/tNEcGEPDfwoYcMsD LwQ+LDowdMk/nRme8Pe/2PP8U5mpI2/vbQhTfrjDmoqRK0P0GMn3klxMiSbaEGAvQx TxXq8Y5RvYtNAFTBQmRE6GfauJ63a/UJka/kDzDprGDEt16iWZR1vfQi3/2DP/Asai fs3QZ5heBo/8vttlafXTbhlXmNU5RDgI6S3oS67JNxncI/lQdczhxSDJGJZhgR1QIC kDsR5rXhwiQHG8PesuHnV3MhFJjuLD1YVEoyKFwdec07E1shE+t0tHzE2NG0moUC11 E/fd2myN6ldFA== Message-ID: Date: Mon, 6 Nov 2023 17:16:20 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v3 09/12] net: add support for skbs with unreadable frags Content-Language: en-US To: Mina Almasry , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesper Dangaard Brouer , Ilias Apalodimas , Arnd Bergmann , Willem de Bruijn , Shuah Khan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi , Willem de Bruijn , Kaiyuan Zhang References: <20231106024413.2801438-1-almasrymina@google.com> <20231106024413.2801438-10-almasrymina@google.com> From: David Ahern In-Reply-To: <20231106024413.2801438-10-almasrymina@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 06 Nov 2023 16:16:36 -0800 (PST) On 11/5/23 7:44 PM, Mina Almasry wrote: > diff --git a/net/core/datagram.c b/net/core/datagram.c > index 176eb5834746..cdd4fb129968 100644 > --- a/net/core/datagram.c > +++ b/net/core/datagram.c > @@ -425,6 +425,9 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset, > return 0; > } > > + if (skb_frags_not_readable(skb)) > + goto short_copy; > + > /* Copy paged appendix. Hmm... why does this look so complicated? */ > for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { > int end; > @@ -616,6 +619,9 @@ int __zerocopy_sg_from_iter(struct msghdr *msg, struct sock *sk, > { > int frag; > > + if (skb_frags_not_readable(skb)) > + return -EFAULT; This check .... > + > if (msg && msg->msg_ubuf && msg->sg_from_iter) > return msg->sg_from_iter(sk, skb, from, length); ... should go here. That allows custome sg_from_iter to have access to the skb. What matters is not expecting struct page (e.g., refcounting); if the custom iter does not do that then all is well. io_uring's iter does not look at the pages, so all good. > > diff --git a/net/core/gro.c b/net/core/gro.c > index 42d7f6755f32..56046d65386a 100644 > --- a/net/core/gro.c > +++ b/net/core/gro.c > @@ -390,6 +390,9 @@ static void gro_pull_from_frag0(struct sk_buff *skb, int grow) > { > struct skb_shared_info *pinfo = skb_shinfo(skb); > > + if (WARN_ON_ONCE(skb_frags_not_readable(skb))) > + return; > + > BUG_ON(skb->end - skb->tail < grow); > > memcpy(skb_tail_pointer(skb), NAPI_GRO_CB(skb)->frag0, grow); > @@ -411,7 +414,7 @@ static void gro_try_pull_from_frag0(struct sk_buff *skb) > { > int grow = skb_gro_offset(skb) - skb_headlen(skb); > > - if (grow > 0) > + if (grow > 0 && !skb_frags_not_readable(skb)) > gro_pull_from_frag0(skb, grow); > } > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 13eca4fd25e1..f01673ed2eff 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -1230,6 +1230,14 @@ void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt) > struct page *p; > u8 *vaddr; > > + if (skb_frag_is_page_pool_iov(frag)) { Why skb_frag_is_page_pool_iov here vs skb_frags_not_readable?