From nobody Thu Sep 4 03:26:08 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91656C54EE9 for ; Tue, 13 Sep 2022 15:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235569AbiIMPKe (ORCPT ); Tue, 13 Sep 2022 11:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235665AbiIMPI7 (ORCPT ); Tue, 13 Sep 2022 11:08:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACE2175FEC; Tue, 13 Sep 2022 07:31:25 -0700 (PDT) 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 1E3B1B80F10; Tue, 13 Sep 2022 14:30:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 813E7C433D6; Tue, 13 Sep 2022 14:30:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079411; bh=Skxu6Kv5ssBQyZSPlWI5KDMZ8WTZbUPGO4+ITBNnGfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wTwo6VA+9SQ/Il+r0qqixblJBIDDY9fykAjOI87MP5aSIM0MOxgbSJi1t/oXkfUef ssyOlw5SsZwH/vPqn739CrFlQ8ZAO9xB61kzjLN7Fk6gH3Cp5BQuapicFsZ8b5lbr+ Bbt+YK2OXjbzAYkYl4+AH563cM5EiUBjuzneaD48= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Jakub Kicinski , Sasha Levin , zdi-disclosures@trendmicro.com Subject: [PATCH 4.19 16/79] sch_cake: Return __NET_XMIT_STOLEN when consuming enqueued skb Date: Tue, 13 Sep 2022 16:06:34 +0200 Message-Id: <20220913140349.652764189@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140348.835121645@linuxfoundation.org> References: <20220913140348.835121645@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Toke H=C3=B8iland-J=C3=B8rgensen [ Upstream commit 90fabae8a2c225c4e4936723c38857887edde5cc ] When the GSO splitting feature of sch_cake is enabled, GSO superpackets will be broken up and the resulting segments enqueued in place of the original skb. In this case, CAKE calls consume_skb() on the original skb, but still returns NET_XMIT_SUCCESS. This can confuse parent qdiscs into assuming the original skb still exists, when it really has been freed. Fix this by adding the __NET_XMIT_STOLEN flag to the return value in this case. Fixes: 0c850344d388 ("sch_cake: Conditionally split GSO segments") Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-18231 Link: https://lore.kernel.org/r/20220831092103.442868-1-toke@toke.dk Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/sch_cake.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index 18c207b85d513..c0a6947545280 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c @@ -1666,6 +1666,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Q= disc *sch, } idx--; flow =3D &b->flows[idx]; + ret =3D NET_XMIT_SUCCESS; =20 /* ensure shaper state isn't stale */ if (!b->tin_backlog) { @@ -1726,6 +1727,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Q= disc *sch, =20 qdisc_tree_reduce_backlog(sch, 1-numsegs, len-slen); consume_skb(skb); + ret |=3D __NET_XMIT_STOLEN; } else { /* not splitting */ cobalt_set_enqueue_time(skb, now); @@ -1849,7 +1851,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Q= disc *sch, } b->drop_overlimit +=3D dropped; } - return NET_XMIT_SUCCESS; + return ret; } =20 static struct sk_buff *cake_dequeue_one(struct Qdisc *sch) --=20 2.35.1