LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] lkdtm/heap: Avoid __alloc_size hint warning
Date: Wed, 18 Aug 2021 16:01:26 +0200	[thread overview]
Message-ID: <YR0StuqeKm1vbaM5@kroah.com> (raw)
In-Reply-To: <20210818044540.1601664-1-keescook@chromium.org>

On Tue, Aug 17, 2021 at 09:45:40PM -0700, Kees Cook wrote:
> Once __alloc_size hints have been added, the compiler will
> (correctly!) see this as an overflow. We are, however, trying to test
> for this condition, so work around it with a volatile int.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  drivers/misc/lkdtm/heap.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/lkdtm/heap.c b/drivers/misc/lkdtm/heap.c
> index 3d9aae5821a0..e59fcbe00ae0 100644
> --- a/drivers/misc/lkdtm/heap.c
> +++ b/drivers/misc/lkdtm/heap.c
> @@ -12,6 +12,8 @@ static struct kmem_cache *double_free_cache;
>  static struct kmem_cache *a_cache;
>  static struct kmem_cache *b_cache;
>  
> +static volatile int __offset = 1;

Perhaps a comment here as to why volatile is ok to use?  That feels like
it is a hack around the compiler of today, what happens tomorrow when
newer versions decide to ignore volatile as it "knows" no one ever
changes it?

thanks,

greg k-h

  reply	other threads:[~2021-08-18 14:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18  4:45 Kees Cook
2021-08-18 14:01 ` Greg Kroah-Hartman [this message]
2021-08-18 17:32   ` Kees Cook

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=YR0StuqeKm1vbaM5@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] lkdtm/heap: Avoid __alloc_size hint warning' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).