Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1524272pxb; Sun, 12 Sep 2021 22:45:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3hHMNvE0h+0l53YdJeiFY3VELb4gG9x9QLwtno6RexVeiDTEQpXgQJiecbD5gySLXP0LR X-Received: by 2002:a05:6402:452:: with SMTP id p18mr11605151edw.34.1631511909019; Sun, 12 Sep 2021 22:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631511909; cv=none; d=google.com; s=arc-20160816; b=BE6ahu3zbep8WdG8RhMTGo+e/wNK21AUONI85mzzrbEVWEE/oCDo1czKL1XWRh86j/ 3c9S+0eHSFTL6iN183+hpEs84ExPL/xqXViUvqQgTin9ooDW2Y9QGZ/3QSvkFzbytl1u hGuW0r2sc0h9rpiLJIOkDgU8vJA6pLSdg/Ftyowahkifrpwk6817FzYUPrQT3yFyE0Tv /f6k5nsNXpcG6dD2YuLVDKps8o/yyNFPrPOuexteYKx5tcE3M68n3fGGXr29QJ1WPiTy MTFeTfZDU6wYHeAcImsyxjFUOQVZ/YNPlZiNwSgVijVhEU6otFJb8Yb7YjKFEsbN+YrL gC0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=fmH2LXB3YYbj1yq4cqvqVQN291/Bevk7C+ybmXkGJs4=; b=qzWBNO9eTjhSJoRWkPjSsWcJKNc0uzsUQ4M3G/JHQZTFB0IyxY2gVW24U88ek8SauG rBBcnQ520vqe66/ql0kGk1yItMaw0JVuODPTdaOs5lY/NmJAdeMGywtnnSqQtV35618C 43BBzi1o78Immo62BNq6P82DuRsEh9Xm9/rosMQyk3318Xr1bwUB6oNt7L++QBumZwk7 +M22WzS9lfwnv8CDG5QwikVyG1NqtQBhu2RReZ6scb8heF1B62cjmoPZhyZ5Y13xdbgT aXmm2tV0wa/FPCb2G4ScX5TezA8XbshECiF2a8AMlNqNK7mhAKDTqK2t2W5EFQFO/HX/ HXAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=MXOmqSVB; 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 v20si7194383ejv.515.2021.09.12.22.44.45; Sun, 12 Sep 2021 22:45:09 -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=@infradead.org header.s=casper.20170209 header.b=MXOmqSVB; 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 S236985AbhIMFnw (ORCPT + 99 others); Mon, 13 Sep 2021 01:43:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236970AbhIMFnv (ORCPT ); Mon, 13 Sep 2021 01:43:51 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62ACBC061760; Sun, 12 Sep 2021 22:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=fmH2LXB3YYbj1yq4cqvqVQN291/Bevk7C+ybmXkGJs4=; b=MXOmqSVB4wrbkg1XuD8128fiQz CoUNXmPtB7i4NkqsXyoCpNKf0PDLmGLco654RxYnXy3k/+Jas+6l1fkaJCTJlza+dPHXSUR1bcvwQ U5MYc6d+C/rTkRV5T1wgXg9Udu/4TuAxLuuT+FXWhjn48+Rj5Y+RZfwEzfMCLdFN1Ai0aMCpsyiz4 3CMSbgqoecqVIL41PDlOJZ3gO5EWGMXSuAqoWJPxFNfc4TMZCAg9zCEb/KSdEGfhr99nzE1BE61TA Lttv6IVSVLflJW+z2FG1xuZoc5VoFTVrQn3WDKcL0kho+oPm+JpRYwu6Wt/PdP412f+Z1imGtjVuS t5mNUCDQ==; Received: from 089144214237.atnat0023.highway.a1.net ([89.144.214.237] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPeiZ-00DCUF-KT; Mon, 13 Sep 2021 05:41:39 +0000 From: Christoph Hellwig To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Alexander Viro Cc: Jens Axboe , Tejun Heo , linux-block@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: start switching sysfs attributes to expose the seq_file Date: Mon, 13 Sep 2021 07:41:08 +0200 Message-Id: <20210913054121.616001-1-hch@lst.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, Al pointed out multiple times that seq_get_buf is highly dangerous as it opens up the tight seq_file abstractions to buffer overflows. The last such caller now is sysfs. This series allows attributes to implement a seq_show method and switch the block and XFS code as users that I'm most familiar with to use seq_files directly after a few preparatory cleanups. With this series "leaf" users of sysfs_ops can be converted one at at a time, after that we can move the seq_get_buf into the multiplexers (e.g. kobj, device, class attributes) and remove the show method in sysfs_ops and repeat the process until all attributes are converted. This will probably take a fair amount of time. Diffstat: block/bfq-iosched.c | 12 +- block/blk-integrity.c | 44 +++++---- block/blk-mq-sysfs.c | 64 ++++++-------- block/blk-sysfs.c | 209 ++++++++++++++++++++++++++--------------------- block/blk-throttle.c | 5 - block/blk.h | 2 block/elevator.c | 42 +++++---- block/kyber-iosched.c | 7 - block/mq-deadline.c | 5 - fs/sysfs/file.c | 135 +++++++++++++++++------------- fs/sysfs/group.c | 15 +-- fs/sysfs/sysfs.h | 8 + fs/xfs/xfs_error.c | 14 +-- fs/xfs/xfs_stats.c | 24 ++--- fs/xfs/xfs_stats.h | 2 fs/xfs/xfs_sysfs.c | 96 ++++++++++----------- include/linux/elevator.h | 4 include/linux/kernfs.h | 28 ------ include/linux/seq_file.h | 4 include/linux/sysfs.h | 9 +- 20 files changed, 376 insertions(+), 353 deletions(-)