Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2051359pxb; Mon, 12 Apr 2021 13:02:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrY1TtRep/d4FXOhwGglvNLxvVhKFmUDhXEMFvL09dpKj6taXIHfxJ0nln/mcEd5uOvMi5 X-Received: by 2002:a63:1425:: with SMTP id u37mr1509266pgl.227.1618257763180; Mon, 12 Apr 2021 13:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618257763; cv=none; d=google.com; s=arc-20160816; b=zmul+WDBPOBn2mCtxsIh7D+tLz65fDvUn34btOyzMWOZyyq99etKs553mZ719shD1C kcoRm5YkiMJavhTG4f6zAsRxBeBfweQKK3Uap9DrtrFwKUNkHIkfcw+C89R+yUDfAuqC tX4dQX/lU7ZIMuTqeUVqPbmyXqpu82nmsX76vnae0hiv8dMtc/56ciZCqmfg+MtDntbv jTo9p4vKMvIm2CQTUUXJLbt0+acI2qtQ3uITKF1n8vZc0to21ll/QhefW0HNgH7SlLa/ 6cd4fB85intSq+ulhFRSgCtYLxAoDDFjri+3Tls4GXHi4EH6uj23DJ5rERhG8LwNLBxx F5nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bLKYnArPRkxMafgEq7Wp73JGJZyZ3qgSwBbPVBJ7Dwo=; b=w2pTmpOJb8ADb+4Ba1SkAR3/lbOQv0cUV/MRX9csl4CWWOE3DT+bS2sifAaIm4H0F6 LTv6J1F66FD0HXeNq2YOqXBnWN6LbM8RzjhqE0sMAXEOwDXeS07a7EDEHVLLV+p+LK2K DJj3ujtWNgK4tR5IvKGbh3oU6fokZM6RyzQ0r4388HJnu1EhoE4zynm2zuMk4vajxhSx INJgCveE9IUMSxLpgMfFs3wwmo7WoTlkuzZUPGX0mewnc0grfpbLGhk1E9D311qmTuoP uCK0ba+vwTN+5Dqcd+91JD9F1Whunq8LzEHx2f6Gzv9K3OPbTehAekyE0CkrqDYg/44x V3GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gL0vidfh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fy4si453916pjb.57.2021.04.12.13.02.30; Mon, 12 Apr 2021 13:02:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gL0vidfh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237615AbhDLIoH (ORCPT + 99 others); Mon, 12 Apr 2021 04:44:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:35466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237534AbhDLIno (ORCPT ); Mon, 12 Apr 2021 04:43:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7B1E961288; Mon, 12 Apr 2021 08:43:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217007; bh=cmHVdTf/6f6hO/2gg50eFrVxz8QJJAGwBLV/6AxIydc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gL0vidfh/UbSeYJ82X9P2JBMgXKhnf1eYS3/y49TuHwmUHDVrlh3HbjESBEfvbaVh Yos4vBrjfOpFhlh1wicWkBgwPHReSqfSjUPeta7lKSDPhassPSW4i+j91DCMlfD1K7 uYLFlZNN5a8uRJASlRi9NGK8qecnGbMmp6jtM8TI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muhammad Usama Anjum , "David S. Miller" Subject: [PATCH 4.19 08/66] net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh Date: Mon, 12 Apr 2021 10:40:14 +0200 Message-Id: <20210412083958.410192221@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412083958.129944265@linuxfoundation.org> References: <20210412083958.129944265@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Muhammad Usama Anjum commit 864db232dc7036aa2de19749c3d5be0143b24f8f upstream. nlh is being checked for validtity two times when it is dereferenced in this function. Check for validity again when updating the flags through nlh pointer to make the dereferencing safe. CC: Addresses-Coverity: ("NULL pointer dereference") Signed-off-by: Muhammad Usama Anjum Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/route.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -4514,9 +4514,11 @@ static int ip6_route_multipath_add(struc * nexthops have been replaced by first new, the rest should * be added to it. */ - cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL | - NLM_F_REPLACE); - cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE; + if (cfg->fc_nlinfo.nlh) { + cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL | + NLM_F_REPLACE); + cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE; + } nhn++; }