Re: [PATCH 19/35] mm/mmap: Add shadow stack pages to memory accounting

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

 



On 1/30/22 13:18, Rick Edgecombe wrote:
> +bool is_shadow_stack_mapping(vm_flags_t vm_flags)
> +{
> +	return vm_flags & VM_SHADOW_STACK;
> +}
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index bc8713a76e03..21fdb1273571 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -911,6 +911,14 @@ static inline void ptep_modify_prot_commit(struct vm_area_struct *vma,
>  	__ptep_modify_prot_commit(vma, addr, ptep, pte);
>  }
>  #endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */
> +
> +#ifndef is_shadow_stack_mapping
> +static inline bool is_shadow_stack_mapping(vm_flags_t vm_flags)
> +{
> +	return false;
> +}
> +#endif

Hold your horses there.  Remember:

+#ifdef CONFIG_X86_SHADOW_STACK
+# define VM_SHADOW_STACK       VM_HIGH_ARCH_5
+#else
+# define VM_SHADOW_STACK       VM_NONE
+#endif

Plus:

#define VM_NONE         0x00000000

That means the arch-generic version, when CONFIG_X86_SHADOW_STACK is off
compiles down to:

bool is_shadow_stack_mapping(vm_flags_t vm_flags)
{
	return vm_flags & 0x00000000;
}

I _suspect_ the compiler *might* compile that down to the same thing as:

	return false;

So, why not just have one version, no additional #ifdefs, and be done
with it?  Heck, why have the helper in the first place?  Just check
VM_SHADOW_STACK directly.



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux