Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp466682ybl; Tue, 28 Jan 2020 06:25:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxj+ldFsC6XSHdwJukXtKixst7u//XTwsQY+dKUa91ls6xTj2Za0FcbcJJg9q2TrWoUvQQm X-Received: by 2002:a9d:12cf:: with SMTP id g73mr15846051otg.329.1580221503823; Tue, 28 Jan 2020 06:25:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221503; cv=none; d=google.com; s=arc-20160816; b=rDZhrA2mQ3Md1+Q1WQR9RCR5qzxWzoHsvYUVTKPd4ALF1Yk4Akj21qQio+7FmMgVxc VG2IQnNeDcA5R+v9bpy4sOA3KYWD0V37ZJPZF6fN8NpbzkY8WxBOAyYyOUU2SfB/9WV+ 3ErWxDfOSsCIPQYmAZWtyhGxV8cZwGeG2gAsYvngWXE+AkV2OraOd299tYBh7IzGKVDy 8TIbQ7r9i4w5Qf4C7vGGebmMy5SgocgeoiiSRoRjT1JpIhI6w0y2d7RBRJ68HfTEiOOp jTs3fHIhdB71ZWRS/KRvmlQxgU7EerQG54MW1gfQwvaxlgCiKOSnOx8bcRVpzNkJT2pl nrYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GYkAQaMaDHAQ33SHbikMUbc81Me2E/UO1TLnesQZRHk=; b=bnQunvAP/OGledbKlPRQmL4XUL9xrY41i0f9cTOuw24+p6iWpV/J6mn+I9KVZqzG1T 98LS0uIAaGXRlPJbpMYSPRkGLaBzQPuqBDbmDcYQudv2/uWu0EqmQ5mfmS9oFi76rMS9 DyenfsTFngCHJnjGi1+hSnobTRmrUxV155XnBlHEXE3DiDgFFpf83R/lKO3W5m1HpesD AjQp2egRH4mWFt8N6y0NNljQW1igxNMxlIGaTMyBZFyx7l0jaMjjCRHpdn93dJx0h0C8 ABXmis1I6I9U5L7cpokb3Fchl6aVQQEkzufy/C10NH1vZEVwpbQw77Noi3sEeK1tv4I/ myMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="aUn/l8Po"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8si9134153otq.262.2020.01.28.06.24.51; Tue, 28 Jan 2020 06:25:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="aUn/l8Po"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730877AbgA1OXv (ORCPT + 99 others); Tue, 28 Jan 2020 09:23:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:50024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728763AbgA1OXo (ORCPT ); Tue, 28 Jan 2020 09:23:44 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BD6824688; Tue, 28 Jan 2020 14:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221423; bh=Ie5ac0/XrS9CVpHlpHaFvjt+q9xSY7ZqJ+bgBdImDwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aUn/l8PoMElI08gSPCxK/4XXyPjCBFn05x9vUMArKoQBvZ+QbcJ/dT3j11Zwdv1k7 oxABQLgw6qOXVArBZo864M40akHYdlvB7O7xSHKzqj2Aisgzw6yQnfEC1Q+T23yvOR uDo9MHtDqG+5cLsEB5bj4AafiwiNX9lmh6VJzZY8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kbuild test robot , Dan Carpenter , Ben Hutchings , Jakub Kicinski , Simon Horman , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 217/271] net: netem: fix error path for corrupted GSO frames Date: Tue, 28 Jan 2020 15:06:06 +0100 Message-Id: <20200128135908.697925823@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jakub Kicinski [ Upstream commit a7fa12d15855904aff1716e1fc723c03ba38c5cc ] To corrupt a GSO frame we first perform segmentation. We then proceed using the first segment instead of the full GSO skb and requeue the rest of the segments as separate packets. If there are any issues with processing the first segment we still want to process the rest, therefore we jump to the finish_segs label. Commit 177b8007463c ("net: netem: fix backlog accounting for corrupted GSO frames") started using the pointer to the first segment in the "rest of segments processing", but as mentioned above the first segment may had already been freed at this point. Backlog corrections for parent qdiscs have to be adjusted. Fixes: 177b8007463c ("net: netem: fix backlog accounting for corrupted GSO frames") Reported-by: kbuild test robot Reported-by: Dan Carpenter Reported-by: Ben Hutchings Signed-off-by: Jakub Kicinski Reviewed-by: Simon Horman Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/sch_netem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 308d92491757e..11c4c93f5ded7 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -510,6 +510,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb)) { qdisc_drop(skb, sch, to_free); + skb = NULL; goto finish_segs; } @@ -586,9 +587,10 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, finish_segs: if (segs) { unsigned int len, last_len; - int nb = 0; + int nb; - len = skb->len; + len = skb ? skb->len : 0; + nb = skb ? 1 : 0; while (segs) { skb2 = segs->next; @@ -605,7 +607,8 @@ finish_segs: } segs = skb2; } - qdisc_tree_reduce_backlog(sch, -nb, prev_len - len); + /* Parent qdiscs accounted for 1 skb of size @prev_len */ + qdisc_tree_reduce_backlog(sch, -(nb - 1), -(len - prev_len)); } return NET_XMIT_SUCCESS; } -- 2.20.1