Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1577596rdb; Sun, 8 Oct 2023 14:51:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE66Q3PU1GvFT4xP0o8h+qsIPAPtIKE8MU97HcUF5WHAznHfVd7PnIn01BmM1axelY6Nl94 X-Received: by 2002:a05:6a20:9191:b0:16b:e46e:1246 with SMTP id v17-20020a056a20919100b0016be46e1246mr8909428pzd.30.1696801902205; Sun, 08 Oct 2023 14:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696801902; cv=none; d=google.com; s=arc-20160816; b=1G9CqHOQqm/DyRJUuwyjfZA0ABhividbWh3BTJy8YvItYT3GE/mIQpPn/DdnKqp8uR 9Vik6FpMfoRG3fIneeYVL7KHk7guBGMgfuV1xJzl50brHocPs4uTuFeJdhZ7f16E8ecP JffGZ9F+hruRbELjRql5nFuFE0/HWgsCpsWTrPr7OL0xmOWN4AEdDzVMrgevGnWNEYop FUjJlRVOKU7zWNOA8N1qLW4OtnFS5zvnqasXApC02pehdT45PL7flGSp9uRXnVuzwTRk ocRmWCoXZ7Wqj1Sanuq+6ra4CWlVlEsaZq00/99QUHsIOhW+XbKquHSzapBPccuAumCi +lmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=awdEI7BOcGPprVM/3CfxRB5xiwqGUlBHRGFcX7oUSEQ=; fh=IaNqf91zfv1Lfl7nD1x/5NOKjyD6dR4N9CHrh5HFTLA=; b=eatv88MN1dti6p3EwS9gyuzf7SEPhFeTjmqGXTPC23oONc9K028WzjJULMABn7LzJj AdCjhvFQEhlcMV15lSZPAPl8tcjN9sUZYGkYnpbcfgpOMXsHZqGk1TSH/bu7iz+/Y0iI QNqB4kXOmW3saBD/TznhBWyJlCItbQyC6hjtCIwGua6sP5dmg31PAPcF54A4MvqDCRcx s+m/QEDc3ovTXX/Dafb42hSjp0sZ0mp0My17ZO5dRvspoTlNR0ypCDdGYwCSWlZxtlQg B/2/Wis7jOp3aWgrQZOksUeji9zD+d1p+HS6vKpOqt1BOiUI+1h7rPlmDhXExKip5l5G ZNhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=1PkLZQSw; 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=yandex-team.ru Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bq9-20020a056a000e0900b0068e26ca7f00si5986224pfb.39.2023.10.08.14.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 14:51:42 -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=@yandex-team.ru header.s=default header.b=1PkLZQSw; 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=yandex-team.ru Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id CFEEB805118D; Sun, 8 Oct 2023 14:51:38 -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 S1344638AbjJHVv2 (ORCPT + 99 others); Sun, 8 Oct 2023 17:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232399AbjJHVv1 (ORCPT ); Sun, 8 Oct 2023 17:51:27 -0400 Received: from forwardcorp1b.mail.yandex.net (forwardcorp1b.mail.yandex.net [178.154.239.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B0EB3; Sun, 8 Oct 2023 14:51:19 -0700 (PDT) Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c08:ba1:0:640:375a:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 5769E623B2; Mon, 9 Oct 2023 00:51:16 +0300 (MSK) Received: from [IPV6:2a02:6b8:b081:b6af::1:24] (unknown [2a02:6b8:b081:b6af::1:24]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id EpjYFZBOlKo0-yX8dmxAB; Mon, 09 Oct 2023 00:51:15 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1696801875; bh=awdEI7BOcGPprVM/3CfxRB5xiwqGUlBHRGFcX7oUSEQ=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=1PkLZQSwcgjw0NKUEL5quf1CLlsPk8ZZIFP0bp8ZxIVKo8RTPM4U+azlz6gPOKPhp AOt8F7HXEBAndI4Ig7CM4MkW/u9MopJO7JHioHCtrigZiIVlmMXjGABC2tiAPKdwQ6 qTktzzKKqSezN37JUKFLwDmbe9IDhdjzxTsD0788= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru Message-ID: <2c7bfe48-b2f5-41a2-81b9-34a49c139d87@yandex-team.ru> Date: Mon, 9 Oct 2023 02:51:13 +0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 2/2] PCI: Implement custom llseek for sysfs resource entries Content-Language: ru, en-US To: Greg Kroah-Hartman Cc: Tejun Heo , "Rafael J. Wysocki" , Bjorn Helgaas , Daniel Vetter , Dan Williams , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org References: <2023092241-obedient-squirt-966c@gregkh> <20230925084013.309399-2-valesini@yandex-team.ru> <2023100503-change-nimbly-8c58@gregkh> From: Valentin Sinitsyn In-Reply-To: <2023100503-change-nimbly-8c58@gregkh> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Sun, 08 Oct 2023 14:51:39 -0700 (PDT) X-Spam-Level: ** On 05.10.2023 16:41, Greg Kroah-Hartman wrote: > 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: Thanks, appreciated. > 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 :) In fact, lseek() on PCI resource files in sysfs was broken since commit 636b21b50152. That was the reason why I started to investigate the issue: one of our applications stopped working after a kernel update. I'm not hundred percent sure if it belongs to stable, but it does fix a user-visible regression. Best, Valentin