From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D03B3922F for ; Wed, 7 Jun 2023 20:54:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82456C433D2; Wed, 7 Jun 2023 20:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686171248; bh=6GeBUh+EyBMC+hyHRk8azuwZpKDUvQF7QezntYceO9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZfojP+qhuJhC4N5pBIHVqws+36n5zp04XKiKG808zEu3b1EB58KGQXXbu27GghL2 KrHyv89PJUMqpIo3TkUGj9hggTI19sZw/C0sApSZl4o1OR4XhbcOzlbrZ3Rqg7BBKU M3lBxVaeytW1Yqe//hsPQXeZAROshbrR46gE7OlY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+b53a9c0d1ea4ad62da8b@syzkaller.appspotmail.com, Pedro Tammela , Jamal Hadi Salim , Vlad Buslov , Peilin Ye , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 16/99] net/sched: sch_ingress: Only create under TC_H_INGRESS Date: Wed, 7 Jun 2023 22:16:08 +0200 Message-ID: <20230607200900.763311150@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230607200900.195572674@linuxfoundation.org> References: <20230607200900.195572674@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Peilin Ye [ Upstream commit c7cfbd115001f94de9e4053657946a383147e803 ] 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/ Tested-by: Pedro Tammela Acked-by: Jamal Hadi Salim Reviewed-by: Jamal Hadi Salim Reviewed-by: Vlad Buslov Signed-off-by: Peilin Ye Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- 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 bf56aa5197974..d5358c033d247 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -79,6 +79,9 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt, struct ingress_sched_data *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); + if (sch->parent != TC_H_INGRESS) + return -EOPNOTSUPP; + net_inc_ingress_queue(); mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress); @@ -94,6 +97,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.39.2