From mboxrd@z Thu Jan 1 00:00:00 1970 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 C8544EB64DD for ; Tue, 11 Jul 2023 09:37:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230091AbjGKJhd (ORCPT ); Tue, 11 Jul 2023 05:37:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231839AbjGKJhU (ORCPT ); Tue, 11 Jul 2023 05:37:20 -0400 Received: from imap4.hz.codethink.co.uk (imap4.hz.codethink.co.uk [188.40.203.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AE6310D4; Tue, 11 Jul 2023 02:36:55 -0700 (PDT) Received: from [134.238.52.102] (helo=[10.8.4.2]) by imap4.hz.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1qJ9ng-00BpLQ-OI; Tue, 11 Jul 2023 10:36:53 +0100 Message-ID: Date: Tue, 11 Jul 2023 10:36:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] ACPI: NFIT: limit string attribute write Content-Language: en-GB To: nvdimm@lists.linux.dev Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lenb@kernel.org References: <20230711092244.22527-1-ben.dooks@codethink.co.uk> From: Ben Dooks Organization: Codethink Limited. In-Reply-To: <20230711092244.22527-1-ben.dooks@codethink.co.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/07/2023 10:22, Ben Dooks wrote: > If we're writing what could be an arbitrary sized string into an attribute > we should probably use sysfs_emit() 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 > --- > v2: > - use sysfs_emit() instead of snprintf. > --- > 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); > whoops, forgot to add before hitting ammend... -- Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius https://www.codethink.co.uk/privacy.html