Thread (60 messages) 60 messages, 8 authors, 2024-10-28

Re: [PATCH v1 11/14] futex: Implement FUTEX2_NUMA

From: Peter Zijlstra <peterz@infradead.org>
Date: 2023-07-21 12:17:09
Also in: linux-arch, linux-mm, lkml

On Fri, Jul 21, 2023 at 12:22:48PM +0200, Peter Zijlstra wrote:
quoted hunk ↗ jump to hunk
@@ -217,32 +259,55 @@ static u64 get_inode_sequence_number(str
  *
  * lock_page() might sleep, the caller should not hold a spinlock.
  */
-int get_futex_key(u32 __user *uaddr, unsigned int flags, union futex_key *key,
+int get_futex_key(void __user *uaddr, unsigned int flags, union futex_key *key,
 		  enum futex_access rw)
 {
 	unsigned long address = (unsigned long)uaddr;
 	struct mm_struct *mm = current->mm;
 	struct page *page, *tail;
 	struct address_space *mapping;
+	int node, err, size, ro = 0;
 	bool fshared;
 
 	fshared = flags & FLAGS_SHARED;
+	size = futex_size(flags);
 
 	/*
 	 * The futex address must be "naturally" aligned.
 	 */
 	key->both.offset = address % PAGE_SIZE;
+	if (unlikely((address % size) != 0))
 		return -EINVAL;
This enforces u32 alignment for:

struct futex_numa_32 {
	u32 val;
	u32 node;
};

Or do we want to enfore u64 alignment for that?
 	address -= key->both.offset;
 
+	if (flags & FLAGS_NUMA)
+		size *= 2;
+
+	if (unlikely(!access_ok(uaddr, size)))
 		return -EFAULT;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help