From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 AE823C43461 for ; Tue, 8 Sep 2020 11:56:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65171206B5 for ; Tue, 8 Sep 2020 11:56:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NxWHKqeW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729824AbgIHLzz (ORCPT ); Tue, 8 Sep 2020 07:55:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729912AbgIHLx2 (ORCPT ); Tue, 8 Sep 2020 07:53:28 -0400 Received: from mail-vk1-xa34.google.com (mail-vk1-xa34.google.com [IPv6:2607:f8b0:4864:20::a34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDDB5C061797 for ; Tue, 8 Sep 2020 04:53:21 -0700 (PDT) Received: by mail-vk1-xa34.google.com with SMTP id c25so3996945vkm.1 for ; Tue, 08 Sep 2020 04:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iNpJDo+gqE3n8OuKKqMvnJiyfSpkNKq1np+3FoTppfI=; b=NxWHKqeWMlPQoU/mbjiNrhFOjTvZGeHZpM+zLLMFWigZmV0OUhk7dj7b7dt2/8OQsr Lkc6tWXsbifJLb0/5FvBAVKRa/CXeyVCntFwzv8bXuK7VcObRc8gkPv1v7diuZch5Sen rmC4nMZGvN7D5kfdt+2DUH0JgjZNXqrU4R4dAYp6Ghew9RoBazonRUVcBYEmIIccBmWs W9uArxhsCYeG402YhgWQpZxyphNYnFQNDQ1JaO2wqAsvi/ON/OHdB3KqUBlP8r0S7Zaj e5xi7OmoWilMVecuDxGlUIRV8FJez+HD7t2D8VnuKXG1OpYq+tPGLhT2WpSlMLnA9rGZ Bb4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iNpJDo+gqE3n8OuKKqMvnJiyfSpkNKq1np+3FoTppfI=; b=KuY8LEKy/OE0AxmD4mTf9xpOXmr4w8gFGn22ptDkydDxfMFs9/Q3JBr1uKsUgSC/0q lmUx/7qlvzOBzZbU0aG7QA/qMPtj/uHoW9+ZzHRmxftG3hfenlVUrixFAMSyZnYtPG3j qAA3I3mUsa1z7i7BojaeG4wj12p3LhG58PMzO9NipjsroO8kqDynA0eEFHC+5dXIoPtc Pk0Pzfustlxk4gj3A0wpZoNr1Yc6cflCIACYuwsz4csHAixWMBLrBOBSp/eMckqEQ8Nq juIS5gsVXCyZw6SHhLjwluQNnmZ5y9lO2Od3p6LOFMPhJRu/pKwXwKrOVNOKOSUunrs8 NTzg== X-Gm-Message-State: AOAM532dz5zTmKG3w+S8LZeuyQeneemvnqf2LB8Oe5Z1nTDBfG+x7+Qf zfq1M/zKZEmH1fBBzjpocKM9zN4EzKCQiA== X-Google-Smtp-Source: ABdhPJzMWznF04T0MrzB3YvcM5K4GfFenvFzik7pLM3/nsd0Yih8Xbhal7Ty53AWNL9GOJU7cRZuiA== X-Received: by 2002:ac5:c297:: with SMTP id h23mr14140752vkk.38.1599565998537; Tue, 08 Sep 2020 04:53:18 -0700 (PDT) Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com. [209.85.222.46]) by smtp.gmail.com with ESMTPSA id k4sm947508vkk.12.2020.09.08.04.53.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Sep 2020 04:53:17 -0700 (PDT) Received: by mail-ua1-f46.google.com with SMTP id l1so4964901uai.3 for ; Tue, 08 Sep 2020 04:53:17 -0700 (PDT) X-Received: by 2002:a9f:2237:: with SMTP id 52mr12620777uad.141.1599565997147; Tue, 08 Sep 2020 04:53:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Willem de Bruijn Date: Tue, 8 Sep 2020 13:52:38 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Question about dev_validate_header used in af_packet.c To: Xie He Cc: Willem de Bruijn , Eric Dumazet , "David S. Miller" , Jakub Kicinski , Linux Kernel Network Developers , LKML Content-Type: text/plain; charset="UTF-8" Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Sep 8, 2020 at 1:04 PM Xie He wrote: > > On Tue, Sep 8, 2020 at 1:41 AM Willem de Bruijn > wrote: > > > > The intent is to bypass such validation to be able to test device > > drivers. Note that removing that may cause someone's test to start > > failing. > > > > > So there's no point in > > > keeping the ability to test this, either. > > > > I don't disagree in principle, but do note the failing tests. Bar any > > strong reasons for change, I'd leave as is. > > OK. I got what you mean. You don't want to make people's test cases fail. > > I was recently looking at some drivers, and I felt that if af_packet.c > could help me filter out the invalid RAW frames, I didn't need to > check the validity of the frames myself (in the driver when > transmitting). But now I guess I still need to check that. > > I feel this makes the dev_validate_header's variable-length header > check not very useful, because drivers need to do this check again > (when transmitting) anyway. > > I was thinking, after I saw dev_validate_header, that we could > eventually make it completely take over the responsibility for a > driver to validate the header when transmitting RAW frames. But now it > seems we would not be able to do this. Agreed. As is, it is mainly useful to block users who are ns_capable, but not capable. A third option is to move it behind a sysctl (with static_branch). Your point is valid that there really is no need for testing of drivers against bad packets if the data is validated directly on kernel entry.