Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1163927pxb; Thu, 4 Mar 2021 05:08:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwx4ygZLi50Zkl8gJ66kt3VtrynBDDbmWUq1qeMgFqmn8xryTI5NL3fpegZQOCndDAWXzza X-Received: by 2002:a17:906:ad96:: with SMTP id la22mr4224064ejb.237.1614863334313; Thu, 04 Mar 2021 05:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614863334; cv=none; d=google.com; s=arc-20160816; b=Tel97ICqx499ijY6zKKaTHTsL5tHCVEAgLqjpzMxUk6GiK/UmaEz9hZL3OGQSGhk9Y oWrstL2dkAtBcKPSbt2h957KffNoBnA5tqnRC9iZx/3xsJ2sV8IDruOtIcoMIdt8Czu7 uXcaEaC9ovvcpcfryQ/px74VPHU2vJEoK2wz5Pt4Do9zsWqKYgWgndtJIJTdhsawDFID mF8cBp8rvWxu2OUvQElhPIOOVXeV4UNzIz3X/LJScTQwLZqE3HSEFxmBkHE56Wdifg7v oW4qkgGR3vyac7VNhldUsR0YbL58gobufPTeU1dcg4+TQ9rJREqr0wh6TYfpkHyhMwkC UKmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=sUcaPALdpy8y+tRs8z2ZURmdWTUCYzuiU0fvzzRaw30=; b=UF68G8YsPYLr5ai201rUEpaTWpoM0P/woHvlJnSlCG6ASv82OiUHEQjJIV/0aPK4uQ LmUKqmj/7uMERx/+5qcR/nW3Ww50T5fjxoaZPTTmpzB0eBYFmyjg+Jnj7aR84wVpYynK 0kSEgv7PDzE6IkxSURnSVFUhPUQ1DoFbZL+w3zNKgdQglSM4U5jRT7k6NzFEQxzrXop9 ia7sDCM0i1yCzTCJvcIIjEpK0GdJSXb+J62GA2fXbUXX1Yo1AB4eUE3jXVvp5ehw4+nz 78+VGDQQdGoxtcxq8UcQ/te3mpQGxiKjepvWNhm5KemHSrpxB4e0WyRV3o6MWsNWx+/6 pozg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=CKxWaide; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y23si17983202eds.278.2021.03.04.05.08.28; Thu, 04 Mar 2021 05:08:54 -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=@mg.codeaurora.org header.s=smtp header.b=CKxWaide; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353576AbhCDAHN (ORCPT + 99 others); Wed, 3 Mar 2021 19:07:13 -0500 Received: from z11.mailgun.us ([104.130.96.11]:51181 "EHLO z11.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1389560AbhCCVjb (ORCPT ); Wed, 3 Mar 2021 16:39:31 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1614807545; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=sUcaPALdpy8y+tRs8z2ZURmdWTUCYzuiU0fvzzRaw30=; b=CKxWaide8rnNz7zt8rBMedLTtHY00A4BcGqtI/lO9F4O57xoggKnFejbTuUv8585zz+PQ/qD 8jN5MuYJZn2M85izYCOg9WZbo4fCui8Y61KBX4u29Zqi6KmOzh35ePojpSmlN30UqwzX6gN7 p+RHKS9M+cxhn4jhwjWcpys1Zdc= X-Mailgun-Sending-Ip: 104.130.96.11 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-west-2.postgun.com with SMTP id 604001d8c862e1b9fdb102d7 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 03 Mar 2021 21:38:32 GMT Sender: sidgup=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 26D94C433ED; Wed, 3 Mar 2021 21:38:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.1.10] (cpe-75-83-25-192.socal.res.rr.com [75.83.25.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sidgup) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4787EC433C6; Wed, 3 Mar 2021 21:38:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4787EC433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=sidgup@codeaurora.org Subject: Re: [PATCH] remoteproc: sysfs: Use scnprintf instead of sprintf To: Bjorn Andersson Cc: ohad@wizery.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Raghavendra Rao Ananta References: <1614801698-25987-1-git-send-email-sidgup@codeaurora.org> From: Siddharth Gupta Message-ID: Date: Wed, 3 Mar 2021 13:38:30 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/3/2021 12:56 PM, Bjorn Andersson wrote: > On Wed 03 Mar 14:01 CST 2021, Siddharth Gupta wrote: > >> From: Raghavendra Rao Ananta >> >> For security reasons scnprintf() is preferred over sprintf(). >> Hence, convert the remoteproc's sysfs show functions accordingly. >> > Thanks for the patch Siddharth. > > There's no possibility for these calls to generate more than PAGE_SIZE > amount of data, so this isn't really necessary. But if you insist, > please let's use sysfs_emit() instead. > > Regards, > Bjorn Sure Bjorn, I'll push the new patch immediately. Thanks, Siddharth > >> Signed-off-by: Raghavendra Rao Ananta >> Signed-off-by: Siddharth Gupta >> --- >> drivers/remoteproc/remoteproc_sysfs.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c >> index 1dbef89..853f569 100644 >> --- a/drivers/remoteproc/remoteproc_sysfs.c >> +++ b/drivers/remoteproc/remoteproc_sysfs.c >> @@ -15,7 +15,8 @@ static ssize_t recovery_show(struct device *dev, >> { >> struct rproc *rproc = to_rproc(dev); >> >> - return sprintf(buf, "%s", rproc->recovery_disabled ? "disabled\n" : "enabled\n"); >> + return scnprintf(buf, PAGE_SIZE, "%s", >> + rproc->recovery_disabled ? "disabled\n" : "enabled\n"); >> } >> >> /* >> @@ -82,7 +83,7 @@ static ssize_t coredump_show(struct device *dev, >> { >> struct rproc *rproc = to_rproc(dev); >> >> - return sprintf(buf, "%s\n", rproc_coredump_str[rproc->dump_conf]); >> + return scnprintf(buf, PAGE_SIZE, "%s\n", rproc_coredump_str[rproc->dump_conf]); >> } >> >> /* >> -- >> Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, >> a Linux Foundation Collaborative Project >>