Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1701109pxu; Tue, 24 Nov 2020 07:00:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2J7ptkmKNsXXM+L2sQPV6IFXDbe2pASEzV3h2tJrSLaW8nrG9yJmFTY21kauN+ZTQOjfA X-Received: by 2002:a17:906:2581:: with SMTP id m1mr4439657ejb.28.1606230022083; Tue, 24 Nov 2020 07:00:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606230022; cv=none; d=google.com; s=arc-20160816; b=iZ9yPueTHHS+EYolU1/ecAIOJS8jH0/S61tsQKlhUOR8/sIuAyb8GQYt48F42YOTN3 e+x85oF1+0OzLmCaa5G0HIkW1QR228iIkYbrb151rK3Fz9E9yc0AVrACOkW990FJTV/H GVg36Ci2EyaFwxeQrQQrhf16UBE38lYdRE9ifxhruY6K1I71rhFe90zq8hyYrYW1hdQK K5h75ob9FuBlAP+nyzgBELS2mRt9vNwhpWYh6vKgyNmy7TJ4mh1/KauBI0lxcKDDV2+l +vBED55waUxVZ7yMDCMuSWLscTptI2STBspf2L4xu8TNpzk4yULyn4vxN14TXlSlAPUz YDxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=IDhfVYWGoL+IpVNQ3e9z+GzCQ3AwBmJ5YyBaFP+39/s=; b=d9hyeeS+hTLtzwYUOnHodstB8nLhOjjHjOrANCrEgrrRKLAuFqgHxEsxStisZRKju8 VxJpFgz14G9wFn4ZaYzF/58LE3Q91e+B90musnQ6aHbrgMQ3WBi8KGGWhcAIySdYGItv k6C7K3sTx5LzbaCU03lFv13h4vdcNdQMKFmPCGJnJZu8S9YCQR4cGDSP6KI2F6flnkjR SU4lNlszIqsgRUN0QelNYBjwNRehcGuk5MksKWELn2cSsxOv0DQTRmXDw4/luFWxAJyq iiP0GUdsG5s2HvCrZ8VWk/EP+0RQiurohQ3ioqu/2e4aQq5KcvvA5+xJN2DgEEvzI+l2 dGyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NzH85F2x; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si8747136edc.249.2020.11.24.06.59.55; Tue, 24 Nov 2020 07:00:22 -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=@redhat.com header.s=mimecast20190719 header.b=NzH85F2x; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389221AbgKXOzq (ORCPT + 99 others); Tue, 24 Nov 2020 09:55:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30015 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388165AbgKXOzq (ORCPT ); Tue, 24 Nov 2020 09:55:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606229744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IDhfVYWGoL+IpVNQ3e9z+GzCQ3AwBmJ5YyBaFP+39/s=; b=NzH85F2xYPSuhTzemjNAZOKzFWzZhBrQtuFHJQKR79udsexoen6XUlWMmr7dgqz8K0gKhQ mHvjewEeQZjNflGvb6d4HdJUzx5njjK3EIsLrBl61iVT6doUDNsp7NmlGNd4Ahmyqhimt+ yhCSRpAtIv7ctB7Npt5+4Gz9Qw0SwQw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-uhRFpvSLPfWubnd5bhYaXw-1; Tue, 24 Nov 2020 09:55:42 -0500 X-MC-Unique: uhRFpvSLPfWubnd5bhYaXw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E98ED9A229; Tue, 24 Nov 2020 14:55:40 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BDB65D6AB; Tue, 24 Nov 2020 14:55:40 +0000 (UTC) From: Jeff Moyer To: Dan Williams Cc: linux-nvdimm@lists.01.org, Dan Carpenter , stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH] ACPI: NFIT: Fix input validation of bus-family References: <160619566216.201177.9354229595539334957.stgit@dwillia2-desk3.amr.corp.intel.com> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 Date: Tue, 24 Nov 2020 09:55:44 -0500 In-Reply-To: <160619566216.201177.9354229595539334957.stgit@dwillia2-desk3.amr.corp.intel.com> (Dan Williams's message of "Mon, 23 Nov 2020 21:27:42 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dan Williams writes: > 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 is 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 > --- > drivers/acpi/nfit/core.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c > index cda7b6c52504..b11b08a60684 100644 > --- a/drivers/acpi/nfit/core.c > +++ b/drivers/acpi/nfit/core.c > @@ -5,6 +5,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -479,8 +480,11 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, > 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 { Reviewed-by: Jeff Moyer