From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5510BC31E40 for ; Fri, 9 Aug 2019 13:48:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21ECC2086D for ; Fri, 9 Aug 2019 13:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565358529; bh=5O/qCdf5EeoEXV+hINy4coar5n+yKm8x+R7wXINU+U8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qkMAx8HnvJBTTIzHk0xBcru++0o4S7CWiHfqVd3iuCff6qV5DFUl8bBAJViKKIc/e M8dWZ7fpmybnmb7/cUadluFnTo2wh1o3ULdxZ4fOEnptxpZduaRMIJWULsVaFzAREA L9548pIfyTbX1+3d9QT/G8Tbo4mJ1pgp5f+ALQtM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436590AbfHINrO (ORCPT ); Fri, 9 Aug 2019 09:47:14 -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; }