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 X-Spam-Level: X-Spam-Status: No, score=-9.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E07B2C433B4 for ; Thu, 13 May 2021 04:50:58 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9BF2361425 for ; Thu, 13 May 2021 04:50:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BF2361425 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Date:Cc:To:From: Subject:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7BdjViIcuJcV5lqBoLvQiEr7P7HgTjB85kYUkw7lOYY=; b=a4Eob+2V3I6zF0GqdIpEg5zwo 9lOuYrKNHLxno8FysgYprpB7ausnyPRkumaqX5pxmF1Di8XjsjZ/Z1k9axVn3IDyHG9yCdQU5ydcu c6/CLS6xrip/ygqqMNXoV08qB5jAvevQz0aohzUyDa6eMtcvKtwwNclumDf8vUJnOjplAM+0K2/W3 4fZI350/X8/hNFY9+z79wPy/YkOUoraMJXREmL9YlZisxBpWAQ7eHpmO851ni+io3WprB7wfdBorX IxzntxRrpqYNuJ/VJv4UkTvyhfJSft7qpBc0ZxsKYN1DE6XXYVlFUusTA4o4PDMkLuvwoS1oJw3SN TXyzmSErg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lh3HF-004kN0-23; Thu, 13 May 2021 04:48:49 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lh3HC-004kMv-Fo for linux-arm-kernel@desiato.infradead.org; Thu, 13 May 2021 04:48:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject: Message-ID:Sender:Reply-To:Content-ID:Content-Description; bh=LfNpRB3UcY4t8h2hzNxeA40Uh+Md9XEQaGq3NflxvfQ=; b=xpN/aiaQW9ZGNI4HaVj20whDwo n8h1jK6Ubc6sM2n7g+XAqbHgb8nxNxotDaiko92/giDpbYOz67LvNO9jIL6Id5YZM10ByccNs2bD3 qIdT+bdQrhTSkd4PnbFJwpt2qXDLK6XUoIVM/GF6+3YvIcNXkluRx0tu+08Qa02I/kpSxP5mgcgyG rXsdkSTB1xXBCn5fpGNkStQ8Z5HYUu9R4TPFbJRE0xVxecKiKg8CelVZj7gv9CLkGeQ4FLIsDjS4U DKY3eO/Zg5+4IDNbIA3SlO3e0KP1FxfSnLkw2KuLLUB9Uwy/aA3zE3goQ8u3nm5zS9JCPeXtq3N+P lJblkJlA==; Received: from smtprelay0080.hostedemail.com ([216.40.44.80] helo=smtprelay.hostedemail.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lh3H9-00B0nO-JG for linux-arm-kernel@lists.infradead.org; Thu, 13 May 2021 04:48:44 +0000 Received: from omf07.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id 9CEC4BA02; Thu, 13 May 2021 04:48:40 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf07.hostedemail.com (Postfix) with ESMTPA id 1CAF7315D73; Thu, 13 May 2021 04:48:39 +0000 (UTC) Message-ID: Subject: Re: [PATCH] watchdog: Use sysfs_emit() and sysfs_emit_at() in "show" functions From: Joe Perches To: Juerg Haefliger , wim@linux-watchdog.org, linux@roeck-us.net, joel@jms.id.au, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org Cc: andrew@aj.id.au, linux-kernel@vger.kernel.org, Juerg Haefliger Date: Wed, 12 May 2021 21:48:37 -0700 In-Reply-To: <20210511061812.480172-1-juergh@canonical.com> References: <20210511061812.480172-1-juergh@canonical.com> User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: 1CAF7315D73 X-Stat-Signature: 6kzj9cfeptqsg315pdhjnu5ex5kpbywt X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/YmSWARqT1SSQJOYqo5pk6qOvYyh48NP4= X-HE-Tag: 1620881318-714369 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_214843_718874_4C65E965 X-CRM114-Status: UNSURE ( 8.57 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 2021-05-11 at 08:18 +0200, Juerg Haefliger wrote: > Convert sprintf() in sysfs "show" functions to sysfs_emit() and > sysfs_emit_at() in order to check for buffer overruns in sysfs outputs. [] > diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wd= t.c [] > @@ -445,8 +445,9 @@ static ssize_t ziirave_wdt_sysfs_show_firm(struct dev= ice *dev, > =A0 if (ret) > =A0 return ret; > =A0 > = > - ret =3D sprintf(buf, ZIIRAVE_FW_VERSION_FMT, w_priv->firmware_rev.major, > - w_priv->firmware_rev.minor); > + ret =3D sysfs_emit(buf, ZIIRAVE_FW_VERSION_FMT, > + w_priv->firmware_rev.major, > + w_priv->firmware_rev.minor); > =A0 > = > =A0 mutex_unlock(&w_priv->sysfs_mutex); > =A0 > = > @@ -468,8 +469,9 @@ static ssize_t ziirave_wdt_sysfs_show_boot(struct dev= ice *dev, > =A0 if (ret) > =A0 return ret; > =A0 > = > - ret =3D sprintf(buf, ZIIRAVE_BL_VERSION_FMT, w_priv->bootloader_rev.maj= or, > - w_priv->bootloader_rev.minor); > + ret =3D sysfs_emit(buf, ZIIRAVE_BL_VERSION_FMT, > + w_priv->bootloader_rev.major, > + w_priv->bootloader_rev.minor); > =A0 > = > =A0 mutex_unlock(&w_priv->sysfs_mutex); > =A0 > = > @@ -491,7 +493,7 @@ static ssize_t ziirave_wdt_sysfs_show_reason(struct d= evice *dev, > =A0 if (ret) > =A0 return ret; > =A0 > = > - ret =3D sprintf(buf, "%s", ziirave_reasons[w_priv->reset_reason]); > + ret =3D sysfs_emit(buf, "%s", ziirave_reasons[w_priv->reset_reason]); All of these formats should probably end with a newline and the ZIIRAVE__VERSION_FMT defines are to me unnecessary. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel