Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp403961rdb; Thu, 5 Oct 2023 09:08:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrsJMuWX1GnrlsyXMO8Ls9Gr5wxzIZa5TUOH46RkC+sX+GaCzu40CXyWKN7Hyo5jfyusym X-Received: by 2002:a17:902:d508:b0:1c8:77f2:7d03 with SMTP id b8-20020a170902d50800b001c877f27d03mr5555583plg.45.1696522084945; Thu, 05 Oct 2023 09:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696522084; cv=none; d=google.com; s=arc-20160816; b=rCa/EJ5VBf5JGli/HztlSgsI4K1DyTW6dHxalheKv7HwHOcdxsA3o8tecYfSHDBVYJ FqOY8EvCwXwkLZFj0zXCreC+UvlIaE5qGPV3gvZFTTTx/3y8Gc1TqZmwEqfUz86ML8XH bPqSrt903dft7SEYMuvlv1kzA4nEjkaneJt8v7lF5ur1pUoh91f7wNyGl76XFIr84ByG e8NfOq5dcWbco8yrWGv47JipGXmG88o05MGP1QMY/fuFOkzAO39eSBj2nmB2m5HwXAff kkOHuyR53JMixNift7Nmx2ZyipMMOHCjKmNFQXmFIZMm0ajzejfi1FtLNuNE8lFkQKvQ YG1A== 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=w82/1VwGzfiBD1e4zworXiOMhryzUOWk7/KsPSgG4I4=; fh=Gg9hyrJaX5rEZ8/AsKkeZHRmh9+nlnEfb2B+gGKwtoU=; b=KN1UT6cm7sKfh0/YHhUn33Syeywa8lMbKEIpQA/KZtynDqeS2tdHu1kAIYDqaWpJU/ EuGBnciyu/gIRSWF4VGxDXB6fHLFCCqTmjWg4jwjjKxMQwUz+XhCJ4f1ZyTZ9hfu+mbI d1d6LHkg8UGZH+yto2RTUAr+ROpGd7J/lQsR78A7otS3tx7+zUakaEa+OYb0xDopEEYj r2v1SagkI9VXYFPQpXLvuMZYuRwxVmjR4rQB/PvpOoujzCkj34AvXylb6KDsqPT0EFEm Yj0bluqFDnKB4TxpmYVh5+vbdicnaOyAVB3u9tQ3YiTSF8SHOkADw4uqI7FptEkD9AEh 16dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IzUJWvyg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id c6-20020a170902d48600b001bda57935fasi1886387plg.64.2023.10.05.09.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:08:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IzUJWvyg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 067AD8182ED7; Thu, 5 Oct 2023 09:07:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235880AbjJEQFH (ORCPT + 99 others); Thu, 5 Oct 2023 12:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237488AbjJEQEE (ORCPT ); Thu, 5 Oct 2023 12:04:04 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0249D5DFCE; Thu, 5 Oct 2023 07:07:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85BD5C4936D; Thu, 5 Oct 2023 11:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696506102; bh=5/c2akYQDQa+5AUEIuaC2Lyms0EC3q6cd/b6zPtv2Oc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IzUJWvyg2uWuoJwnUC4g0aGsoEtxo/jyNhLez+4oqOyCBkFG193DSI8dSz2o3sgnL Uhe1mIFQRX6RO2ROVu4vf1Gh2g7DX4xeq/W95JheoklK/cMH8sB2Agp/fu9BQzDaU3 GJ+y2Dh1NH4jiCr4PbcyH8qfF1cxi8itppxJpUgY= Date: Thu, 5 Oct 2023 13:41:38 +0200 From: Greg Kroah-Hartman To: Valentine Sinitsyn Cc: Tejun Heo , "Rafael J. Wysocki" , Bjorn Helgaas , Daniel Vetter , Dan Williams , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v9 2/2] PCI: Implement custom llseek for sysfs resource entries Message-ID: <2023100503-change-nimbly-8c58@gregkh> References: <2023092241-obedient-squirt-966c@gregkh> <20230925084013.309399-2-valesini@yandex-team.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230925084013.309399-2-valesini@yandex-team.ru> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:07:19 -0700 (PDT) On Mon, Sep 25, 2023 at 11:40:13AM +0300, Valentine Sinitsyn wrote: > Since commit 636b21b50152 ("PCI: Revoke mappings like devmem"), mmappable > sysfs entries have started to receive their f_mapping from the iomem > pseudo filesystem, so that CONFIG_IO_STRICT_DEVMEM is honored in sysfs > (and procfs) as well as in /dev/[k]mem. > > This resulted in a userspace-visible regression: > > 1. Open a sysfs PCI resource file (eg. /sys/bus/pci/devices/*/resource0) > 2. Use lseek(fd, 0, SEEK_END) to determine its size > > Expected result: a PCI region size is returned. > Actual result: 0 is returned. > > The reason is that PCI resource files residing in sysfs use > generic_file_llseek(), which relies on f_mapping->host inode to get the > file size. As f_mapping is now redefined, f_mapping->host points to an > anonymous zero-sized iomem_inode which has nothing to do with sysfs file > in question. > > Implement a custom llseek method for sysfs PCI resources, which is > almost the same as proc_bus_pci_lseek() used for procfs entries. > > This makes sysfs and procfs entries consistent with regards to seeking, > but also introduces userspace-visible changes to seeking PCI resources > in sysfs: > > - SEEK_DATA and SEEK_HOLE are no longer supported; > - Seeking past the end of the file is prohibited while previously > offsets up to MAX_NON_LFS were accepted (reading from these offsets > was always invalid). > > Fixes: 636b21b50152 ("PCI: Revoke mappings like devmem") > Cc: stable@vger.kernel.org > Signed-off-by: Valentine Sinitsyn > Acked-by: Bjorn Helgaas > --- > drivers/pci/pci-sysfs.c | 26 +++++++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) I'll take these now, for 6.7-rc1, but not mark them as fixes or cc: stable as this is a new functionality, the code has never worked for lseek on these files so it's not like anything was broken :) thanks, greg k-h