lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <53026c47-4bfa-44fe-1cba-f9c78d901a02@arm.com>
Date:   Thu, 3 Feb 2022 10:54:14 +0530
From:   Anshuman Khandual <anshuman.khandual@....com>
To:     linux-mm@...ck.org
Cc:     linux-kernel@...r.kernel.org, hch@...radead.org,
        akpm@...ux-foundation.org
Subject: Re: [RFC V1 31/31] mm/mmap: Define macros for vm_flags access
 permission combinations



On 1/24/22 6:27 PM, Anshuman Khandual wrote:
> These macros will be useful in cleaning up the all those switch statements
> in vm_get_page_prot() across all platforms.
> 
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: linux-mm@...ck.org
> Cc: linux-kernel@...r.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@....com>
> ---
>  include/linux/mm.h | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 6c0844b99b3e..b3691eeec500 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -2828,6 +2828,45 @@ static inline bool range_in_vma(struct vm_area_struct *vma,
>  	return (vma && vma->vm_start <= start && end <= vma->vm_end);
>  }
>  
> +/*
> + * Access permission related vm_flags combination is used to map into
> + * platform defined page protection flags. This enumeration helps in
> + * abstracting out possible indices after vm_flags is probed for all
> + * access permission i.e  (VM_SHARED | VM_EXEC | VM_READ | VM_WRITE).
> + *
> + * VM_EXEC ---------------------|
> + *                              |
> + * VM_WRITE ---------------|    |
> + *                         |    |
> + * VM_READ -----------|    |    |
> + *                    |    |    |
> + * VM_SHARED ----|    |    |    |
> + *               |    |    |    |
> + *               v    v    v    v
> + * VMFLAGS_IDX_(S|X)(R|X)(W|X)(E|X)
> + *
> + * X - Indicates that the access flag is absent
> + */
> +enum vmflags_idx {
> +	VMFLAGS_IDX_XXXX,	/* (VM_NONE)                                    */
> +	VMFLAGS_IDX_XRXX,	/* (VM_READ)                                    */
> +	VMFLAGS_IDX_XXWX,	/* (VM_WRITE)                                   */
> +	VMFLAGS_IDX_XRWX,	/* (VM_READ | VM_WRITE)                         */
> +	VMFLAGS_IDX_XXXE,	/* (VM_EXEC)                                    */
> +	VMFLAGS_IDX_XRXE,	/* (VM_EXEC | VM_READ)                          */
> +	VMFLAGS_IDX_XXWE,	/* (VM_EXEC | VM_WRITE)                         */
> +	VMFLAGS_IDX_XRWE,	/* (VM_EXEC | VM_READ | VM_WRITE)               */
> +	VMFLAGS_IDX_SXXX,	/* (VM_SHARED | VM_NONE)                        */
> +	VMFLAGS_IDX_SRXX,	/* (VM_SHARED | VM_READ)                        */
> +	VMFLAGS_IDX_SXWX,	/* (VM_SHARED | VM_WRITE)                       */
> +	VMFLAGS_IDX_SRWX,	/* (VM_SHARED | VM_READ | VM_WRITE)             */
> +	VMFLAGS_IDX_SXXE,	/* (VM_SHARED | VM_EXEC)                        */
> +	VMFLAGS_IDX_SRXE,	/* (VM_SHARED | VM_EXEC | VM_READ)              */
> +	VMFLAGS_IDX_SXWE,	/* (VM_SHARED | VM_EXEC | VM_WRITE)             */
> +	VMFLAGS_IDX_SRWE,	/* (VM_SHARED | VM_EXEC | VM_READ | VM_WRITE)   */
> +	VMFLAGS_IDX_MAX
> +};

Defining platform specific vm_get_page_prot() involves a switch statement
with various vm_flags access combinations as cases. Hence I am wondering,
will it help to use these above macros, instead of existing combinations
separated with '|' flags. I can move this patch earlier in the series and
change all platform switch cases. Please do suggest. Thank you.

- Anshuman

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ