Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2846385ybi; Sun, 28 Jul 2019 19:22:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8Y9Kla4MjJ8Y7fiYky9uV+FAoqONepSXiS+pq2q4sQbW4m5HmC5OP7G/jJet1Vh6dNc8m X-Received: by 2002:a63:d002:: with SMTP id z2mr104607447pgf.364.1564366974985; Sun, 28 Jul 2019 19:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564366974; cv=none; d=google.com; s=arc-20160816; b=dM+CJqmsoJjw5QI4I2CT98KFmtLDcx2f8aFQJwUI1AkMQcvjYf5V38aSpPGGO7EfZ/ eIhF77ti07A07Zsdu25mMtDGH+Pf7s5E8cLfk5JMe+V+jlEsZ2X6IdHbDIMN9mRKFMjN l7k6Nold4Jt9j8MEOWLRSOEJH9LLVNF3ITWGl4mnuL3FiniKQV1T5ObRwfcEWY+T4MmJ xYbPOXkvoi7f4oVkEeyF86pt6RUrAAR7CZAn+NXOVrKL8xqQ6t0Wkvnz5hGR4Dhy9c35 ufWZJJTWcVvrJItU72xChFcgFS3520C+k435s1mJhtEl4rv0TQ1S/k0i7wgM6uW+T5HR NEEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=7fp1YuLIkMp6V8LF5r3sZVLgOMYUpY55IUl5NCyG7hQ=; b=isDdvXldoGRTQmP73gtcu20ic1q5mqjUrieD2A5sIP536jdNvH+6hCFIDGTn8VKyHf 2Oelz+7Q07pX6R+xxe7sF0bW4pVkv9YGWH7EKpcIAfZQf6++HJUyQyINeG/5NaITmzUa uarKVHyoNTCHNTS1pKbBMJdnqyLtF8cUWfDad9gLs9IdM3+X+j1DbGXaswOIHjUI//RG YO9F6QqCX4GlO2zOYsRdXK/lL+MyHuVvTDnNsMnNXNB3bUhQj4CXTMJzNzYWGXj7VHud LESP4UyfcBm9RA/IxoOAVlX3Kb/f0I7q9g36YtPKgyd3Y/Sne17aTpYAARsBqowfYAtA RZxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NDckJD4L; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v66si26380355pgb.584.2019.07.28.19.22.39; Sun, 28 Jul 2019 19:22:54 -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=@gmail.com header.s=20161025 header.b=NDckJD4L; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbfG2CWF (ORCPT + 99 others); Sun, 28 Jul 2019 22:22:05 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37853 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726251AbfG2CWE (ORCPT ); Sun, 28 Jul 2019 22:22:04 -0400 Received: by mail-pg1-f195.google.com with SMTP id i70so16664713pgd.4; Sun, 28 Jul 2019 19:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=7fp1YuLIkMp6V8LF5r3sZVLgOMYUpY55IUl5NCyG7hQ=; b=NDckJD4LK99YxCkG/Uove+eO+w0elZ6wg+NR79uzg5bvZfri5Opl3sEsl2Bkb2yBmV 0N3VNYxCruJ8jiyuya3Hrb2dsklL5xlB2t84gVkQYLy9urKgwj2wDLgtMp/KeZWYbN6Q i2ZGiaAf7R7iklB3W8KDkeo+fhhteBW95MKj0Vl/CZAd0d/LLdRxv9gCKfEV8sObclw4 3IQAVmsHDEHyGQlxWKvyGQ0TZkBmSVLNcYRDE40RGzdk3e2DTAHTzb0hUcRVEBdL3Br8 VQxG0Y8YqoGEwCS8MAABUrGvWsWSR/In0XlEXA6tnCeG2rAioJ4uimRuX1xHBdRd4y9p +KOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7fp1YuLIkMp6V8LF5r3sZVLgOMYUpY55IUl5NCyG7hQ=; b=LUsuLeaCz2wOOO5NnXlCGnw7q4ksK7vFVjNrSArcv+2d4u7lzYG5bwyn1SR1Wv7uNe s5NFqUEzPYTpn8Ec7ZnrxZyMeuyd45tMXJK36IzuG+wCJohUMP97dhdt73UB0+WRfwL4 5XobdpnpOYZqR/N2n0oQBA3QRF+81CUyN5KYinDrWeQvjzp8J4qQC9ZRWqCE9rE0o7vS Wtif62Q92BcNYqNlrELTZ8lfbzChLqk1y97FTsOjrZBLiTEvqTj7tndg1T64stARMM0N 0z/9S3o1v5b7hyREKIPswDtsR7vWxwsqn5sJObbrMZTv1isLLBwKW9lIH8pBTTFQMobJ vjHw== X-Gm-Message-State: APjAAAXZmE5IWpzFs7HSUk+xk6hlaeb7UrljYwlVcPURsO+yMmzFRvzq 1C/rzF+D9q0ffEEodUz6scE= X-Received: by 2002:a63:d04e:: with SMTP id s14mr97287640pgi.189.1564366924059; Sun, 28 Jul 2019 19:22:04 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id j128sm56150318pfg.28.2019.07.28.19.22.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jul 2019 19:22:03 -0700 (PDT) From: Jia-Ju Bai To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] net: sched: Fix a possible null-pointer dereference in dequeue_func() Date: Mon, 29 Jul 2019 10:21:57 +0800 Message-Id: <20190729022157.18090-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Jia-Ju Bai --- net/sched/sch_codel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/sched/sch_codel.c b/net/sched/sch_codel.c index 25ef172c23df..30169b3adbbb 100644 --- a/net/sched/sch_codel.c +++ b/net/sched/sch_codel.c @@ -71,10 +71,10 @@ static struct sk_buff *dequeue_func(struct codel_vars *vars, void *ctx) 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; } -- 2.17.0