From: sashiko-bot@kernel.org
To: "Krzysztof Wilczyński" <kwilczynski@kernel.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 3/3] proc: Unmap mmaps of removed files via file->f_mapping
Date: Sat, 25 Jul 2026 21:19:58 +0000 [thread overview]
Message-ID: <20260725211958.B801E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260725210549.3716546-4-kwilczynski@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] A TOCTOU race allows a newly mmap'd VMA to bypass the zapping process during device rundown, leaving active PTEs mapped to removed hardware.
--
--- Patch [3]: [PATCH v2 3/3] proc: Unmap mmaps of removed files via file->f_mapping ---
commit d70ab9967b02c9e0d34615bf288a6ac4be654e1f
Author: Krzysztof Wilczyński <kwilczynski@kernel.org>
proc: Unmap mmaps of removed files via file->f_mapping
This commit unmaps user space mappings associated with removable proc
entries when the entry is being removed. It does this by calling
unmap_mapping_file() in close_pdeo() for each open file.
> diff --git a/fs/proc/inode.c b/fs/proc/inode.c
> --- a/fs/proc/inode.c
> +++ b/fs/proc/inode.c
> @@ -239,6 +239,8 @@ static void close_pdeo(struct proc_dir_entry *pde, struct pde_opener *pdeo)
> spin_unlock(&pde->pde_unload_lock);
>
> file = pdeo->file;
> + if (pde_is_removed(pde))
> + unmap_mapping_file(file);
[Severity: Critical]
Can this race with a concurrent mmap() operation?
Looking at proc_reg_mmap() in fs/proc/inode.c, the PDE usage count is
dropped before the VMA is linked into the address space:
fs/proc/inode.c:proc_reg_mmap() {
...
rv = pde_mmap(pde, file, vma);
unuse_pde(pde);
return rv;
}
If Thread A drops the usage count via unuse_pde(), Thread B's rundown
could proceed and execute unmap_mapping_file() here.
Because Thread A has not yet returned to the VFS layer to link the VMA
to the interval tree:
mm/vma.c:__mmap_new_vma() {
...
vma_link_file(vma, action->hide_from_rmap_until_complete);
...
}
Would unmap_mapping_file() miss this new VMA, allowing Thread A to return
to userspace with an active mapping to the removed device?
> pde->proc_ops->proc_release(file_inode(file), file);
>
> spin_lock(&pde->pde_unload_lock);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260725210549.3716546-1-kwilczynski@kernel.org?part=3
next prev parent reply other threads:[~2026-07-25 21:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 21:05 [PATCH v2 0/3] mm,kernfs,proc: Unmap mmaps of removed files via file->f_mapping Krzysztof Wilczyński
2026-07-25 21:05 ` [PATCH v2 1/3] mm: Add unmap_mapping_file() helper Krzysztof Wilczyński
2026-07-25 21:35 ` sashiko-bot
2026-07-25 21:05 ` [PATCH v2 2/3] kernfs: Unmap mmaps of removed files via file->f_mapping Krzysztof Wilczyński
2026-07-25 21:22 ` sashiko-bot
2026-07-25 21:05 ` [PATCH v2 3/3] proc: " Krzysztof Wilczyński
2026-07-25 21:19 ` sashiko-bot [this message]
2026-07-25 21:37 ` [PATCH v2 0/3] mm,kernfs,proc: " Andrew Morton
2026-07-26 1:22 ` Krzysztof Wilczyński
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=20260725211958.B801E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.