linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Ryan Roberts <ryan.roberts@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Andrea Arcangeli <aarcange@redhat.com>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH v1] mm/userfaultfd: UFFDIO_MOVE implementation should use ptep_get()
Date: Wed, 24 Jan 2024 14:57:13 +0100	[thread overview]
Message-ID: <82c14904-fb73-4ded-a643-f4cffb5cdbe5@redhat.com> (raw)
In-Reply-To: <20240123141755.3836179-1-ryan.roberts@arm.com>

On 23.01.24 15:17, Ryan Roberts wrote:
> Commit c33c794828f2 ("mm: ptep_get() conversion") converted all
> (non-arch) call sites to use ptep_get() instead of doing a direct
> dereference of the pte. Full rationale can be found in that commit's
> log.
> 
> Since then, UFFDIO_MOVE has been implemented which does 7 direct pte
> dereferences. Let's fix those up to use ptep_get().
> 
> Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
> ---
> Hi All,
> 
> This applies on top of v6.8-rc1. I'm hoping this can be merged into the
> next rc.
> 
> I've asserted in the past that there is no reliable automated mechanism
> to catch these; I'm relying on a combination of Coccinelle (which throws
> up a lot of false positives) and some compiler magic to force a compiler
> error on dereference. But given the frequency with which new issues are
> coming up, I'll add it to my todo list to try to find an automated
> solution.
If we'd use a distinct type for pte pointers that are only passed around 
(and not worked on), the compiler would bail out when doing such 
assignments.

Like

typedef struct { unsigned long pte; } pte_t;
typedef struct { unsigned long pte; } pte2_t;


pte_t pte = { 2 };
pte2_t pte2;

pte2 = pte;

-> "error: incompatible types when assigning to type 'pte2_t' from type 
'pte_t'"


pte_get() would do the conversion.


... but just thinking about it this would require a lot of work.

-- 
Cheers,

David / dhildenb



      parent reply	other threads:[~2024-01-24 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 14:17 [PATCH v1] mm/userfaultfd: UFFDIO_MOVE implementation should use ptep_get() Ryan Roberts
2024-01-23 20:54 ` Suren Baghdasaryan
2024-01-24 13:57 ` David Hildenbrand [this message]

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=82c14904-fb73-4ded-a643-f4cffb5cdbe5@redhat.com \
    --to=david@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.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;
as well as URLs for NNTP newsgroup(s).