Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C68DC433E0 for ; Mon, 6 Jul 2020 04:24:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50D0020715 for ; Mon, 6 Jul 2020 04:24:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tzabOV92" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727055AbgGFEYv (ORCPT ); Mon, 6 Jul 2020 00:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727039AbgGFEYv (ORCPT ); Mon, 6 Jul 2020 00:24:51 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AF0BC061794; Sun, 5 Jul 2020 21:24:51 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id f2so14829016plr.8; Sun, 05 Jul 2020 21:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NhQuh/M+EWr/H+2AN4zsqP1K1gI1NFzEkYpBnUNzwu8=; b=tzabOV92NsrmrViHXK0nWYnzKyxMnXybz1c5LHrpbDZvsULkOEjoUwyg0SEJZWfv2j ke044ICDxjqm31S6SUtqUtsSNgikx9OupmoDwcqP4bmuxNg3IK1qbyy3SvLCR2/I2pur VxoNfSeScLptOrJjsstSIQo9lvVctL3xwjCOl0BpXU1wfF3hp3IWqZsRLp8zzqIqGJAK BzdKyAYWRXGcwRVo6Xb5F9dbkqkuQunR5ZZ/I/wk4eNu8OWhQ+ROPxtuaCJbZuj0Ga6i C3CW4lXhSdwsxT8A5EMFgsQGQs/5JFpeTr7wKEz4Wbdhzew5aHKRXnYJMH00J12AbpKe nIQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NhQuh/M+EWr/H+2AN4zsqP1K1gI1NFzEkYpBnUNzwu8=; b=dgPFk/51CzJw8R9ZVRxcDygIgYefCG+chT1YaRoI9qCI/hERgKF8AK51jFryTSRyd9 g3yez9UZcooGb/5AoF/5fLO1b7dr+JZVfssJ3856i0aK9QmnxMxhA/XqP3Z1a0HBF+EP K2XD7mbV62BaDVvVCDaFzQy0hXtsywDJbmy5VAmcBirqKjcp87fOygSxr4rE8kky0v8Y u45ohCddemDqlOiJyDgl+1hpH8yzl2TbRO4ctPmOJhxBctXnkitg1CS2wTVTii2A/jkd 99oiy9TB4xo4nIDa0UmIpR/nQN090K/FdDQC5tysXYgr/SB8dKUxwAmUNvNBa/8e9lng zqOQ== X-Gm-Message-State: AOAM532EYscvjbIBMpkcgMbTnWT9wgilWno87E+Bm1eyejEdBhbJsRpq K/VSn6ES8CJrpytPxK6zukM= X-Google-Smtp-Source: ABdhPJyHCUXMwb1alkHT6aU83lgl85yKQ4N8yg8Bm1A7RfvY/tx7kGh5nrkaA6qdA1Cf5r2jzEe7Sw== X-Received: by 2002:a17:902:684e:: with SMTP id f14mr11268525pln.166.1594009490929; Sun, 05 Jul 2020 21:24:50 -0700 (PDT) Received: from [172.20.20.103] ([222.151.198.97]) by smtp.gmail.com with ESMTPSA id d14sm298902pjc.20.2020.07.05.21.24.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 05 Jul 2020 21:24:50 -0700 (PDT) Subject: Re: [PATCH net v3] sched: consistently handle layer3 header accesses in the presence of VLANs To: =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= Cc: davem@davemloft.net, netdev@vger.kernel.org, bpf@vger.kernel.org, cake@lists.bufferbloat.net, Davide Caratti , Jiri Pirko , Jamal Hadi Salim , Cong Wang , Roman Mashak , Lawrence Brakmo , Ilya Ponetayev References: <20200703202643.12919-1-toke@redhat.com> <878sfzms4p.fsf@toke.dk> From: Toshiaki Makita Message-ID: Date: Mon, 6 Jul 2020 13:24:42 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <878sfzms4p.fsf@toke.dk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 2020/07/04 20:33, Toke Høiland-Jørgensen wrote: > Toshiaki Makita writes: >> On 2020/07/04 5:26, Toke Høiland-Jørgensen wrote: >> ... >>> +/* A getter for the SKB protocol field which will handle VLAN tags consistently >>> + * whether VLAN acceleration is enabled or not. >>> + */ >>> +static inline __be16 skb_protocol(const struct sk_buff *skb, bool skip_vlan) >>> +{ >>> + unsigned int offset = skb_mac_offset(skb) + sizeof(struct ethhdr); >>> + __be16 proto = skb->protocol; >>> + >>> + if (!skip_vlan) >>> + /* VLAN acceleration strips the VLAN header from the skb and >>> + * moves it to skb->vlan_proto >>> + */ >>> + return skb_vlan_tag_present(skb) ? skb->vlan_proto : proto; >>> + >>> + while (eth_type_vlan(proto)) { >>> + struct vlan_hdr vhdr, *vh; >>> + >>> + vh = skb_header_pointer(skb, offset, sizeof(vhdr), &vhdr); >>> + if (!vh) >>> + break; >>> + >>> + proto = vh->h_vlan_encapsulated_proto; >>> + offset += sizeof(vhdr); >>> + } >> >> Why don't you use __vlan_get_protocol() here? It looks quite similar. >> Is there any problem with using that? > > TBH, I completely missed that helper. It seems to have side effects, > though (pskb_may_pull()), which is one of the things the original patch > to sch_cake that initiated all of this was trying to avoid. Sorry for not completely following the discussion... Pulling data is wrong for cake or other schedulers? > I guess I could just fix that, though, and switch __vlan_get_protocol() > over to using skb_header_pointer(). Will send a follow-up to do that. > > Any opinion on whether it's a good idea to limit the max parse depth > while I'm at it (see Daniel's reply)? The logic was originally introduced by skb_network_protocol() back in v3.10, and I have never heard of security report about that. But yes, I guess it potentially can be used for DoS attack. Toshiaki Makita