Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5769279pxu; Thu, 22 Oct 2020 10:32:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/3oqk4qTAvCjJSVC4X5TODPs4tX4OZ2uRN3a89uFYWRp7Fn5YWHI1ny6j5BTqdjG7CgKb X-Received: by 2002:a05:6402:b91:: with SMTP id cf17mr3210027edb.130.1603387923827; Thu, 22 Oct 2020 10:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603387923; cv=none; d=google.com; s=arc-20160816; b=wONzyMUZNdyPauJya4+s4B0kwKnoqvrFHO9lNXUjeTHF8FNpe8wZQEn8u7u+oOS+zX 6Z2/C5+CNhsPeu2d08cJ99dS8BN6VeU4BggI8mz+m+m5Z6hPWVUtmDGh2x5FTrA1fEsv mq413i7HsG/sZ7Nu4stYCq9+ckxORV09J7UHqFG9qdgBJ8sQiwRxGh27y3+TRKcwx6aB rmhuLU8+Jm8ymHwfQW4++YJ2kd8C+LSDHl33AKosDSWsR28KWKgYPt3C0XyzD1oyKUWS 7w6mP/FZ2H8khqqWntenw8NF3D2QJatcmhuwE/f/DcyYqzWYmft/q21SK7KdlB3WzBWt zcAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=67j3g1tf0vI2lJQeE3skwbiU83QZeuDhLbp0tXHL0eM=; b=U5l5i35b9+4JHndbTSleNqIY/bHQ4PzsCblm/P8X8H/IM8K3s0urZSL3+EE+oFL/QP YAsbNYN+jKreu8rsMfVDjjypME+wnz15gV3Slo/u6BZOaX0u7yygBtvTD3KPHWrUe9oN ih4csdPh08iIGc89J77xXlhldXeeGTx1+uuz2oqy7oqNv5xCbM933z/zUvFyUQK0ObKq G9PLyQafO47mOwtNUmpSuORlEAiFoJOko9QCR3rbqEKIeByqKcqFVVGVlcvrpNCyG5uO 21dWA12lf8leg1SuZzTtdD3K70T2f8HV3NT1k9awlVJYjT/VBM9FEB3adUV1j2SC6INe t4Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JfhNMyMo; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si1996881edi.24.2020.10.22.10.31.41; Thu, 22 Oct 2020 10:32:03 -0700 (PDT) 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=@kernel.org header.s=default header.b=JfhNMyMo; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2506841AbgJVNyU (ORCPT + 99 others); Thu, 22 Oct 2020 09:54:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:35032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443322AbgJVNyT (ORCPT ); Thu, 22 Oct 2020 09:54:19 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D64E22275; Thu, 22 Oct 2020 13:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603374859; bh=k/96McXBUQrMgM4y/fJNrw43hXeNtSxVU6BUe2aasrQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JfhNMyMoeo79vFKGh2kPdEK6Z9KBVoCnHEiWkZoBbSOYVIyDiVjzohSe9tyINoAEu oQ0dY0PKFot074Qy8U0+2w1ZtMNyp1HRdU4TTmBWVu4+9DC+f2dCt3amempuKh7ErT xcK5tj42W5UNWipPg8217GvuzCo3QQf1TRVGoBfQ= Date: Thu, 22 Oct 2020 15:54:55 +0200 From: Greg KH To: Sumera Priyadarsini Cc: dri-devel@lists.freedesktop.org, outreachy-kernel@googlegroups.com, alexander.deucher@amd.com, christian.koenig@amd.com, airlied@linux.ie, daniel@ffwll.ch, melissa.srw@gmail.com, linux-media@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [Outreachy kernel] [PATCH 4/5] gpu: drm: amdgpu: Replace snprintf() with sysfs_emit() Message-ID: <20201022135455.GA1788090@kroah.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 22, 2020 at 07:17:56PM +0530, Sumera Priyadarsini wrote: > Using snprintf() for show() methods holds the risk of buffer overrun > as snprintf() does not know the PAGE_SIZE maximum of the temporary > buffer used to output sysfs content. > > Modify amdgpu_psp.c to use sysfs_emit() instead which knows the > size of the temporary buffer. > > Issue found with Coccinelle. > > Signed-off-by: Sumera Priyadarsini > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > index d6c38e24f130..4d1d1e1b005d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > @@ -2621,7 +2621,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_read(struct device *dev, > return ret; > } > > - return snprintf(buf, PAGE_SIZE, "%x\n", fw_ver); > + return sysfs_emit(buf, PAGE_SIZE, "%x\n", fw_ver); Did you build this code? I don't think it is correct... thanks, greg k-h