Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp339924ybl; Fri, 9 Aug 2019 06:49:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVSpPY2D2hQjyHImyLQ1aWSZgFRO5Amg5kSWonHaogUynCdbC03UlO6dM/xHhkSVufZ4by X-Received: by 2002:a17:902:ac87:: with SMTP id h7mr19754424plr.36.1565358596663; Fri, 09 Aug 2019 06:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565358596; cv=none; d=google.com; s=arc-20160816; b=oLR9SLc1v4eRrp7ZSqKpFT1EV9csdzhLe6sfDXUbLg8ABMvyMSD7xQ5YLJ2+Lz5ssf uIbpT+u2Eh3BgYfbAaH8gQB97k4UldbLfbOE3wBm8dGH5o+iFTUu9F0D1E47erkVXkFp oG3iBogJhYjB2gkXVDYcgl5xIeqZ7RUEHKLSa42zYAF5AkAYcb8mprrr9roRCcvqhbeR +4oUcZDu7RPzA/jgcHprwZCrSe12uhoT9CEj7MmxV8S0eVGlMegCJjXJaOSWuWVYFpSH cNm9nKlsbhZ0MeSkWN5OZn5eGNoghwvq8oyasv3aacjRTxlbgEDKSmwfks/pFavnsHmL iRhA== 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=NAbd7pK121FyYxOI5HqJC2uh2xWL91aYBqFO84VTyNc=; b=Vk25EkdqXRB8IvSP16X08CTWpSeYhxk2MZkfjUK7wrZBOhA0ib3DBujVQNKWyibug4 DDU4pkwAImlx/rFK/0LU8mawv82BIZI6Oa/mpirYRwcmSdpjEu8DujvsiHa+iuyIxQvA ufpWThiuozCCewdSeKOdNY4ImKmxGduA613OEVZsUqyxFBfXOsOxLBodYW458SKGWw51 D2ATPY1MMycGlv+Mh6IEC/ApHH6iKZE9/xoar70maczoLu4Z+paG1AExciw1Zg1O2zZs 2/Cdnu61gevs8wpNySTpCqYnxuEADc/yO6vjbNMJfY6p1drRy2XqMdm7LYpVLonjoxx6 9W2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iXMD4B0R; 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 f1si4351361pjs.86.2019.08.09.06.49.40; Fri, 09 Aug 2019 06:49:56 -0700 (PDT) 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=iXMD4B0R; 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 S2406722AbfHINrN (ORCPT + 99 others); Fri, 9 Aug 2019 09:47:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:37080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436577AbfHINrI (ORCPT ); Fri, 9 Aug 2019 09:47:08 -0400 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 8109A214C6; Fri, 9 Aug 2019 13:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565358428; bh=5O/qCdf5EeoEXV+hINy4coar5n+yKm8x+R7wXINU+U8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iXMD4B0RTMe0DnBVRIJ2I0vMXPw6sGkEcpvI5bZ8LuCAh25CAmXRXF3zd+1tPibjs 5Zthbcj9v/iz5AftRxQHDoAMsfeixxCEzgrD4ESB4ZxrEjnzCnGbSu4NZUBmdY2R+X 1wochU3mfRAiwNwjQtey6OAKuVTj2Gp812lNlhbo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Jiri Pirko , "David S. Miller" Subject: [PATCH 4.9 20/32] net: sched: Fix a possible null-pointer dereference in dequeue_func() Date: Fri, 9 Aug 2019 15:45:23 +0200 Message-Id: <20190809133923.599973260@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190809133922.945349906@linuxfoundation.org> References: <20190809133922.945349906@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: Jia-Ju Bai [ Upstream commit 051c7b39be4a91f6b7d8c4548444e4b850f1f56c ] In dequeue_func(), there is an if statement on line 74 to check whether skb is NULL: if (skb) When skb is NULL, it is used on line 77: prefetch(&skb->end); Thus, a possible null-pointer dereference may occur. To fix this bug, skb->end is used when skb is not NULL. This bug is found by a static analysis tool STCheck written by us. Fixes: 76e3cc126bb2 ("codel: Controlled Delay AQM") Signed-off-by: Jia-Ju Bai Reviewed-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_codel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/net/sched/sch_codel.c +++ b/net/sched/sch_codel.c @@ -71,10 +71,10 @@ static struct sk_buff *dequeue_func(stru struct Qdisc *sch = ctx; struct sk_buff *skb = __qdisc_dequeue_head(&sch->q); - if (skb) + if (skb) { sch->qstats.backlog -= qdisc_pkt_len(skb); - - prefetch(&skb->end); /* we'll need skb_shinfo() */ + prefetch(&skb->end); /* we'll need skb_shinfo() */ + } return skb; }