Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp762663ybi; Fri, 21 Jun 2019 07:47:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHx3JzPI/xbrmMaO5Hy/EIBo76SlsUltQVAKCL2eEd+49I0y1Vw6AeachzmApw6NriQnM7 X-Received: by 2002:a17:90a:8c87:: with SMTP id b7mr6968135pjo.139.1561128427141; Fri, 21 Jun 2019 07:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561128427; cv=none; d=google.com; s=arc-20160816; b=TTXOsSrmV4/s5hf1ZOZ4AxzrtBtoGpn/P8jDdB/F01wNFZsdmUukhUIRWSt7ze2Glz OqNDr0VET56JdBEmOnoTUoiteMP5zMwRIhn7YcO9J34NbqMOYS0iSlEYriekoXtEKKhX 6hg0EvOMTcaSO1C8nKDJNEde63ad1yz1yaHxqNU3QZbroFigHKU9Wpnozglv6kQt5C/5 odolKo0J9V4f1kHOwGkpQx/mew+mD6daCVtw+iyk1dImv/V+SqOgaKi+WVkoZ2WnB/my Ry7WXg2dnQ+VqQ+qJNvO54IQJHwvLDo/k74MhMALIcF45iDmQxfOpybs6FXWLGSZeYzP sTQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=oJhEQtxC/biKKS1b+LjEff35IggIHw3WBBid8w8k7pY=; b=wjGUHflwPEKOcFZVtKsPj80//LYQgBJ8DUIh1INfU+zzb1w0n9dLTWQ+q5yg1kTAGB qFRiflZXlJVXEpQKnOx9ZXmRDT/LSnH2PFSelH3RM8xL6WvbljUWmCHNppjWrmXXiEWl aR604sRiPNCHpi8PxgYIQPMNk4X2Y4Q8o7rSe3SozpJorQLNZOOsySwdl3xFlJ3IJiky Swm2rE4fsydpzyNnh3sHykS4H0wB+bIHN0/zm/nJuaBTExRPPUYwBVxTKpbwhRF1s/x8 /N0i1Gu1teQ5PAuqplqBRd/A66hR5WDlkqZR/BA9rBAobiCI3ATp4FyXfaw2yuS58YLm NuOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pt1qnHia; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si2785730pjr.109.2019.06.21.07.46.51; Fri, 21 Jun 2019 07:47:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pt1qnHia; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726357AbfFUOpS (ORCPT + 99 others); Fri, 21 Jun 2019 10:45:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:35728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfFUOpR (ORCPT ); Fri, 21 Jun 2019 10:45:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 4E23C2089E; Fri, 21 Jun 2019 14:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561128316; bh=rsCDn3qBb6zALp8DkCiY9VjakZ7sbnF4v1lpfSmqIgY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pt1qnHiaVa94ao+grRWkTuG10JTHcF/bDa+54km7+h6lxQKR/RJXV2B/ayzRPSOl6 gHvKhTBmlif7HvDupZb7a95DkOd45YJxEaqIiqIjBJczzcRmN8Ps8F6qVl4aFKvS59 GMcApy5WNnDO6/3Up2lEoumpYwg+J9v59sZKmz2M= Date: Fri, 21 Jun 2019 16:45:14 +0200 From: Greg Kroah-Hartman To: Rajat Jain Cc: Bjorn Helgaas , linux-pci , Linux Kernel Mailing List Subject: Re: PCI/AER sysfs files violate the rules of how sysfs works Message-ID: <20190621144514.GB6493@kroah.com> References: <20190621072911.GA21600@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 21, 2019 at 07:08:38AM -0700, Rajat Jain wrote: > On Fri, Jun 21, 2019, 12:29 AM Greg KH wrote: > > > Hi, > > > > When working on some documentation scripts to show the > > Documentation/ABI/ files in an automated way, I ran across this "gem" of > > a sysfs file: Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats > > > > In it you describe how the files > > /sys/bus/pci/devices//aer_dev_correctable and > > /sys/bus/pci/devices//aer_dev_fatal and > > /sys/bus/pci/devices//aer_dev_nonfatal > > all display a bunch of text on multiple lines. > > > > This violates the "one value per sysfs file" rule, and should never have > > been merged as-is :( > > > > Please fix it up to be a lot of individual files if your really need all > > of those different values. > > > > Remember, sysfs files should never have to have a parser to read them > > other than a simple "what is this single value", and you should NEVER > > have fun macros like: > > > > for (i = 0; i < ARRAY_SIZE(strings_array); i++) { \ > > if (strings_array[i]) \ > > str += sprintf(str, "%s %llu\n", \ > > strings_array[i], stats[i]); \ > > else if (stats[i]) \ > > str += sprintf(str, #stats_array "_bit[%d] > > %llu\n",\ > > i, stats[i]); \ > > } \ > > str += sprintf(str, "TOTAL_%s %llu\n", total_string, \ > > pdev->aer_stats->total_field); \ > > > > spit out sysfs information. > > > > Note, I am all for not properly checking the length of the sysfs file > > when writing to it, but that is ONLY because you "know" that a single > > integer will never overflow anything. Here you are writing a ton of > > different values, with no error checking at all. So just when I thought > > it couldn't be any worse... > > > > Please fix. > > > > My apologies. I will discuss with Bjorn and fix this. thank you. I'll be glad to review patches for this. thanks, greg k-h