ACK: [PATCH] efi_runtime: fix access_ok build issues on 5.0 kernels

ivanhu ivan.hu at canonical.com
Mon Jan 28 08:20:35 UTC 2019



On 1/24/19 5:21 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1813059
> 
> The type argument to access_ok has been dropped in the 5.0 kernel
> so add a compat shim to handle the new version.
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   efi_runtime/efi_runtime.c | 14 ++++++++++----
>   1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 74999e10..5dfa089e 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -41,6 +41,12 @@ MODULE_LICENSE("GPL");
>   #define EFI_RUNTIME_ENABLED	efi_enabled
>   #endif
>   
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
> +#define ACCESS_OK(type, addr, size)	access_ok(addr, size)
> +#else
> +#define ACCESS_OK(type, addr, size)	access_ok(type, addr, size)
> +#endif
> +
>   /*
>    * Count the bytes in 'str', including the terminating NULL.
>    *
> @@ -87,7 +93,7 @@ copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src,
>   		return 0;
>   	}
>   
> -	if (!access_ok(VERIFY_READ, src, 1))
> +	if (!ACCESS_OK(VERIFY_READ, src, 1))
>   		return -EFAULT;
>   
>   	buf = memdup_user(src, len);
> @@ -108,7 +114,7 @@ copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src,
>   static inline int
>   get_ucs2_strsize_from_user(efi_char16_t __user *src, size_t *len)
>   {
> -	if (!access_ok(VERIFY_READ, src, 1))
> +	if (!ACCESS_OK(VERIFY_READ, src, 1))
>   		return -EFAULT;
>   
>   	*len = user_ucs2_strsize(src);
> @@ -135,7 +141,7 @@ copy_ucs2_from_user(efi_char16_t **dst, efi_char16_t __user *src)
>   {
>   	size_t len;
>   
> -	if (!access_ok(VERIFY_READ, src, 1))
> +	if (!ACCESS_OK(VERIFY_READ, src, 1))
>   		return -EFAULT;
>   
>   	len = user_ucs2_strsize(src);
> @@ -159,7 +165,7 @@ copy_ucs2_to_user_len(efi_char16_t __user *dst, efi_char16_t *src, size_t len)
>   	if (!src)
>   		return 0;
>   
> -	if (!access_ok(VERIFY_WRITE, dst, 1))
> +	if (!ACCESS_OK(VERIFY_WRITE, dst, 1))
>   		return -EFAULT;
>   
>   	return copy_to_user(dst, src, len);
> 

Acked-by: Ivan Hu <ivan.hu at canonical.com>



More information about the fwts-devel mailing list