From patchwork Thu Jan 19 15:09:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13108263 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDD127485 for ; Thu, 19 Jan 2023 15:09:59 +0000 (UTC) Received: by mail-wm1-f42.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso1479553wmq.5 for ; Thu, 19 Jan 2023 07:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=UAyoS/l0ukb8nWYy7RZDQQ8DiM08SBtHt1L84CqYlRc=; b=TjcnCssRgj+EfEZEr5WV0hvoRM0b5BzKvluALWmMw0IpLVZH4dq15+EwYLmr5tlijq l5EmfwjYhZS3Oq6zL6xfjTFis8ERb45I4R/9H13MJHD/gr2T+5n91U4uvLzTEW4pJzix JtsvGq6lWCS/hzzAhCBmBTNt11hG9TJUs+5hhEIdyl4pFn5onTF2nRnVlh7VN9rk/7Nz JW7e6tNuP8f88EWly/1YpgtBWbppvG8ACYd23xql5Ab5Fq7TO6LYyPplp56Rg1SRl5/Y /9rGjHbJOdHvf4+XKeb0648rqOhY+9EXZr55eW5iZtvg3TxMWK69lb5lDIqiW+yjKB+X V8WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UAyoS/l0ukb8nWYy7RZDQQ8DiM08SBtHt1L84CqYlRc=; b=2AdYcuwGlA9yQPL+zYQMB4KMlRoIzczqkP1S3fTojwXEJU7Pth3qD+yCE58HatTezi zDb99QYVJqFgAXojnVPO66STA/Q95ewnHa/CZF86CmYTJ6uEItZtLiwTES0HMgIH7fCN OkegyTZebHTSK7iRNTGGM0zgPN+w6JzCnnpwkRroeWI72a2NPS2L6LyDlmDm0KfYRIJq CzQF1wjPd2Oojx4j5QdU/zVfrkik5EKI5s68kpecVBTAnFjoRTLbEtJ3M5675lEAFvDI F5JHnmdLXPzNnyf0AbXNC343ksRfqLdaD54BFsjlghyZIG6XDaG7ATkuHIS+mKxE9IaV YlOw== X-Gm-Message-State: AFqh2koB5pdPNUGDbS1BhH9NSF0Xb3ADzYcKsJUqh98s8JCcDrkiGEar ploridgVhBlY1uspC/9d0QuD+pq+NT5VZQ== X-Google-Smtp-Source: AMrXdXsp0JKlPpH8FShIRP0LvtpChF3J/qGgB+aSM3orEEx/A6n7DvN+mte7plsHtFaCM4K21rzXog== X-Received: by 2002:a05:600c:3549:b0:3da:acb1:2f09 with SMTP id i9-20020a05600c354900b003daacb12f09mr6758658wmq.19.1674140998132; Thu, 19 Jan 2023 07:09:58 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id k9-20020a5d6d49000000b002bc8130cca7sm25982573wri.23.2023.01.19.07.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 07:09:57 -0800 (PST) Date: Thu, 19 Jan 2023 18:09:54 +0300 From: Dan Carpenter To: Dan Williams Cc: Vishal Verma , Dave Jiang , Ira Weiny , "Rafael J. Wysocki" , Len Brown , nvdimm@lists.linux.dev, linux-acpi@vger.kernel.org, kernel-janitors@vger.kernel.org, cip-dev , Harshit Mogalapalli Subject: [PATCH v2] ACPI: NFIT: prevent underflow in acpi_nfit_ctl() Message-ID: Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline The concern here would be that "family" is negative and we pass a negative value to test_bit() resulting in an out of bounds read and potentially a crash. This patch is based on static analysis and not on testing. Fixes: 9a7e3d7f0568 ("ACPI: NFIT: Fix input validation of bus-family") Signed-off-by: Dan Carpenter --- v2: add missing close parens ) in subject drivers/acpi/nfit/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index f1cc5ec6a3b6..da0739f04c98 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -446,10 +446,10 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, const char *cmd_name, *dimm_name; unsigned long cmd_mask, dsm_mask; u32 offset, fw_status = 0; + unsigned int family = 0; acpi_handle handle; const guid_t *guid; int func, rc, i; - int family = 0; if (cmd_rc) *cmd_rc = -EINVAL;