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 0CC7AC001DF for ; Fri, 4 Aug 2023 10:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229557AbjHDKlV (ORCPT ); Fri, 4 Aug 2023 06:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjHDKlU (ORCPT ); Fri, 4 Aug 2023 06:41:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F82746B5 for ; Fri, 4 Aug 2023 03:41:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2DA6161F66 for ; Fri, 4 Aug 2023 10:41:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EB56C433C8; Fri, 4 Aug 2023 10:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1691145678; bh=iDi1tJjznXMzCkUttpTQRlkA1u/Ffp9OKLG4wtLUlZE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ij5ywbeyKt6LT+AE2K9vLiT9FbxlACvA0XtgA8HrM9/prEKX2uz7Ud3irJnXrkCeW cvNENy/LllZZoJAlqQca1eImZqg8FgtkmsAkO0A/35CXPvG3ZljTUXia5+gYAfRRoZ aChA3ieq4enLM+AI41tK+lOioYKU4bAxD6XgnXT4= Date: Fri, 4 Aug 2023 12:41:15 +0200 From: Greg Kroah-Hartman To: Brennan Lamoreaux Cc: stable@vger.kernel.org, akaher@vmware.com, amakhalov@vmware.com, vsirnapalli@vmware.com, ankitja@vmware.com, Joe Perches Subject: Re: [PATCH v4.19.y] drivers core: Use sysfs_emit and sysfs_emit_at for show(device *...) functions Message-ID: <2023080457-chaplain-tingle-1af5@gregkh> References: <86FA1210-9388-4376-B4A3-5F150E33B19F@vmware.com> <20230801213044.68581-1-blamoreaux@vmware.com> <2023080459-sprint-dreamless-eb79@gregkh> <2023080459-visitor-fleshy-7e05@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2023080459-visitor-fleshy-7e05@gregkh> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Fri, Aug 04, 2023 at 12:29:16PM +0200, Greg Kroah-Hartman wrote: > On Fri, Aug 04, 2023 at 12:22:09PM +0200, Greg Kroah-Hartman wrote: > > On Tue, Aug 01, 2023 at 02:30:44PM -0700, Brennan Lamoreaux wrote: > > > From: Joe Perches > > > > > > commit aa838896d87af561a33ecefea1caa4c15a68bc47 upstream > > > > > > Convert the various sprintf fmaily calls in sysfs device show functions > > > to sysfs_emit and sysfs_emit_at for PAGE_SIZE buffer safety. > > > > > > Done with: > > > > > > $ spatch -sp-file sysfs_emit_dev.cocci --in-place --max-width=80 . > > > > > > And cocci script: > > > > > > $ cat sysfs_emit_dev.cocci > > > @@ > > > identifier d_show; > > > identifier dev, attr, buf; > > > @@ > > > > > > ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) > > > { > > > <... > > > return > > > - sprintf(buf, > > > + sysfs_emit(buf, > > > ...); > > > ...> > > > } > > > > > > @@ > > > identifier d_show; > > > identifier dev, attr, buf; > > > @@ > > > > > > ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) > > > { > > > <... > > > return > > > - snprintf(buf, PAGE_SIZE, > > > + sysfs_emit(buf, > > > ...); > > > ...> > > > } > > > > > > @@ > > > identifier d_show; > > > identifier dev, attr, buf; > > > @@ > > > > > > ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) > > > { > > > <... > > > return > > > - scnprintf(buf, PAGE_SIZE, > > > + sysfs_emit(buf, > > > ...); > > > ...> > > > } > > > > > > @@ > > > identifier d_show; > > > identifier dev, attr, buf; > > > expression chr; > > > @@ > > > > > > ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) > > > { > > > <... > > > return > > > - strcpy(buf, chr); > > > + sysfs_emit(buf, chr); > > > ...> > > > } > > > > > > @@ > > > identifier d_show; > > > identifier dev, attr, buf; > > > identifier len; > > > @@ > > > > > > ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) > > > { > > > <... > > > len = > > > - sprintf(buf, > > > + sysfs_emit(buf, > > > ...); > > > ...> > > > return len; > > > } > > > > > > @@ > > > identifier d_show; > > > identifier dev, attr, buf; > > > identifier len; > > > @@ > > > > > > ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) > > > { > > > <... > > > len = > > > - snprintf(buf, PAGE_SIZE, > > > + sysfs_emit(buf, > > > ...); > > > ...> > > > return len; > > > } > > > > > > @@ > > > identifier d_show; > > > identifier dev, attr, buf; > > > identifier len; > > > @@ > > > > > > ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) > > > { > > > <... > > > len = > > > - scnprintf(buf, PAGE_SIZE, > > > + sysfs_emit(buf, > > > ...); > > > ...> > > > return len; > > > } > > > > > > @@ > > > identifier d_show; > > > identifier dev, attr, buf; > > > identifier len; > > > @@ > > > > > > ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) > > > { > > > <... > > > - len += scnprintf(buf + len, PAGE_SIZE - len, > > > + len += sysfs_emit_at(buf, len, > > > ...); > > > ...> > > > return len; > > > } > > > > > > @@ > > > identifier d_show; > > > identifier dev, attr, buf; > > > expression chr; > > > @@ > > > > > > ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) > > > { > > > ... > > > - strcpy(buf, chr); > > > - return strlen(buf); > > > + return sysfs_emit(buf, chr); > > > } > > > > > > Signed-off-by: Joe Perches > > > Link: https://lore.kernel.org/r/3d033c33056d88bbe34d4ddb62afd05ee166ab9a.1600285923.git.joe@perches.com > > > Signed-off-by: Greg Kroah-Hartman > > > [ Brennan : Regenerated for 4.19 to fix CVE-2022-20166 ] > > > Signed-off-by: Brennan Lamoreaux > > > > Thanks, now queued up. > > Nope, now dropped, this didn't even build. How did you test this thing? Sorry, it built, but had warnings. We don't like to add new warnings if possible, right?