From: Hugh Dickins <hughd@google.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Peter Xu <peterx@redhat.com>,
linux-mm@kvack.org
Subject: Re: [bug report] mm/pgtable: allow pte_offset_map[_lock]() to fail
Date: Tue, 11 Jul 2023 18:23:07 -0700 (PDT) [thread overview]
Message-ID: <7d4486c5-679d-67f8-dee4-f33d2b73517@google.com> (raw)
In-Reply-To: <3ac58297-c3b4-4ef3-9743-d96a477ac53c@moroto.mountain>
On Tue, 11 Jul 2023, Dan Carpenter wrote:
> Hello Hugh Dickins,
>
> The patch 0d940a9b270b: "mm/pgtable: allow pte_offset_map[_lock]() to
> fail" from Jun 8, 2023, leads to the following Smatch static checker
> warning:
>
> mm/userfaultfd.c:321 mfill_atomic_pte_poison()
> error: uninitialized symbol 'ptl'.
In mm-unstable or linux-next: not a problem in 6.5-rc.
Thanks, Dan: yes.
A little unfair to blame my patch for code that went in later, but it's
a good reminder that I do need to keep checking for new usages of
pte_offset_map[_lock](), and this is the only one so far.
Great that Smatch is helping me with that.
Fix to the guilty patch follows.
Hugh
>
> mm/userfaultfd.c
> 292 static int mfill_atomic_pte_poison(pmd_t *dst_pmd,
> 293 struct vm_area_struct *dst_vma,
> 294 unsigned long dst_addr,
> 295 uffd_flags_t flags)
> 296 {
> 297 int ret;
> 298 struct mm_struct *dst_mm = dst_vma->vm_mm;
> 299 pte_t _dst_pte, *dst_pte;
> 300 spinlock_t *ptl;
> 301
> 302 _dst_pte = make_pte_marker(PTE_MARKER_POISONED);
> 303 dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl);
> ^^^^
> The __pte_offset_map_lock() function does not initialize ptl if it
> returns NULL.
>
> 304
> 305 if (mfill_file_over_size(dst_vma, dst_addr)) {
> 306 ret = -EFAULT;
> 307 goto out_unlock;
> 308 }
> 309
> 310 ret = -EEXIST;
> 311 /* Refuse to overwrite any PTE, even a PTE marker (e.g. UFFD WP). */
> 312 if (!pte_none(*dst_pte))
> 313 goto out_unlock;
> 314
> 315 set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte);
> 316
> 317 /* No need to invalidate - it was non-present before */
> 318 update_mmu_cache(dst_vma, dst_addr, dst_pte);
> 319 ret = 0;
> 320 out_unlock:
> --> 321 pte_unmap_unlock(dst_pte, ptl);
> 322 return ret;
> 323 }
>
> regards,
> dan carpenter
next prev parent reply other threads:[~2023-07-12 1:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-11 7:25 Dan Carpenter
2023-07-12 1:23 ` Hugh Dickins [this message]
2023-07-12 6:50 ` Dan Carpenter
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=7d4486c5-679d-67f8-dee4-f33d2b73517@google.com \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=dan.carpenter@linaro.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox