Linux Hardening
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Kees Cook <keescook@chromium.org>, Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	"Gustavo A . R . Silva" <gustavoars@kernel.org>,
	xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH] xen/gntalloc: Replace UAPI 1-element array
Date: Tue, 6 Feb 2024 11:06:29 -0600	[thread overview]
Message-ID: <33b313d4-ee53-4cd5-842e-147d60f462d6@embeddedor.com> (raw)
In-Reply-To: <20240206170320.work.437-kees@kernel.org>



On 2/6/24 11:03, Kees Cook wrote:
> Without changing the structure size (since it is UAPI), add a proper
> flexible array member, and reference it in the kernel so that it will
> not be trip the array-bounds sanitizer[1].
> 
> Link: https://github.com/KSPP/linux/issues/113 [1]
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
> Cc: xen-devel@lists.xenproject.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks!
--
Gustavo

> ---
>   drivers/xen/gntalloc.c      | 2 +-
>   include/uapi/xen/gntalloc.h | 5 ++++-
>   2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c
> index 26ffb8755ffb..f93f73ecefee 100644
> --- a/drivers/xen/gntalloc.c
> +++ b/drivers/xen/gntalloc.c
> @@ -317,7 +317,7 @@ static long gntalloc_ioctl_alloc(struct gntalloc_file_private_data *priv,
>   		rc = -EFAULT;
>   		goto out_free;
>   	}
> -	if (copy_to_user(arg->gref_ids, gref_ids,
> +	if (copy_to_user(arg->gref_ids_flex, gref_ids,
>   			sizeof(gref_ids[0]) * op.count)) {
>   		rc = -EFAULT;
>   		goto out_free;
> diff --git a/include/uapi/xen/gntalloc.h b/include/uapi/xen/gntalloc.h
> index 48d2790ef928..3109282672f3 100644
> --- a/include/uapi/xen/gntalloc.h
> +++ b/include/uapi/xen/gntalloc.h
> @@ -31,7 +31,10 @@ struct ioctl_gntalloc_alloc_gref {
>   	__u64 index;
>   	/* The grant references of the newly created grant, one per page */
>   	/* Variable size, depending on count */
> -	__u32 gref_ids[1];
> +	union {
> +		__u32 gref_ids[1];
> +		__DECLARE_FLEX_ARRAY(__u32, gref_ids_flex);
> +	};
>   };
>   
>   #define GNTALLOC_FLAG_WRITABLE 1

      reply	other threads:[~2024-02-06 17:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 17:03 [PATCH] xen/gntalloc: Replace UAPI 1-element array Kees Cook
2024-02-06 17:06 ` Gustavo A. R. Silva [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33b313d4-ee53-4cd5-842e-147d60f462d6@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=jgross@suse.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox