Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2620741rwo; Thu, 3 Aug 2023 12:08:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlHNEDUMTXusjDtnTljT1VOE9AnrwTns2E2sSnRNINvbosfbfMl/vO25KM+8bOrwTR4J95jH X-Received: by 2002:a05:6a20:1441:b0:134:3a9b:4cd7 with SMTP id a1-20020a056a20144100b001343a9b4cd7mr22971160pzi.23.1691089719045; Thu, 03 Aug 2023 12:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691089718; cv=none; d=google.com; s=arc-20160816; b=zx/+wTpl8craWXOlgbZyhqGPk/Qb3gR5ek8PpZLeG/a3Avm8YPnOwjrN7iF12LfJJs 5DbVhNA2EzoY6XGy1k0xBLhBABM6HbzeEXmu38YiTa3NCwQdRtqQgfjFnDUC2X+SsAtb ybJK+PN/8GIs6BLXYhLVW8366OfOkwzU4nj9In9WjUgrftJF2CkjBat27MDvvmszmkby LGugbyrEK70yY8mqfz+rZP7GrWrMCYu4rWlE9uo+qROgImU5bXG/68mg1wWhHFY4U8s1 X1HViljNjbflxqRGQ+QE+gjokeC7xnbPSPxQhH24VlmKh0a4VTWdxr3wOUUu0RLtqwTI lb4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:subject:cc:to:from:date:message-id:dkim-signature; bh=V+wyudEu/QspMENufwePSDeBm7uMlK4OkNp5EvN/35o=; fh=japsXROqvvAX82h5mgAEttnl24uEPlYIaD1f2BVCEG0=; b=rS2gTgFDCFBGwqa11+74w/AQxrsjRZVR2oVnrw6kM1wGG1MOa0EQ8dm4OYJJWp2KZy NJ6JnvzewJpddicP2fWwmESNrbKtxjFmgBneYxSRCf2zFikosIgb2pfIYsTO4Cd6xLdZ EyWjJwsZG7FrX7nx8Z3pOgrzXuirGYOZzJc+UYRvTLU+yl3mftFuBHGRVXIqkEDALX9b +UyjSEAh2rnU0K1AUXIWQlf+/1nGYbDx+p9r1+koc44+aEmFS0XlBmPBT3YP29WtuDQi qIbTm1iZ4nAelyTIL40z8Qe6Q5p9kmMsJOJdGFVFCMeGmT+aVYmDMOnCYL1Gdi8RUDXk i/jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=JL+ZqAqj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a637705000000b005649a48340esi388480pgc.797.2023.08.03.12.08.18; Thu, 03 Aug 2023 12:08:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=JL+ZqAqj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234739AbjHCRxf (ORCPT + 99 others); Thu, 3 Aug 2023 13:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234871AbjHCRxd (ORCPT ); Thu, 3 Aug 2023 13:53:33 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D713C3A; Thu, 3 Aug 2023 10:53:24 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4fe4f5290daso2141262e87.1; Thu, 03 Aug 2023 10:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691085202; x=1691690002; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=V+wyudEu/QspMENufwePSDeBm7uMlK4OkNp5EvN/35o=; b=JL+ZqAqjXrPGGLl4Rbob9P7lElgz/eZuZmXKnawuVKZBW75wL5TqICw4umkMOq+7PV 00x8OW1CbC//gpvy8dRhNiGfAPCugbxKC3zfXksmbBbUscvWho018BDCca2uVKy0k8vw 8TRd/qdKa6fpUJychSdgSxRvnTiB8e8Wn/gwrh/UaAoC+eF6HkUz/G/nqoBBD/szkhnc XQ6l2u6atW5ZZbHWLQ4Tal1fh+ROry20RaLG35HfU1ewxzJMlgFT3J4Tj7MaRKxxxBBY OEndrsRCD8JDKLUN53jpgdimIobPT096j/V0OHlJkxMkn1InGJ8WO1nAuRezDqZDc5WG 7+EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691085202; x=1691690002; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=V+wyudEu/QspMENufwePSDeBm7uMlK4OkNp5EvN/35o=; b=fe7Z9aW1EEzvCYaWE8THVTM66cMwpkSQdwGbiCsd+pTq0N3kpDdUDcY4mQLjeArhAh ZetESbWKjgng3lzGz2FCtaPuwFS4m2R0XBUUln9gfYddfx3bU9NyrXdj3ubo+0p+RZ3P V5Mxf6P7U95GC4AVumHEWYPrdQouQv2bKfrgsgKVlt52HYRF6nG7VsncVYf4Tt+scJCc JDHSnNCYN37M4VBQM5BbHEL0HdhgQFyYVIBeG/ljHQeOgwuzf7Lt2p+bKCGzk6TgFO64 1jNAbRlYvL9mULzPpMRGmONqKfTTsVzihXauauYpvANLAD8oWJ1X2lRUjwHgcgcgAlzo Y4bQ== X-Gm-Message-State: ABy/qLbloKpjmW0nVjPReEWeVTfisW2QUQIGWew3QgGToHu/bmKUk8F/ ReMZ04WacxC4gwAx6Nzqad4agvDAEzj7UA== X-Received: by 2002:a05:6512:370b:b0:4fe:279b:8a02 with SMTP id z11-20020a056512370b00b004fe279b8a02mr6690530lfr.67.1691085201631; Thu, 03 Aug 2023 10:53:21 -0700 (PDT) Received: from akanner-r14. ([77.222.27.58]) by smtp.gmail.com with ESMTPSA id m8-20020a195208000000b004fe31fa2490sm46205lfb.247.2023.08.03.10.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 10:53:21 -0700 (PDT) Message-ID: <64cbe991.190a0220.b646b.04c1@mx.google.com> X-Google-Original-Message-ID: Date: Thu, 3 Aug 2023 20:53:16 +0300 From: Andrew Kanner To: Jason Wang , Jesper Dangaard Brouer Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, dsahern@gmail.com, jbrouer@redhat.com, john.fastabend@gmail.com, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, syzbot+f817490f5bd20541b90a@syzkaller.appspotmail.com Subject: Re: [PATCH v4 1/2] drivers: net: prevent tun_build_skb() to exceed the packet size limit References: <20230801220710.464-1-andrew.kanner@gmail.com> <2cb34364-0d7c-cf0a-487f-c15ba6568ac8@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 03, 2023 at 11:19:47AM +0800, Jason Wang wrote: > > > @@ -1594,7 +1597,13 @@ static bool tun_can_build_skb(struct tun_struct *tun, struct tun_file *tfile, > > > if (zerocopy) > > > return false; > > > > > > - if (SKB_DATA_ALIGN(len + TUN_RX_PAD) + > > > + rcu_read_lock(); > > > + xdp_prog = rcu_dereference(tun->xdp_prog); > > > + if (xdp_prog) > > > + pad += XDP_PACKET_HEADROOM; > > > + rcu_read_unlock(); > > > + > > > > Isolated seen, I guess, this is a correct fix to 7df13219d757. > > I think so. > > Actually, I think we can probably always count XDP_PACKET_HEADROOM > here. Since there's a window that XDP program might be attached in the > middle of tun_can_build_skb() and tun_build_skb(). Thanks, that makes sense. I will do it in v5. > > Question to Jason Wang: > > Why fall back (to e.g. tun_alloc_skb()) when size is above PAGE_SIZE? > > > > AFAIK tun_build_skb() *can* create get larger packets than PAGE_SIZE > > from it's page_frag. Is there a reason for this limitation? > > I couldn't recall but I think we can relax. Jesper already sent enough info for this idea in v2, I will use it for the next patch/series. Jesper, I will add this tag for this next patch/series if you don't mind: Suggested-by: Jesper Dangaard Brouer -- Andrew Kanner