Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3989936pxb; Tue, 25 Jan 2022 00:50:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwIdDbY9eVJqUArEA2dxkmN0nmAyuIh5TSplQU0o1fgxCtfogHQmdJkfFQvfK0J/o8VgW8 X-Received: by 2002:aa7:ce03:: with SMTP id d3mr14863006edv.56.1643100640697; Tue, 25 Jan 2022 00:50:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643100640; cv=none; d=google.com; s=arc-20160816; b=nXd9IIghLmTzOiYHdqnQ0bVC/EXJf+utGjTx4Q41rM+VYcIT8UAQUKtREzsO2koZyQ 3j4q21+v5oWqaROV9BFI2iG0HALFRISE1A3HKCKl5ZRgUVRkKcgxjiq3SAePbJPvL1oY 2fRfvLtY1PJBIf1mepq0dP19MwJaitwfRE5MvP2ibjbiuIMPRj5rc3FK9iRteWTAyieo gU9jJWRbsQ7K5iB94GfnXRIwpYQgifLAC/F+iBVxe0hz3N/4N6B6exUZU4D0+hYkBox0 YxHhMMxFltT7dX1+/K1tERhnaRhfjsMP3oIqKuZ8ySA1t/Vn9toV7XRSczqoiJKXaomR Hp5g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=y48xTWKi2OaxrCvdAgLhr7umUuFEgQGyJD0WBhOXpvU=; b=h16cW9dn9xCy6oQi6Ix/hC8qdV/kq4tEVek9bvbYQm7IJDv3VBo5KaU7cbsE4pen8h x4L3YISNtTzZ+n1b8OToW/p8CsgI+qR7vl+VkMRkgubUKkGH2Go2OgZBUl45+XZCKV7A L4xU8tMl95ySCHft1TQGyyuUNYCW7/ixaCvKIzdhL2SS9AfvKgmLd0+JP0qFQ1b7D92A +fByjuqIdusi6A0Y4KO4GPtNUxUyudcZNv/2IGtZwpc6aaX9k42/HNUBQIOAR38enO8h VPuwzIymNdK0yUkmqstYMa74DErSA3fLrbPQwpO8AzaefM7fyE2RewS5RIdFfJbZGNqn QKuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ucyyQiGO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds11si2413228ejc.302.2022.01.25.00.50.16; Tue, 25 Jan 2022 00:50:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ucyyQiGO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1322355AbiAYDVh (ORCPT + 99 others); Mon, 24 Jan 2022 22:21:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1319411AbiAYDIt (ORCPT ); Mon, 24 Jan 2022 22:08:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93500C0FE698; Mon, 24 Jan 2022 13:44:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 596DFB811FB; Mon, 24 Jan 2022 21:44:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 740D0C340E4; Mon, 24 Jan 2022 21:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060669; bh=jHBt4D2LHkfF9t7FKzh7y8T3seROGWJIg2IRNcojcvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ucyyQiGOdoiSgLTnPHBAKn6Jgualeyrd7DjNcaryeIkLqdUgucHF0yt4DzG1DWly4 6INCzf4oLHUsnbxgTjP/2PjWGfXO9NCscTscSMeB07GMFEOtzrFSEzkH3XFfUtRMII Gp+dZOXAjDQaNa3LMGf2pKy3wgnOqntR3FSsKNy4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , Eric Dumazet , "David S. Miller" Subject: [PATCH 5.16 1025/1039] sch_api: Dont skip qdisc attach on ingress Date: Mon, 24 Jan 2022 19:46:54 +0100 Message-Id: <20220124184159.746106739@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Mikityanskiy commit de2d807b294d3d2ce5e59043ae2634016765d076 upstream. The attach callback of struct Qdisc_ops is used by only a few qdiscs: mq, mqprio and htb. qdisc_graft() contains the following logic (pseudocode): if (!qdisc->ops->attach) { if (ingress) do ingress stuff; else do egress stuff; } if (!ingress) { ... if (qdisc->ops->attach) qdisc->ops->attach(qdisc); } else { ... } As we see, the attach callback is not called if the qdisc is being attached to ingress (TC_H_INGRESS). That wasn't a problem for mq and mqprio, since they contain a check that they are attached to TC_H_ROOT, and they can't be attached to TC_H_INGRESS anyway. However, the commit cited below added the attach callback to htb. It is needed for the hardware offload, but in the non-offload mode it simulates the "do egress stuff" part of the pseudocode above. The problem is that when htb is attached to ingress, neither "do ingress stuff" nor attach() is called. It results in an inconsistency, and the following message is printed to dmesg: unregister_netdevice: waiting for lo to become free. Usage count = 2 This commit addresses the issue by running "do ingress stuff" in the ingress flow even in the attach callback is present, which is fine, because attach isn't going to be called afterwards. The bug was found by syzbot and reported by Eric. Fixes: d03b195b5aa0 ("sch_htb: Hierarchical QoS hardware offload") Signed-off-by: Maxim Mikityanskiy Reported-by: Eric Dumazet Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1062,7 +1062,7 @@ static int qdisc_graft(struct net_device qdisc_offload_graft_root(dev, new, old, extack); - if (new && new->ops->attach) + if (new && new->ops->attach && !ingress) goto skip; for (i = 0; i < num_q; i++) {