From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4694813E02A for ; Sun, 3 May 2026 23:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777849337; cv=none; b=PoJxWIZ7Dtaxm7HsW2AOAKySR8FC2y2STC+ws1SlFRiA4lqSAKJhxOeCzeIVcxOJBpDneADzWzYuWPXK7DUmFbROJwNEl1H+O6ODfGIFfIz9MUnTLcMQz/ErAm+dmTreZBOUlyMKM+XkbIPbEF6Eae5WMAcfJIxSEv+qhk6CSpw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777849337; c=relaxed/simple; bh=0nkPVTIOZtoWybvWRf0WUkhS3Ld5XBksfEFCfzykh1s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lJsvHVoBi5BSHAVinRxjQvKq6xQLOrXKFOW0v1mUZbl2SpNb1INWA4HNCHeufeLNlgHGown1PEHAPfyWHWp+xjp7w7qKVFSwIIjlr+vxveo7SVg4EUbAOmLs5sSwksP4rb32Wdo+SiMgZrlVpRSOmiSXBHiaGC+t2ym2EDvFYuw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-c8173b2af32so303002a12.0 for ; Sun, 03 May 2026 16:02:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777849336; x=1778454136; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O13aNb1HJ5Ca667sB1UdqKXPXeqoh3GCzMzEHFbbH/I=; b=lQLdY3NdNk6b5GeVtbpZfTXigjJM62b7F3RGFFTq12/yaDB+hdMILnHzhkQs960cxa LObXk4GXynLF0u755s6l53SnBLtqdyAhBY+XT86DQMcp6/TYcEl+359U5BE23pYkXVx4 deOzvQrAzNMbSEph6R8o+44F6up7dH5fJ1jrd7k33xYkcTfv9Udsf4a7uucwEFnV5pBZ Fj9yinE+jiHJJ6Dta2h6rrPbY56R4JgcoC72R6oiIoyrhNMnq6MK+/HCuHRrw3vV2aoC 3jczHaZ6rREhlIN/fQAvHW05Lica5NvaBjPDVnG9gwoCwVbDtyEJd4LWyfVYomuWoJZF TiXA== X-Forwarded-Encrypted: i=1; AFNElJ8HNgvNToBAAYgZaKdBswnQZGd5SvdHv8AM7Kw+TivyTGeP6reY+vMfAXDPOwm6mA6CSA08LcUME0WDXc4=@vger.kernel.org X-Gm-Message-State: AOJu0Yzb8PEeICouRKzuPxRD6nDRrcDKNbT4ZwcfzoBF+jPwki2/b7K7 2vEJ/kXwcbJ/MKNvqlhqmTbuzGSoaOXOxUo1Ysk9D+CW6/G0aSj7iy+i X-Gm-Gg: AeBDietcShc7fbDF4nSI/GjZRr3NfG9NIFfjwyYDN6Ld+AxpIKPZp6K5t6wds9T2uuL TY/Qd+DZUt+WaYTBXxc4IdAdZuUobtQ8N6xY4xQ012/Axev49BksikQJIgmzZquq7peQ8dzI+BE wNewWO0HKWlcM54Q/dnnScsUZfmpw1rizjoLFSXt+DjTGJPI527gQXNcXyU2W7EyT9fmTzAqu/V ngy7R8K2m582Bc9MR7VIEtlCaF4kKkHaYrGZMWYe4vn693PZsAtI/n9x33+fzS9tl3B3AAUpA2+ tRR6pMdPBF9gwrA0XHsUa/R/9jL2C2tqHBrcTAm01uqGmRK91vVZv+VubbMujQy7tEl19iLFpiW O8s1f4zD3SQIWhGtQZ4/Gw43iPmEbQ9/p9mYfqS9iS9dioL91bGgcdAu9jQqIktnIsIS1XUp+ze EO1OPL02i6X6Z9inmMmAc4inUiYz/WbpNAp0XvawobEOsM2K0foILRHqx6A8PsSscToV1Sgc2te oJKnhcDijwB7lFZat/uxkn3I8TcYEkGceDSVMbpxY0TgOm9L+zR8srYD/c96u+ZsgXnV/vT12lJ fe6OaWEvz2+QnWQXLfjHuvi5D78IOYa8gxTHW459klWk7ID10khc X-Received: by 2002:a05:6a00:1d94:b0:82f:8a29:e3b4 with SMTP id d2e1a72fcca58-8352d2f7d66mr6884843b3a.50.1777849335504; Sun, 03 May 2026 16:02:15 -0700 (PDT) Received: from localhost (fpd11144dd.ap.nuro.jp. [209.17.68.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83515b01a4asm9035616b3a.43.2026.05.03.16.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 16:02:14 -0700 (PDT) Date: Mon, 4 May 2026 08:02:13 +0900 From: Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= To: Ziming Du Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, liuyongqiang13@huawei.com Subject: Re: [PATCH 1/4] PCI: Align proc_bus_pci_write() with pci_write_config() Message-ID: <20260503223843.GB3862479@rocinante> References: <20260414024544.2975605-1-duziming2@huawei.com> <20260414024544.2975605-2-duziming2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260414024544.2975605-2-duziming2@huawei.com> Hello, > - if (pos >= size) > + if (off >= dev->cfg_size) > return 0; > - if (nbytes >= size) > + if (off + size > dev->cfg_size) { > + size = dev->cfg_size - off; > nbytes = size; > - if (pos + nbytes > size) > - nbytes = size - pos; > - cnt = nbytes; > + } Some of these boundary checks have issues on the sysfs side, where for some offsets, a gratuitous pci_config_pm_runtime_get()/put() invocation would take place, even though there would be no real work done. Something to fix, too, since you are looking to align both implementations. > - if ((pos & 1) && cnt) { > + if ((off & 1) && size) { > unsigned char val; > __get_user(val, buf); Sashiko is complaining about __get_user() here. However, the following patch was sent recently, which aims to fix this (seems Syzkaller found this, too): https://lore.kernel.org/linux-pci/20260502011446.125268-1-kartikey406@gmail.com/ If this one is accepted, then there is nothing to do here. Otherwise, you could consider moving to get_user(), etc., here, too. > - while (cnt >= 4) { > + while (size >= 4) { This can still be aligned between here and sysfs. Have a look there. There is also the resource_is_exclusive() check on the sysfs side which adds a warning and a taint when write is accessing some address ranges which some driver claimed for itself. procfs does not have this at the moment (not sure if on purpose or it simly wasn't ever added). Thank you! Krzysztof