Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp8156542rdb; Thu, 4 Jan 2024 23:39:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7fs7Sgkd3uS+vC3bx89lr02cqJ7eM1XGrhMNkvURy9TJiTrHrQnZ9YwFazW2HOVSd4Zwz X-Received: by 2002:a05:622a:1a02:b0:429:7abe:afbe with SMTP id f2-20020a05622a1a0200b004297abeafbemr133640qtb.19.1704440345834; Thu, 04 Jan 2024 23:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704440345; cv=none; d=google.com; s=arc-20160816; b=eGvB46LbNCsBgm28s2TgE7pudMW82dzFz/6QyGgp+xsme3RBItz2P/GSYjwx8J4l3U aV7cSoHSfF+OsC3cqypvujVVnES8kCkuqI/KdMcAh8FzD1KWSmbn8CzOKyVBJQS82Jbd CPdnfJ70YcFtnievWKq+ZRnMV93uV4hutvCksXVK71AVviAGvrdcitbhtAJsc95N45ke yT1ZFfC/ad+BcAlXcCw8gvY/YmIsDwMXQKT+pDBk9z8HmQECcLJOMdy3B5ueewokfUtn pW5mrrrFnf73elU+kLkfIP4+JTU+/kE+Kh2BMnRAGf9HT5UKB7Ef9vSIr/dNQmKfFs40 4Wuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=idHE10ZDLhgzwn3I1/XoplM9AVYo/5Fx/+k0C8sQexY=; fh=hFxmSgmogF+IN+IGtRVZ5L8UB4bQghWr3+P3L7W9pKg=; b=qzUDRvIL2uBJBRTofU4dxtnGycfH/IVWSYd/8KiO0tpLy9KMCxqHKIJX80eWeArCYA nlSIvni+lRKeXlDqEuXcvDT/oL1g0WmwTQbsGvIA01t7XFlqvxk+aGi8r+hhaEPazQo0 jW9Skb/oekRDnJ9jgzoiz8dYoTULZ2nhoOVeEYgAUmDVkD2BDf8Og6vb6Kr025FvyFcL yTIx/IgVTa0DDFUoMVJJ1yKIRk/GJ/v0BWO6mArynHv3Bw0HjF3AopLveMEGFvgSSRQt E18J7ZKbTVaH+fzE3TAZR/QLkl5NZwxtNKAg4l+ud4b4UqFNqIY/xAky7Dbdw89/a1lC N+hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bMI3keqk; spf=pass (google.com: domain of linux-kernel+bounces-17552-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17552-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fj13-20020a05622a550d00b004260c8f8d1esi1347158qtb.328.2024.01.04.23.39.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 23:39:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17552-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bMI3keqk; spf=pass (google.com: domain of linux-kernel+bounces-17552-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17552-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9782E1C20FE7 for ; Fri, 5 Jan 2024 07:39:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02540208B4; Fri, 5 Jan 2024 07:38:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bMI3keqk" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E50CD20B0E; Fri, 5 Jan 2024 07:38:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46916C433C7; Fri, 5 Jan 2024 07:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1704440328; bh=6oagLH0ZnzA9OExagj9jK3ris0AggDvZMrPRowXSBgw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bMI3keqk1NLcrjInsJm7BVPpFvf7SZ3daSntEpyGtU0FglEpxyW+WValibzVvw3X3 DqsXnmC2fJvOQ5D0cDhVGhM68xrmpISyuUNMCERBuygWu6ESvQU2ePk7eW/oeD/4id 9ibUlioQ7GYpg9MzTwnIpaIUhLXloabxMoj3k8/k= Date: Fri, 5 Jan 2024 08:38:45 +0100 From: Greg KH To: Christian Marangi Cc: Christophe JAILLET , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jonghwa Lee , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, stable@vger.kernel.org Subject: Re: [RESEND PATCH 1/2] PM / devfreq: Fix buffer overflow in trans_stat_show Message-ID: <2024010542-thespian-agreed-ff3d@gregkh> References: <20240104215521.10772-1-ansuelsmth@gmail.com> <9d57f4ea-67d1-48b5-92df-c5556f95f5d6@wanadoo.fr> <659735f1.050a0220.efb5.1c0d@mx.google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <659735f1.050a0220.efb5.1c0d@mx.google.com> On Thu, Jan 04, 2024 at 11:44:54PM +0100, Christian Marangi wrote: > On Thu, Jan 04, 2024 at 11:19:44PM +0100, Christophe JAILLET wrote: > > > @@ -1688,7 +1688,7 @@ static ssize_t trans_stat_show(struct device *dev, > > > struct device_attribute *attr, char *buf) > > > { > > > struct devfreq *df = to_devfreq(dev); > > > - ssize_t len; > > > + ssize_t len = 0; > > > int i, j; > > > unsigned int max_state; > > > @@ -1697,7 +1697,7 @@ static ssize_t trans_stat_show(struct device *dev, > > > max_state = df->max_state; > > > if (max_state == 0) > > > - return sprintf(buf, "Not Supported.\n"); > > > + return scnprintf(buf, PAGE_SIZE, "Not Supported.\n"); > > > > Hi, > > > > maybe using sysfs_emit_at() could be even cleaner and less verbose? > > > > If you notice this change is done in the second patch of the series. > This patch still use this more generic way to permit this to be > backported on stable kernel. (older kernel doesn't have sysfs_emit_at() > hence it can't be backported) All activly supported kernels on the kernel.org front page have sysfs_emit_at(), so this should not be an issue for anyone. Just do the change here at the same time. thanks, greg k-h