Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11569193ybi; Thu, 25 Jul 2019 19:26:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXtrIKs4yL9uZZO4ce3LDrqLBAQ9LH0ZGx4wOwvAXDZJj7aWlAx9hkcwtxmAjvQeiLooFd X-Received: by 2002:a63:66c5:: with SMTP id a188mr88666907pgc.127.1564107979756; Thu, 25 Jul 2019 19:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564107979; cv=none; d=google.com; s=arc-20160816; b=qSZ5vY80iOZHLAfvnIp1YLOIzUCfCx/QFkLTNsFoBOhzuIjefubdcRCjHULpVC3TAy i38MsRC7BSDJiDAVW9zyOEghRvwZi5TIy9FY3v9QezGRualIEHRmbOSwJKAig+X0UWcJ Tal6IKaEMjqMUgVBNlrM67KiORLUzcFO1W0U4h/et1vy6bxYJW2KQ6SRvZiUaX22+1sN CNWVPJPd7qLUZrtK03cAG5S254v69Jv9/tK7knEhSgmGtlnhtXIMFWqsR7lJQCsH2PjQ RaWlR8hHW5o2QxnQRMZxaxFQVnOhT3LwIZ+berYhAhe7FzO39MokrJRRwRjhI8zcL2PE 4WXA== 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=cepRcJFNdm0krVpqW6DO9gzxmkMHHb5KLKaLQ5UTyH8=; b=E0Edp9R7BR4acuU9n3gpXfeaClldcRfAdWPApaTt/TMV4LasE5bvQvcsK2s9Igxx6r hecV1o4lXBXplmftGXcky0YXsBc/lRegVtCTFVDBrismqZafsZFwdfLu7SrVPSE8uBmh sRgt9bOJTTyK4yldGirXhzS2Q+K19RBe6n7OPR8uAtfGqjuPRiKVHCFdp4LQWmvVU0wP rsUwn3uGCdUXOZp5hV6HBKqyXuTOiQaQiynX+IZnRPAAXqI97O5NZNCDV9zPg8BpLaXM 2uPF2VJBPWOyraiU5xTNYTrEKMAkeQR4LF0G+pAUdPJtsOvVLi7FFXfbOEdowab9wX9u Bj3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K78OYLh7; 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 r71si20000998pfc.152.2019.07.25.19.26.04; Thu, 25 Jul 2019 19:26:19 -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=K78OYLh7; 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 S1726191AbfGZCZM (ORCPT + 99 others); Thu, 25 Jul 2019 22:25:12 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42055 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725808AbfGZCZL (ORCPT ); Thu, 25 Jul 2019 22:25:11 -0400 Received: by mail-pg1-f194.google.com with SMTP id t132so23965171pgb.9; Thu, 25 Jul 2019 19:25:11 -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=cepRcJFNdm0krVpqW6DO9gzxmkMHHb5KLKaLQ5UTyH8=; b=K78OYLh7hUM7NYoZlo/ezQ8HwVYNuZ61/Z8S429pPWg2irUhbSOVqUUuYzp0iDX/Jd SncaE1JfEm6w2nKX30MTCp2iB1qlc6jyMuC0mIdjxhyX9m6/bDQuw8yvcaxZ00FcsxWk TFFsS2LQu9a0+UjbnUZl158jxLGPfyCZ3qP6qCANivPuDH78rKV8ktA005lROQE7CivA LOrzulfln+8JlKG7CNh8GORqQm+HdccEOqfPjzCDIleG9VVUH9iNyTJp0oHRBXy9pAla 2rcmQkH1UVrSmTFXIFFpTjeKXFjn0OjS12hS+LvhH8Fq1Np5FeiOpxKx/4yT2p5sX2UK sxUg== 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=cepRcJFNdm0krVpqW6DO9gzxmkMHHb5KLKaLQ5UTyH8=; b=monhcPQKIzzLrsTTZj0udcDTmNK6qxs8Yc47De8LUS78h4T6/jSwFYx0W6qN5Amt7T 7pT+qsmboL7NhFk2WAUZwQdMG+7DEegaffbmdV6n1sO0/qoRZ4ocBs2/p97O5DLH0UTW /rg7EzJ0QhPl0b7IV6D753LqI5m0LD3X1W2IOl4eETY0TUAVKecl3NQAH+gk5Xmu2nb3 uaiH/IdwbF8IBn3zDdylC8etWYnZSV2e4jhKbehgcytkKFzfnhDggQZ/Tsa1ntllC9Gq E+i46z/ckTd3ziZrYGbC8eJ6uzs7UwytDzClQyIXC1DHfgaEhhZ0mpko5N55B6b0iSA7 0EwQ== X-Gm-Message-State: APjAAAUiHlZZc6HYsW+JRbToTytAya2wAQaAV8fLKJyIDC3WVlA0TU2+ cICwsfJwWLyuy67JqKNavR4= X-Received: by 2002:a62:fb15:: with SMTP id x21mr11759590pfm.233.1564107911329; Thu, 25 Jul 2019 19:25:11 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id w18sm64658103pfj.37.2019.07.25.19.25.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 19:25:10 -0700 (PDT) From: Jia-Ju Bai To: davem@davemloft.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 2/2] net: ipv4: Fix a possible null-pointer dereference in fib4_rule_suppress() Date: Fri, 26 Jul 2019 10:25:04 +0800 Message-Id: <20190726022505.24938-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 fib4_rule_suppress(), there is an if statement on line 145 to check whether result->fi is NULL: if (result->fi) When result->fi is NULL, it is used on line 167: fib_info_put(result->fi); In fib_info_put(), the argument fi is used: if (refcount_dec_and_test(&fi->fib_clntref)) Thus, a possible null-pointer dereference may occur. To fix this bug, result->fi is checked before calling fib_info_put(). This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- net/ipv4/fib_rules.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index b43a7ba5c6a4..daedce293aab 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c @@ -163,7 +163,7 @@ static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg return false; suppress_route: - if (!(arg->flags & FIB_LOOKUP_NOREF)) + if (!(arg->flags & FIB_LOOKUP_NOREF) && result->fi) fib_info_put(result->fi); return true; } -- 2.17.0