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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS 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 0E0F2C10F11 for ; Mon, 22 Apr 2019 19:22:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE8BC20896 for ; Mon, 22 Apr 2019 19:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728497AbfDVTWp convert rfc822-to-8bit (ORCPT ); Mon, 22 Apr 2019 15:22:45 -0400 Received: from mga11.intel.com ([192.55.52.93]:61763 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727670AbfDVTWp (ORCPT ); Mon, 22 Apr 2019 15:22:45 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Apr 2019 12:22:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,383,1549958400"; d="scan'208";a="136423401" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga008.jf.intel.com with ESMTP; 22 Apr 2019 12:22:44 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 22 Apr 2019 12:22:44 -0700 Received: from crsmsx103.amr.corp.intel.com (172.18.63.31) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 22 Apr 2019 12:21:42 -0700 Received: from crsmsx101.amr.corp.intel.com ([169.254.1.94]) by CRSMSX103.amr.corp.intel.com ([169.254.4.179]) with mapi id 14.03.0415.000; Mon, 22 Apr 2019 13:21:40 -0600 From: "Guedes, Andre" To: Cong Wang CC: Linux Kernel Network Developers , "Gomes, Vinicius" Subject: Re: [PATCH 3/5] net: sched: taprio: Fix null pointer deref bug Thread-Topic: [PATCH 3/5] net: sched: taprio: Fix null pointer deref bug Thread-Index: AQHU9xUBQFJxoKDFEEuAenXzsmJROqZI4hOAgAAAuQCAABTVAA== Date: Mon, 22 Apr 2019 19:21:39 +0000 Message-ID: References: <20190420000052.4242-1-andre.guedes@intel.com> <20190420000052.4242-4-andre.guedes@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.24.12.83] Content-Type: text/plain; charset="us-ascii" Content-ID: <92B238FD53915B4198A9E2531D0D8FFB@intel.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > On Apr 22, 2019, at 11:07 AM, Cong Wang wrote: > > On Mon, Apr 22, 2019 at 11:04 AM Cong Wang wrote: >> >> On Fri, Apr 19, 2019 at 6:06 PM Andre Guedes wrote: >>> >>> If 'entry' is NULL we WARN_ON() but dereference the pointer anyway, >>> generating a null pointer dereference bug. This patch fixes should_ >>> restart_cycle() so we return if the pointer is NULL. >> >> Hmm, while you are on it, how is it possible to have entry==NULL >> for should_restart_cycle(). It is only called in advance_sched() >> where entry is already checked against NULL right before it, >> so for me, entry is always NULL at the point of calling >> should_restart_cycle(). > > I meant, 'entry' is always non-NULL here... I typed too fast. Your assessment is correct. I believe the WARN_ON() was added as a defensive practice to prevent null pointer dereference in case someone misuse that helper in the future. - Andre