Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3332857rwo; Fri, 4 Aug 2023 03:18:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGoL2H4dvUM5icEA0ruiO8b1rHwixbCEOwB/7bmJxUvbsmsB0V9MKdPOp0lbjD5vHtjipaV X-Received: by 2002:a17:902:ab0c:b0:1bb:b855:db3c with SMTP id ik12-20020a170902ab0c00b001bbb855db3cmr1000287plb.41.1691144286458; Fri, 04 Aug 2023 03:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691144286; cv=none; d=google.com; s=arc-20160816; b=izCF9aIXp17lY63IZxFVbC+jq/AcuVzwJatbKgIt4pcesafFgbC1OXtqF4nxlfYvBO XNbpgI7v4xcdmpRAViedmsXVtMf/JgF3+93IBggEGzREsHBVJe9J3Cn1nbxQZj+/kLuV 4Pd2J9skM+R0L8suVqAhak1+VDYayKCDFe9p5BSWpqxmK8nRtRT6+Q2fPIsXhL8Hbw2n Vq3nBPedQ9mQ4Pj/QwOmLg7u0BNu3qAYoeNz62JeNRfT+N6IveDwg4zmu7/dQ+j/29l9 VH1LrhNq93iYzikZoEbNxoRCeBbTchuBmn6xzyXDEZq4o0UHRgq+Qbb7qltNrxSWkt9w qbPQ== 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=CVimFwHslmd0mYFwPDuSuYeHC8j5W+Na6g2L4tb8wXw=; fh=s7dJ2rcMGFZpTidsiavjN2IVENAr3tySZbk6jeqosQE=; b=Nl96TQdN2Es6eB+cEXVuyoyDNfI1v3UGj8tSMYPZyMq+BUmbe4SKUM+kYppSEB2YbE lJffBXLHBjCP3A4FjWh85VFI10Q/A1CXbqY98vOwpHmSN0HmizQfJTMk2FlGMQI0V3tw 6NkGuXHSCHb6kg3J2xA0UTaJzgQ8VV8mIyxXq6m2SPF6fF+nGYrfPwOGHZyEkDVUlCmP 7CJ6lQKYBr/Gg6ZpFGYxm9AgYDGMSA57PWuM1N/8tdfyGt1s8vaOETbyXfqoLvhb4Ij5 QpRdBBLrHX6xtNq8pnv9L5vlcZz76zy12fr8oYHRnhFrY3lrVXabATlwi9e60vbUyaMC astQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sIGAu88h; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r12-20020a170903410c00b001b9c3498526si1446845pld.433.2023.08.04.03.17.54; Fri, 04 Aug 2023 03:18:06 -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=@kernel.org header.s=k20201202 header.b=sIGAu88h; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230253AbjHDJaU (ORCPT + 99 others); Fri, 4 Aug 2023 05:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbjHDJaK (ORCPT ); Fri, 4 Aug 2023 05:30:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8209530EA for ; Fri, 4 Aug 2023 02:30:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1636961EBE for ; Fri, 4 Aug 2023 09:30:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE5BDC433C7; Fri, 4 Aug 2023 09:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691141408; bh=LEzM9G3hCkmW57EJI+SwefMcALPoyoAqXr/zZx0/GPw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=sIGAu88hByPr2pePZ9Q6D3Op+OdIxyXOdviLitcorwMWrv8SrX0NOW/EDrU5LDMRu hbC7eG8xmtLQf+t62qRsaSoAEwpDcb1klZN6MFIfPJiCvpF/2GOTg7fidd0TiMIe3s TgLaTMxQvbTEMyrZ3dp3/jqeJxlPeyTi+F4GJHh+mU5+pz+mKvRL0dY/knGbTdvr26 Jetk/KBw7uzKMLQa8BIUZ3MuzFJ1hR98N0GM7SLCFrCndR0/I6S3MJV5J/kYCbPPHZ XmxwbxAs2V855E3W7I+pwkz8Jaq4Z8N7SK70s1QU2+HqqZRpM39LnD0og0yM2QRggL NxhvBslhPcR7Q== Message-ID: <224e100b-6874-2993-a743-0a93ca0201fd@kernel.org> Date: Fri, 4 Aug 2023 11:30:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v4 1/2] drivers: net: prevent tun_build_skb() to exceed the packet size limit Content-Language: en-US To: Andrew Kanner , Jason Wang 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, Alexander Duyck References: <20230801220710.464-1-andrew.kanner@gmail.com> <2cb34364-0d7c-cf0a-487f-c15ba6568ac8@kernel.org> <64cbe991.190a0220.b646b.04c1@mx.google.com> From: Jesper Dangaard Brouer In-Reply-To: <64cbe991.190a0220.b646b.04c1@mx.google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 03/08/2023 19.53, Andrew Kanner wrote: >>> 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. > I have some more input and considerations when selecting the new constant that replace PAGE_SIZE. Lets see if Eric Dumazet or Alex Duyck disagree? ("inventors" of page_frag scheme) The function tun_alloc_skb() uses a page_frag scheme for allocation. The maximim size is 32768 bytes (Order-3), but using something that is close to this max alloc size can cause memory waste and fragmentation. My suggestion would be to use the constant SKB_MAX_ALLOC (16KiB). Maybe Eric or Alex would recommend using something smaller? (e.g. 8192) page_frag limit comes from: #define SKB_FRAG_PAGE_ORDER get_order(32768) > Jesper, I will add this tag for this next patch/series if you don't > mind: > Suggested-by: Jesper Dangaard Brouer ACK