public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch] x86, microcode, AMD: use after free in free_cache()
Date: Thu, 06 Sep 2012 14:04:01 +0000	[thread overview]
Message-ID: <20120906140401.GJ19410@mwanda> (raw)
In-Reply-To: <20120905123042.GB6128@elgon.mountain>

On Thu, Sep 06, 2012 at 03:06:53PM +0200, Borislav Petkov wrote:
> On Thu, Sep 06, 2012 at 05:30:48AM -0700, Dan Carpenter wrote:
> > > #define list_for_each_entry_reverse(pos, head, member)			\
> > > 	for (pos = list_entry((head)->prev, typeof(*pos), member);	\
> > > 	     &pos->member != (head); 	\					<--- DEREF.
> > 
> > No.  That's not what I'm talking about.  (And also that's not a
> > dereference, it just gives you the address of the struct member).
> > 
> > > 	     pos = list_entry(pos->member.prev, typeof(*pos), member))
> >                               ^^^^^
> > Here is the dereference.  We have already freed "pos" at this point.
> 
> Ok, I see it now, thanks for pointing it out exactly.
> 
> One last thing remains: why didn't I hit this during testing at all?
> Timings, or some other out-of-order x86 reason I'm unable to see now?
> 

You wouldn't see it unless something called kmalloc() on another CPU
and reused the freed memory.  Or if you had CONFIG_DEBUG_SLAB
enabled then I believe that will poison freed memory immediately.

(Btw, I haven't tested this code either before or after my patch
because I don't have any AMD systems).

regards,
dan carpenter


  parent reply	other threads:[~2012-09-06 14:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05 12:30 [patch] x86, microcode, AMD: use after free in free_cache() Dan Carpenter
2012-09-05 13:20 ` Borislav Petkov
2012-09-05 23:42 ` Dan Carpenter
2012-09-06 12:01 ` Borislav Petkov
2012-09-06 12:30 ` Dan Carpenter
2012-09-06 13:06 ` Borislav Petkov
2012-09-06 14:04 ` Dan Carpenter [this message]
2012-09-06 16:16 ` Borislav Petkov
2012-09-12 11:00 ` Borislav Petkov

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=20120906140401.GJ19410@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.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