All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: wuqianhai@loongson.cn, chenhuacai@kernel.org, kernel@xen0n.name,
	tzimmermann@suse.de, deller@gmx.de, bhelgaas@google.com
Cc: ardb@kernel.org, ilias.apalodimas@linaro.org, javierm@redhat.com,
	linux-pci@vger.kernel.org, linux-efi@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment
Date: Tue, 10 Nov 2026 09:52:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-206810@kernel.org> (raw)
In-Reply-To: <20261110090203.2631481-3-wuqianhai@loongson.cn>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] LoongArch/PCI: repeated fixup and UAF via
  screen_info_apply_fixups()
--

commit 1413644b1b0b80d135ecb2502366b5c2eb670d52
Author: wuqianhai <wuqianhai@loongson.cn>

LoongArch/PCI: Refresh screen_info after resource assignment

This commit calls screen_info_apply_fixups() in pci_acpi_scan_root() after
assigning root bus resources so that screen_info reflects any relocated
firmware framebuffer BAR before vga_arb_device_init() and sysfb_init() run.

> diff --git a/arch/loongarch/pci/acpi.c b/arch/loongarch/pci/acpi.c
> index ccbcea61fcd9c..cb313ff67f7e7 100644
> --- a/arch/loongarch/pci/acpi.c
> +++ b/arch/loongarch/pci/acpi.c
[ ... ]
> @@ -256,6 +257,9 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  		 */
>  		pci_assign_unassigned_root_bus_resources(bus);
>  
> +		if (IS_ENABLED(CONFIG_SCREEN_INFO))
> +			screen_info_apply_fixups();

[Severity: Medium]
Is screen_info_apply_fixups() safe to call from pci_acpi_scan_root()?

screen_info_apply_fixups() was previously called only once from
sysfb_init().  When it updates the framebuffer address, it neither updates
screen_info_lfb_res_start nor clears screen_info_lfb_pdev:

drivers/video/screen_info_pci.c:screen_info_apply_fixups() {
	...
	if (screen_info_lfb_pdev) {
		struct resource *pr = &screen_info_lfb_pdev->resource[screen_info_lfb_bar];

		if (pr->start != screen_info_lfb_res_start) {
			if (__screen_info_relocation_is_valid(si, pr)) {
				__screen_info_set_lfb_base(si, pr->start + screen_info_lfb_offset);
				pr_info("Relocating firmware framebuffer to offset %pa[d] within %pr\n",
					&screen_info_lfb_offset, pr);
	...
}

Because pr->start != screen_info_lfb_res_start remains true after a
relocation, every subsequent root bridge scan on multi-root systems and the
later call in sysfb_init() will re-run the relocation branch and emit
duplicate messages.  If a built-in DRM driver probes before sysfb_init(),
calls sysfb_disable(), and resizes the BAR, sysfb_init() will also
re-evaluate the resized BAR before checking whether sysfb was disabled.

In addition, screen_info_lfb_pdev is an unreferenced pointer that is never
cleared on PCI device removal, while pci_acpi_scan_root() can be called
after boot via acpi_pci_root_add() hotplug.  Removing the boot display PCI
device and hot-adding an ACPI PCI root bridge would dereference the freed
screen_info_lfb_pdev in screen_info_apply_fixups().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261110090203.2631481-1-wuqianhai@loongson.cn?part=2

  reply	other threads:[~2026-11-10  9:52 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  9:46 [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation wuqianhai
2026-10-28 10:11 ` sashiko-bot
2026-10-28 23:15 ` Bjorn Helgaas
2026-10-29  3:39   ` wuqianhai
2026-10-29 20:03     ` Bjorn Helgaas
2026-10-29  7:54   ` Thomas Zimmermann
2026-10-29  3:34 ` [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch wuqianhai
2026-10-29  3:58   ` sashiko-bot
2026-10-29  8:10   ` Thomas Zimmermann
2026-11-10  8:56   ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai
2026-11-10  8:56     ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai
2026-11-10 14:34       ` Thomas Zimmermann
2026-11-10 14:39       ` Thomas Zimmermann
2026-11-10 16:25       ` Thomas Zimmermann
2026-11-10  8:56     ` [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment wuqianhai
2026-11-10 14:46       ` Thomas Zimmermann
2026-11-10  8:56     ` [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override wuqianhai
2026-11-10  9:01   ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai
2026-11-10  9:01     ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai
2026-11-10  9:38       ` sashiko-bot
2026-11-10  9:01     ` [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment wuqianhai
2026-11-10  9:52       ` sashiko-bot [this message]
2026-11-10  9:02     ` [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override wuqianhai
2026-11-10  9:41       ` sashiko-bot
2026-11-10  9:24     ` [PATCH v3 4/6] LoongArch: video: Implement primary framebuffer device detection wuqianhai
2026-11-10  9:58       ` sashiko-bot
2026-11-10  9:24     ` [PATCH v3 5/6] efi/libstub: Enable direct sysfb_primary_display access on LoongArch wuqianhai
2026-11-10  9:35       ` sashiko-bot
2026-11-10  9:24     ` [PATCH v3 6/6] PCI/VGA: Enable firmware default device detection " wuqianhai
2026-11-10  9:49       ` sashiko-bot
2026-11-10 10:00     ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device Huacai Chen
2026-10-29  7:00 ` [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation kernel test robot
2026-10-29 13:30 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-206810@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ardb@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=chenhuacai@kernel.org \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=javierm@redhat.com \
    --cc=kernel@xen0n.name \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tzimmermann@suse.de \
    --cc=wuqianhai@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.