mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Julio Auto" <mindvortex@gmail.com>
To: "David Wagner" <daw-usenet@taverner.cs.berkeley.edu>,
	schwidefsky@de.ibm.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [S390] cio: kernel stack overflow.
Date: Wed, 30 Aug 2006 14:52:33 -0300	[thread overview]
Message-ID: <18d709710608301052u1307139dpf6e3b2da6e7bfcbe@mail.gmail.com> (raw)
In-Reply-To: <ed4gno$d29$1@taverner.cs.berkeley.edu>

On 8/30/06, David Wagner <daw@cs.berkeley.edu> wrote:
> Have you checked that in all cases all fields of the struct have
> been overwritten?  For instance, look at this:
>
> Martin Schwidefsky  wrote:
> >-      chp->dev = (struct device) {
> >-              .parent  = &css[0]->device,
> >-              .release = chp_release,
> >-      };
> >+      chp->dev.parent = &css[0]->device;
> >+      chp->dev.release = chp_release;
>
> Doesn't this leave chp->dev.bus still holding whatever old value it
> had laying around before?

You're correct. While this eliminates the possibility of getting
random values from the stack, it still leaves space for letting
previous unwanted values unchanged.
Unless, of course, the structure in question is kcalloc()'d (which is
not the case of gdev in the beginning of the patch - I haven't had the
time to check the other cases). But we surely can't rely on that.

>Unless I'm missing something, it looks to
> me like this diff causes a change in the semantics of the code.

I can't see the semantic change.

>
> Perhaps it would be better to memset() the entire struct (chp->dev, in
> this case) to zero, before assigning to individual fields, so there is
> no possibility of old remnant data still being left laying around?

Yes. Since the code can't be depend on the caller passing a zeroed
structure, it's definitely more safe to memset to 0 (or use kcalloc(),
instead of kmalloc(), when the allocation is the routine's own
responsability).

Changing subjects a little bit: where's the stack overflow in the
code? Either I'm too stupid to find it myself by looking at the patch
or the e-mail is mistitled.

Cheers,

    Julio Auto

  parent reply	other threads:[~2006-08-30 17:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-30 12:40 Martin Schwidefsky
2006-08-30 17:09 ` David Wagner
2006-08-30 17:40   ` Martin Schwidefsky
2006-08-30 17:52   ` Julio Auto [this message]
2006-08-30 18:20     ` Julio Auto
2006-08-30 18:41     ` David Wagner
2006-08-30 19:05 ` David Wagner
2006-08-30 19:19   ` Heiko Carstens
2006-08-31  9:06     ` Martin Schwidefsky
2006-08-30 19:25   ` Julio Auto

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=18d709710608301052u1307139dpf6e3b2da6e7bfcbe@mail.gmail.com \
    --to=mindvortex@gmail.com \
    --cc=daw-usenet@taverner.cs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    /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

all inboxes | Powered by JetHome®