Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1876136lql; Wed, 13 Mar 2024 10:29:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUpTxkSu8yFhhVuhp5KadXHsK8SpZHM+4Gn/cZHrXyEuVmzyjiBM27Mi9YhgWEQdQVwpolvJvg4iwGN2oNSfUKhQAHweGUY6rFYpoVUTQ== X-Google-Smtp-Source: AGHT+IHvEnJkqOlp0uNlGAd8S547WXuq8zFjNJXbOY9QjX856jCV1rQFdAoW2Q5HHrJl7VzoDChB X-Received: by 2002:a17:906:ba84:b0:a45:ad29:72e7 with SMTP id cu4-20020a170906ba8400b00a45ad2972e7mr9683022ejd.36.1710350949777; Wed, 13 Mar 2024 10:29:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710350949; cv=pass; d=google.com; s=arc-20160816; b=NpNlr0woGKWP23I/JWoedUsIseBDiUYJlN0XL1wfwCuXz4dVvZ4dwiqH3Dmq8QnJN6 efNjHK9A8YPpEJ64z6qTg3vj84xHmSvTLx54+Y2/MdBu0FlFi1zH/c8CvPqMU8E0Itfz KW1G3EA3Yzg9pgbQ8P4etFA57rCHLvnkdW9aKxrlfm7AFGIoG3Q4ls5aooVn6+/zlYPD +0VoOkmbLXmbMLBgChSxYd2PMYk8IZhjPpdyVGMWVsOSJQWjTVSGMWPEW81Xcu4p2GCe INALkWbpeKugmBs7Z6Ts3Gret0DmxFM5dWyBnjHSUBCOmPl0vKd6FIm8BwA88RyXuJb+ WqMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ySRx3MXC/6xzTtc3pQnA5XGYryWKvzBtxUH2+nV+Nw8=; fh=b7FykSoXLOnj6aKUKR1n5Zr5fbYmOPFLxyzJwBcIv/M=; b=I0V0wq282hgumsih6+gqf8qCNL+kewWYFr7ziLllnm+CQUi7ymkpb+bbQWtdp2gAmb E/Zw3WXalmNOde8hmlSehqumpgpoZnNnqG427bX6WX/sTzLvnTDUmkKCiBzKSd/D8/6Y WfkxLCgVwDnL/Xb/FBWiapAF9OPKlJ2DwG3GZVMPLJodV5QpCl6aCm4rEAyxqIhZkuRY 5gEOIi1pHIbgilPRoq44xXUDgQhj/jH2EYbIZ2/m7fwydohkuHhiTzUq3JRzEHB0HRYA bRED9jfNKKneP1s8FzxmCSGN86jAspPNssoagAGi0DQeZQ3JS+ST5n7w+8kgDr+pc6T2 /O6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ucixwqT4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101878-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id di9-20020a170906730900b00a4669becb68si154808ejc.873.2024.03.13.10.29.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:29:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ucixwqT4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101878-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CEA6F1F2A847 for ; Wed, 13 Mar 2024 17:06:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 698757765E; Wed, 13 Mar 2024 16:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ucixwqT4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D6BF7763B; Wed, 13 Mar 2024 16:40:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348012; cv=none; b=Ej2R+RGnQqBaDNyhsgz7IPnzMFDzrNCUaxdeg8F8YMETlriSQ3QIxYSLI1QB2PrqE9MJHwFCRWAfgEWtRWLYZlf0z8/g7B3spge+BF5yvp4x5yjc2CLEQdUjaMxYgCovUWGaQfcaurZZA7nAVgGn/CU731ttFUDXp6gFVkMHGIM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348012; c=relaxed/simple; bh=2V2Bq/MN+rP82veBxozgfmRQQZwAkbRMpZsbmWuJCLE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TagUhyl76cKRAyXKIzvbhZX4DGrurUTies5BVK2iOS3c3Mf9ojBlCnvdw8Rq9F50+pYaMqwNiranZhoDAJepqlkBNdccaxm6Q3Iuj5x8i3LtiOyWyotQwRAzup9Oh+KoqDuXta51oFV4LlKTfAP0b/kI/a9ln/lOFlSnErxFUbM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ucixwqT4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CB31C433C7; Wed, 13 Mar 2024 16:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348012; bh=2V2Bq/MN+rP82veBxozgfmRQQZwAkbRMpZsbmWuJCLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ucixwqT4EG/BKqxRLSboO3CaosWWCK8JSLA1SCIUoq7NS552mjm0TJ8eKWxBoxqFk RPcK3t+BaFIeMnPTpr+rrVeHLK+Q/iYCziA0jYqiHNKqgGEcXYX9Qij3LwT3lVxaFg 5uIQTP60FEO49eMGJ8lC4LD3hdt8wpjviGNmgnup3T6/PFOYVvZ1INcc142qHnwUCD 23z9YKy3uHuN/39mMuGxzhzhZgSeODAVb+SZYxIoGTeTChr76zljQUhwvbqWtX0kEJ qp3UVDuX7g4Xd5DqzFYxbSMIVJERPuE5tscA8Zd1l8obnT1RYh18VE2U4RrGzaL7pu 3+4KuCdTtLMPg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Rand Deeb , Simon Horman , Tony Nguyen , Sasha Levin Subject: [PATCH 6.1 10/71] net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink() Date: Wed, 13 Mar 2024 12:38:56 -0400 Message-ID: <20240313163957.615276-11-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163957.615276-1-sashal@kernel.org> References: <20240313163957.615276-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.82-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.1.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.1.82-rc1 X-KernelTest-Deadline: 2024-03-15T16:39+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Rand Deeb [ Upstream commit 06e456a05d669ca30b224b8ed962421770c1496c ] The function ice_bridge_setlink() may encounter a NULL pointer dereference if nlmsg_find_attr() returns NULL and br_spec is dereferenced subsequently in nla_for_each_nested(). To address this issue, add a check to ensure that br_spec is not NULL before proceeding with the nested attribute iteration. Fixes: b1edc14a3fbf ("ice: Implement ice_bridge_getlink and ice_bridge_setlink") Signed-off-by: Rand Deeb Reviewed-by: Simon Horman Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index ab46cfca4028d..3117f65253b37 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -7681,6 +7681,8 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, pf_sw = pf->first_sw; /* find the attribute in the netlink message */ br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); + if (!br_spec) + return -EINVAL; nla_for_each_nested(attr, br_spec, rem) { __u16 mode; -- 2.43.0