Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1484742rwi; Fri, 14 Oct 2022 20:26:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Bfo/k2ETK1oT375MN9wllE809T02Ot0rmE/RPr0NQp9jMxRgGLcaYeQPzfdTCVlzhj9i8 X-Received: by 2002:a17:90b:1956:b0:20a:9ab0:6f9e with SMTP id nk22-20020a17090b195600b0020a9ab06f9emr1191401pjb.231.1665804418836; Fri, 14 Oct 2022 20:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665804418; cv=none; d=google.com; s=arc-20160816; b=lX+3/tzNvRL98jOURhKDidZ2acUQFO1TUTJ/LIYc4AkBAqECRz0TH4e1BE1FAH3UC3 UAGUVAEBdXlkjLocTSa7XIISfSfiSesOm0XxD5rJfZ0nv+xPfY9CaIIqB2jT5w3zSqC8 q6lUi7TeSnDbDMXaKARxJMiH46DhZbVRwphIByNyOeI1RWx0ehBjI4ogB4r7r4J7tNg2 I+8RfBcSLhp2VDbrR9kTlh/oV4KAYphD3B48P52pTf7BxEeJkiO8LWaZ4j0dtAaWPaVs 4nV2wgUtcrF4AR2LvyZbxYEJ0KL+gs6csFUdAz9pO+qNbvBAQtgmz/iyIVHXR+UaVdOh 1deg== 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:subject:user-agent:mime-version:date:message-id; bh=qdGYHO4Yg6x7VsfHhH13kbfzOzrTWzYnNtezZQIUJAs=; b=00n2BtrBYBL/GhP+iye7TKJrDGOzTBJIEK8+BEnsIbC7HCnSCpcahYBGEJ9m58qf71 unzNqJ8qLJOPjSH/YOxOR6bZJR6duVYCW4sV4/sfYEKPfr34aLRsg3rqvaKrOgbrJcJo xJ6ux6phdiRanpXv9xjG+OtvdrmbQivJ8U4eb8Q4/GGCYqi1/WlhszXXupExNy/CLpG+ jZ8BT6eqhW4O+6cZIiQI+f9nXzDXKlkKDl+RN7DSDFwFjtMBXHQBtOACWbM0hn88z9rZ IaCrOHOl5imL88sElndStzRG/7jFOmE3NZVAm82ghw36qNvl9hPHgW5/QW0Hkj6X0Ilw DHwQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a1709026bca00b00171311470f7si4614996plt.3.2022.10.14.20.26.42; Fri, 14 Oct 2022 20:26:58 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbiJOCgv (ORCPT + 99 others); Fri, 14 Oct 2022 22:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbiJOCgt (ORCPT ); Fri, 14 Oct 2022 22:36:49 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6CDA2B1AA; Fri, 14 Oct 2022 19:36:48 -0700 (PDT) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Mq6j50HSmz1P7MC; Sat, 15 Oct 2022 10:32:09 +0800 (CST) Received: from [10.174.178.66] (10.174.178.66) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 15 Oct 2022 10:36:46 +0800 Message-ID: Date: Sat, 15 Oct 2022 10:36:46 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0.2 Subject: Re: [PATCH v4,bpf-next] bpf: Don't redirect packets with invalid pkt_len To: , Lorenz Bauer CC: Alexei Starovoitov , Daniel Borkmann , , , References: <20220715115559.139691-1-shaozhengchao@huawei.com> <20220914111936.19881-1-oss@lmb.io> <5a3c5ea9-d557-6070-d778-1092f3c51257@huawei.com> <04d2eb4a-7365-495a-ab74-704febac2789@app.fastmail.com> From: shaozhengchao In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.66] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500026.china.huawei.com (7.185.36.106) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 2022/10/15 0:55, sdf@google.com wrote: > On 10/14, Lorenz Bauer wrote: >> On Thu, 13 Oct 2022, at 11:44, shaozhengchao wrote: >> >     Sorry, I haven't fully understood your intentions yet. >> > Can you explain it more detail? > >> I'll try! Roughly, we do the following: > >> 1. Create a BPF_PROG_TYPE_SOCKET_FILTER program that just returns 0 >> 2. Load the program into the kernel >> 3. Call BPF_PROG_RUN with data_size_in == 14 > >> After your bugfix, it seems like step 3 is rejected due to >> data_size_in == 14. We had to increase data_size_in to 15 to >> avoid this, see [0]. > >> This breaks user space, so it would be great if you could fix this in >> a way that doesn't refuse BPF_PROG_RUN with > > [..] > >> data_size_in == 14. Since I don't understand the original problem very >> well I can't tell you what the best fix is however. > > The problem was that we were able to generate skb with len=0 via > BPF_PROG_RUN. Prohibiting those cases breaks backwards compatibility, so > we either have to: > > a) (preferred?) accept inputs with <14, but maybe internally pad to 14 > bytes to make the core stack happy > b) revert the patch and instead have length checks at runtime; doesn't > seem to > be worth the penalty in the forwarding path because of some corner cases > like these ? > Hi sdf: a) looks better and I'll put up a patch as soon as possible to fix it. Zhengchao Shao > >> 0: >> https://github.com/cilium/ebpf/commit/a38fb6b5a46ab3b5639ea4d421232a10013596c0 > >> Thanks >> Lorenz