mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Fleming <matt.fleming@intel.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jeremy Kerr <jeremy.kerr@canonical.com>,
	Lingzhu Xiang <lxiang@redhat.com>
Subject: Re: [RFC] efivars write(2) races
Date: Fri, 25 Jan 2013 12:50:21 +0000	[thread overview]
Message-ID: <1359118221.2496.150.camel@mfleming-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20130125002552.GC4503@ZenIV.linux.org.uk>

On Fri, 2013-01-25 at 00:25 +0000, Al Viro wrote:
> 	1) process A does write() on efivars file, reaches ->get_variable(),
> gets newdatasize set, drops efivars->lock and loses CPU before an attempt to
> grab ->i_mutex.  process B comes and does the same thing, replacing the
> variable contents.  Then it grabs ->i_mutex, updates size, drops ->i_mutex
> and buggers off.  At which point A gets CPU back and proceeds to set size
> to whatever would be valid for its write.  Only the value is bogus now...

Crap, yes. We'll have to jiggle the locking rules around to fix this
one.

> 	2) what's to prevent EFI_NOT_FOUND being hit twice?  Bad things
> will obviously happen in that case...

I'm not sure which execution path will trigger this? Oh, if we're
spinning for the spinlock in efivarfs_unlink() while another process
does a delete via efivarfs_file_write()? Yeah, that's gonna cause some
tears.

Thanks, Al.


      parent reply	other threads:[~2013-01-25 12:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-25  0:25 Al Viro
2013-01-25  3:50 ` Lingzhu Xiang
2013-01-25 13:18   ` Matt Fleming
2013-01-28  2:38     ` Lingzhu Xiang
2013-01-28 12:38       ` Matt Fleming
2013-01-29  2:30         ` Lingzhu Xiang
2013-01-25 12:50 ` Matt Fleming [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=1359118221.2496.150.camel@mfleming-mobl1.ger.corp.intel.com \
    --to=matt.fleming@intel.com \
    --cc=jeremy.kerr@canonical.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lxiang@redhat.com \
    --cc=viro@ZenIV.linux.org.uk \
    /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®