Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9092321pxu; Mon, 28 Dec 2020 06:27:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNG1UbZJwlrVJWZTQ0v/kC0KrDAoqCz27tcj9pP6sjTS7ZLMRiDDTmypIG3cmS31gSW+Gz X-Received: by 2002:a17:906:4705:: with SMTP id y5mr41513223ejq.112.1609165630159; Mon, 28 Dec 2020 06:27:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165630; cv=none; d=google.com; s=arc-20160816; b=vElH9xh5qQTQ0A26vzS72aWznOcMKjzXgVHnOHDlXrldv3WcIHd7gtIIM7it0tx43K TGYrDpVWEFjA2XRLT8XIxGyHU/Uwjc4QswgIvxWqf+UmEhdetnmVnKu+g1dWR4ieuAqf kcrKBByBt91iqFNdLwB8Urk7189OaCLfU4HhFryR2Xja6JWuZ7RCXl+i6S4psYt0MYUr U+GtvABAO9kXvbbHaDbZhLo93oQxpMbMrIUDONl31MlD4XI11vVFChkxKzuj79yc7/NK 3lPQbxm0USseKzlAIb/rT5dUZk0hcKmDelI/WQkp/O9a/2A8PxDyGCJlFuTH+uDWidHm 23zQ== 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=Og2amC9itmezEk79ECzYbZc4/1QOK77HcB1dFc2f4YY=; b=hTPMcLvZooR2qFsgOL+jh6H4Sxe/BAHANumcEWQRCfKNnw35+A7hOa+WKDJiZRmMFi YANjT8JHNuhw3ZJHmpmlGfKsN/2i+Lue8VyT0SgclQqYQgEn/c4L7R5Jzdu3mehEcaxL w8j4GPPc7mBL9ZDlfBMRd0tfazw1OUR9Ws6whknwWOH4uTxQ0Xtj7/dWNQVNtobSrUff k5/oVW0AH/+YIxuQBLF/BjugiEn/tFjzr0GJMSJjuPcdnov4hJClx9YeZwa9Py8Wkl6i 4nO3vVYN6G8Kz+yIa4In1/UePameme3wcn606+S1vIpa1ydw+7uj9b/tn7dTd7WTtlbX SdjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ga+xZGWj; 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 b32si21077211edf.406.2020.12.28.06.26.47; Mon, 28 Dec 2020 06:27:10 -0800 (PST) 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=ga+xZGWj; 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 S2503122AbgL1OYl (ORCPT + 99 others); Mon, 28 Dec 2020 09:24:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:60706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503114AbgL1OYi (ORCPT ); Mon, 28 Dec 2020 09:24:38 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7FFA0229C5; Mon, 28 Dec 2020 14:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165438; bh=3EEhOlEurmIC09uDV5qvb5mP6poKmMSiplCtiTjKOdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ga+xZGWjuAOPxtxGaTaPXm46X15wI+iNGIgmAwi5WMqb/Mc9atyviwCLQT1adsykm +m7q6kSvv5JtodJtfPnSnvLbzJIXtOlpJ+0hCQwE0wFzadQm2MohKzePSCBv2bvYNh 12q9s4w6igIstYjnh/f13KXIPkjXyQfjkW1cnhHM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Dan Williams Subject: [PATCH 5.10 531/717] ACPI: NFIT: Fix input validation of bus-family Date: Mon, 28 Dec 2020 13:48:49 +0100 Message-Id: <20201228125046.408298346@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Dan Williams commit 9a7e3d7f056831a6193d6d737fb7a26dfdceb04b upstream. Dan reports that smatch thinks userspace can craft an out-of-bound bus family number. However, nd_cmd_clear_to_send() blocks all non-zero values of bus-family since only the kernel can initiate these commands. However, in the speculation path, family is a user controlled array index value so mask it for speculation safety. Also, since the nd_cmd_clear_to_send() safety is non-obvious and possibly may change in the future include input validation as if userspace could get past the nd_cmd_clear_to_send() gatekeeper. Link: http://lore.kernel.org/r/20201111113000.GA1237157@mwanda Reported-by: Dan Carpenter Fixes: 6450ddbd5d8e ("ACPI: NFIT: Define runtime firmware activation commands") Cc: Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/nfit/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -478,8 +479,11 @@ int acpi_nfit_ctl(struct nvdimm_bus_desc cmd_mask = nd_desc->cmd_mask; if (cmd == ND_CMD_CALL && call_pkg->nd_family) { family = call_pkg->nd_family; - if (!test_bit(family, &nd_desc->bus_family_mask)) + if (family > NVDIMM_BUS_FAMILY_MAX || + !test_bit(family, &nd_desc->bus_family_mask)) return -EINVAL; + family = array_index_nospec(family, + NVDIMM_BUS_FAMILY_MAX + 1); dsm_mask = acpi_desc->family_dsm_mask[family]; guid = to_nfit_bus_uuid(family); } else {