public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Joe Perches <joe@perches.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Dan Carpenter <error27@gmail.com>,
	Julia Lawall <julia.lawall@lip6.fr>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] kernel: sys.c: Avoid copying possible padding bytes in copy_to_user
Date: Mon, 28 Oct 2019 10:18:56 +0300	[thread overview]
Message-ID: <20191028071856.GA1944@kadam> (raw)
In-Reply-To: <dfa331c00881d61c8ee51577a082d8bebd61805c.camel@perches.com>

On Sat, Oct 26, 2019 at 12:46:08PM -0700, Joe Perches wrote:
> Initialization is not guaranteed to zero padding bytes so
> use an explicit memset instead to avoid leaking any kernel
> content in any possible padding bytes.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  kernel/sys.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sys.c b/kernel/sys.c
> index a611d1..3459a5 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -1279,11 +1279,13 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)
>  
>  SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
>  {
> -	struct oldold_utsname tmp = {};
> +	struct oldold_utsname tmp;

oldold_utsname doesn't have an struct holes.  It looks like this:

struct oldold_utsname {
        char sysname[9];
        char nodename[9];
        char release[9];
        char version[9];
        char machine[9];
};

regards,
dan carpenter


  parent reply	other threads:[~2019-10-28  7:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-26 19:46 [PATCH] kernel: sys.c: Avoid copying possible padding bytes in copy_to_user Joe Perches
2019-10-27  5:47 ` Julia Lawall
2019-10-27 22:47   ` Joe Perches
2019-10-28  7:30     ` Dan Carpenter
2019-10-28 18:58     ` Kees Cook
2019-10-28  7:18 ` Dan Carpenter [this message]
2019-10-28  8:08   ` Joe Perches

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=20191028071856.GA1944@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=error27@gmail.com \
    --cc=joe@perches.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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