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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 21, 2023 at 12:22:48PM +0200, Peter Zijlstra wrote:
> @@ -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;



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux