From patchwork Tue Jul 4 08:17:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 698979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 664E0EB64DA for ; Tue, 4 Jul 2023 08:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231190AbjGDISI (ORCPT ); Tue, 4 Jul 2023 04:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231497AbjGDIR5 (ORCPT ); Tue, 4 Jul 2023 04:17:57 -0400 Received: from imap5.colo.codethink.co.uk (imap5.colo.codethink.co.uk [78.40.148.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61759107; Tue, 4 Jul 2023 01:17:56 -0700 (PDT) Received: from cpc152649-stkp13-2-0-cust121.10-2.cable.virginm.net ([86.15.83.122] helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1qGbEP-002i2E-4L; Tue, 04 Jul 2023 09:17:53 +0100 Received: from ben by rainbowdash with local (Exim 4.96) (envelope-from ) id 1qGbEO-0003AV-1k; Tue, 04 Jul 2023 09:17:52 +0100 From: Ben Dooks To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Cc: nvdimm@lists.linux.dev, lenb@kernel.org, Ben Dooks Subject: [PATCH] ACPI: NFIT: limit string attribute write Date: Tue, 4 Jul 2023 09:17:51 +0100 Message-Id: <20230704081751.12170-1-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org If we're writing what could be an arbitrary sized string into an attribute we should probably use snprintf() just to be safe. Most of the other attriubtes are some sort of integer so unlikely to be an issue so not altered at this time. Signed-off-by: Ben Dooks --- 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 9213b426b125..d7e9d9cd16d2 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1579,7 +1579,7 @@ static ssize_t id_show(struct device *dev, { struct nfit_mem *nfit_mem = to_nfit_mem(dev); - return sprintf(buf, "%s\n", nfit_mem->id); + return snprintf(buf, PAGE_SIZE, "%s\n", nfit_mem->id); } static DEVICE_ATTR_RO(id);