Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2118134pxb; Mon, 12 Apr 2021 15:05:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+Afpqg4PHkiF0xwP7+inufgBXxHtSWbRnla6aVp5w+Oeanr6x34dTl3oYr9lyeUTEcypN X-Received: by 2002:a63:fc58:: with SMTP id r24mr29086324pgk.368.1618265136926; Mon, 12 Apr 2021 15:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618265136; cv=none; d=google.com; s=arc-20160816; b=qV+EU3FvXVA2L/w8S680mG5klCpxzUOD0plBSbCWj9ZzSb4WHGwDfSuY7IgJyZY5nK gl2Ehc6Nx4hWCXLYGeHqcblPhpHyysdZlCenpW+SFg6KzuwfFAOPSCko7qsTgCGkpZ1e MAeQpGQSrp4pP3ygPUfTGZNtdslB8LnBqbE5hPt/q7HZ5WD9PAkmttE7JxrC8I17ibsq DTlJ9qXqW8dFUiCYle3dZO4t62PQFditJD12Ow6YlpowCrnhunBWfcpfnnjj11MNqVj3 G9mxOx+CB3jCYECLuGl0QQtTjTIpZg7dfMbv0iYb+S+KYSwCZdi/jWdTvXrG0gCujwnh JbMw== 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=YZ+qsiGPr4QMSPycQFlgXKSX+xMdPdFIQgoHQbOAErs=; b=VMFo6XoEu4FDtAbKeN0Co6/bmtoKqe3nkCfgZyjaEPd7WXOHIBXppuQX5xHYNqdb5M dHixvsqd2hWIuntQPy9YvMuR60aP4BvoORFwPai7SQVxSTu2XqoD7BCJM8Efarkz/ODE Lao2IjXdQvL815qH+5K8qScqgyLLAT0devgwadDiBum9ItcY6NIFISX3eTR8yXhT+kS+ LzpdOUpU3p4eUvbLIEmECw7wb6Zs95cqFMY7FVGIbGD3cfMw6grMUfTEfDVul148Ras5 PhM0qC9g3k2M1n2qbItGsgNAvfA023zzRICkCvfA0s9dvr5DqGFhxHNTg3evNSJKpH62 fJfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yYhMREDz; 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 r11si5787822plr.376.2021.04.12.15.05.23; Mon, 12 Apr 2021 15:05:36 -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=yYhMREDz; 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 S240929AbhDLJY6 (ORCPT + 99 others); Mon, 12 Apr 2021 05:24:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:54822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237550AbhDLJBl (ORCPT ); Mon, 12 Apr 2021 05:01:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4779961382; Mon, 12 Apr 2021 09:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618218022; bh=xP7z3D3xVMshlpGHETo/ZM6PXFeJURpMtgodQtBDOm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yYhMREDz7QUDAunhzeYHMMSUyqOLKc+U2N+M2JJLDeCstdHQOhyJYKHV7wALF9tQZ ShcBRFDH9oq2hZAV8rsWb1t0Lq6f8mYtf3FtJSAq9kd2vpbRCklFpDzIWeJ9lz1zFf t7wTqGO4Z8bkxHQdJ3qrR+GrySQR5wHgi+dRyhlk= 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 5.11 015/210] net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh Date: Mon, 12 Apr 2021 10:38:40 +0200 Message-Id: <20210412084016.513159862@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@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 @@ -5203,9 +5203,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++; }