Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5100431rwd; Tue, 23 May 2023 18:29:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4MN20M3I6LE0ZRxiIvWEDFA9azG8M66PmL1to05ktbGeybSKsOvKebTP2ztxAim8F0q2n/ X-Received: by 2002:a17:90a:6341:b0:252:8698:d03b with SMTP id v1-20020a17090a634100b002528698d03bmr14123085pjs.14.1684891763514; Tue, 23 May 2023 18:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684891763; cv=none; d=google.com; s=arc-20160816; b=Bp1YFy12ghV6fzG4I0wf1A46cIK3aQ0ShtHU8KmgYCMqZD3kz6O1gajwB7R9vx3rNo PG6HLdbVefJ4tv3VljyIgBXw3xu1XhxQji8P8o3qANohoyv+g6paml/YYQ6pihdhhXUT 8kCh0U5wzE8n6mRgUKbQDSgvOTgoruYKPQgAms9SeY4YHdVS/ZU2cSnoZt0uWoh4pqkV Ls5NiJ5em3Q0Y08g40FUM3VtVWCZypnAj9f40i2RqM6hiLh+xVjWpVuRMvC47KXTy7nv WPvJWvJ9i2FBZ6MWbjHcl8ZkYwJPdOOp0fhCpYsJ3qHu6th+gq7QLj7956YrsBJ4wA5A JAgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CcHI3x4ohvXiCTNBiyxTM+9Lco9SeIQmLnH1EsUllhU=; b=TUIpyeg0B9aeydnReBgZaa+Zn112nTABrvj14IuV4be/lML21CrMcEzGyN0QZ8Fo42 EtE9qem7rLLtAwFKHAeHHAtmIdnZgM5WzztWQWaLA1hzUqBEDzvenY1IV6ejVw4rZo8M +YBAZUitxcH2Ymw9aYufEtWZEffZ5tkKc8B6U78/tnph/pgg1k16HFbMxkCrlyk7XzZI nsrfF+NhRtDlth2RmCr8RZNgWwpCUMTgu7aq2YjJibzjxrEJ+dgnCl1d90xwioQmFbAR tBIF5y1Ey4cTOJqZsaJrueFLwxuckkG3yyDCR3Ln45R2ITG9IvGF0vnE7kZScBEgTPUM ZnVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=DtQCWPCO; 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 26-20020a17090a031a00b0024743ec226dsi343661pje.70.2023.05.23.18.29.09; Tue, 23 May 2023 18:29:23 -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=DtQCWPCO; 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 S238655AbjEXBSJ (ORCPT + 99 others); Tue, 23 May 2023 21:18:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230480AbjEXBSH (ORCPT ); Tue, 23 May 2023 21:18:07 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E945DA; Tue, 23 May 2023 18:18:06 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-75b17b80834so70486885a.1; Tue, 23 May 2023 18:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684891086; x=1687483086; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CcHI3x4ohvXiCTNBiyxTM+9Lco9SeIQmLnH1EsUllhU=; b=DtQCWPCOPWS0+xDr8/swlbtrJH3RwebebAKwTSXG5R4kuTsfi71x0G5lXvhMh74ox8 dgtHcrBAOndyoBNqZBxeK6YufsUoALMkPziyDyfAQ4OTLdq1iM3viKF+Cm10LfzTGeu9 wTMHxvOZL/V6yit4mFGrJsEN3eLmxA3ceGnL49kT5HIZZU29wqZ8/LjBVdGdDGyLv8Qc Xz8Tad0q9vny+wNpxp29SHxmxOfDXXgHuqDMyRoxhBu1nKaMRtcPeszYw3tiIWMG/X1L QwT4ODVyrWHkBcmfRyk9eiw4DMHEsiRx47/TLNvLZEgVB85NuB8pQcsyb0dZtabOhjSO tX6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684891086; x=1687483086; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CcHI3x4ohvXiCTNBiyxTM+9Lco9SeIQmLnH1EsUllhU=; b=GVNuoUg3Rzpv6ljtobEd0LWguU5jLW1gVngzva4cy7Z6VfJKwtQFWL2BVVQWHcz9la /fLsyB9rG8gm6sh1Hq9YDh1V68ETBsMo13IkqlhrIiUUs/gJOHqE8iCXV5fspkadeJ/o 4h+FiEnUmnUMuQ+giqUQOXLTuCKv0jrnl/GawO+qP3Ccabwd1kkTUhUs92pDIBEDcPW+ mClnmkhjIaSEPHtUGmqxXvL3BWm2D/oppY2rnUQdk9GLqC6EwFcXrq8PbOcShJyFQ1Jm tObkAkI3J+0fyNVUxfwr7wcJN1QJumm5yplhhi3p9grgtM5R40v/r18PkmD5duhZR+oA 2wCQ== X-Gm-Message-State: AC+VfDwL43rP6Hc7cjCvdPDPoZgwGyGZpDsuqPigbg8ZI97sVI/+S8CE XOBqd6VN2uW0ADI+J5L4qZuOrtuf5g== X-Received: by 2002:a37:4d6:0:b0:75b:23a1:44b with SMTP id 205-20020a3704d6000000b0075b23a1044bmr5344164qke.17.1684891085685; Tue, 23 May 2023 18:18:05 -0700 (PDT) Received: from C02FL77VMD6R.bytedance.net ([2600:1700:d860:12b0:c32:b55:eaec:a556]) by smtp.gmail.com with ESMTPSA id a19-20020a05620a103300b0075798551db7sm2920764qkk.22.2023.05.23.18.18.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 May 2023 18:18:05 -0700 (PDT) From: Peilin Ye X-Google-Original-From: Peilin Ye To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: Peilin Ye , Daniel Borkmann , John Fastabend , Vlad Buslov , Pedro Tammela , Hillf Danton , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , Peilin Ye Subject: [PATCH v5 net 1/6] net/sched: sch_ingress: Only create under TC_H_INGRESS Date: Tue, 23 May 2023 18:17:39 -0700 Message-Id: X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_NONE,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 From: Peilin Ye ingress Qdiscs are only supposed to be created under TC_H_INGRESS. Return -EOPNOTSUPP if 'parent' is not TC_H_INGRESS, similar to mq_init(). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: syzbot+b53a9c0d1ea4ad62da8b@syzkaller.appspotmail.com Closes: https://lore.kernel.org/r/0000000000006cf87705f79acf1a@google.com/ Signed-off-by: Peilin Ye --- change in v5: - avoid underflowing @ingress_needed_key in ->destroy(), reported by Pedro change in v3, v4: - add in-body From: tag net/sched/sch_ingress.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c index 84838128b9c5..f9ef6deb2770 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -80,6 +80,9 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt, struct net_device *dev = qdisc_dev(sch); int err; + if (sch->parent != TC_H_INGRESS) + return -EOPNOTSUPP; + net_inc_ingress_queue(); mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress); @@ -101,6 +104,9 @@ static void ingress_destroy(struct Qdisc *sch) { struct ingress_sched_data *q = qdisc_priv(sch); + if (sch->parent != TC_H_INGRESS) + return; + tcf_block_put_ext(q->block, sch, &q->block_info); net_dec_ingress_queue(); } -- 2.20.1