public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Clements <paul.clements@steeleye.com>
To: Pavel Machek <pavel@suse.cz>
Cc: kernel list <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: nbd: add locking to nbd_ioctl
Date: Mon, 26 Jan 2009 12:01:27 -0500	[thread overview]
Message-ID: <497DEC67.8030709@steeleye.com> (raw)
In-Reply-To: <20090126164959.GB4145@atrey.karlin.mff.cuni.cz>

Pavel Machek wrote:
>> Pavel Machek wrote:
>>>> Pavel Machek wrote:
>>>>> On Fri 2009-01-16 10:24:06, Paul Clements wrote:
>>>> lo->sock is only modified under tx_lock (except for SET_SOCK, where the 
>>>> device is being initialized, in which case it's impossible for any other 
>>>> thread to be accessing the device)
>>> Well, unless the user is evil or confused? :-).
>> Even in that case, you're just going to get EBUSY. Nothing bad will 
>> happen. SET_SOCK checks for lo->file, so it cannot be called on an 
>> active nbd device.
>>
>>
>>>> As for other fields, I assume you're talking about blksize, et al. 
>>>> Taking tx_lock doesn't prevent you from screwing yourself if you modify 
>>>> those while the device is active. You'd need to disallow those ioctls 
>>>> when the device is active (check lo->file). Again, this is only going to 
>>>> happen if you really misuse the ioctls.
>>> Ok, I'll take a look at the missing checks. I'd really like to make
>>> this "stable" -- no amount of misuse should crash the kernel.
>> Just to summarize, I don't think we need to hold tx_lock around the 
>> entirety of nbd_ioctl. We do need one extra tx_lock around xmit_timeout 
>> and we do need to check for lo->file and return EBUSY in all of the 
>> SET_*SIZE* ioctls.
> 
> I could do that but it would be a bit too complex, and still rely on
> big kernel lock. Would you agree to patch that added tx_lock around
> all of it, and moved ioctl to unlocked ioctl?

OK, I can buy the complexity argument. Your patch sounds fine to me.

--
Paul

  reply	other threads:[~2009-01-26 17:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-16 11:55 nbd: add locking to nbd_ioctl Pavel Machek
2009-01-16 12:08 ` Pavel Machek
2009-01-16 12:29 ` Arnd Bergmann
2009-01-16 15:24 ` Paul Clements
2009-01-16 15:36   ` Pavel Machek
2009-01-16 16:28     ` Paul Clements
2009-01-19  9:54       ` Pavel Machek
2009-01-19 14:56         ` Paul Clements
2009-01-26 16:49           ` Pavel Machek
2009-01-26 17:01             ` Paul Clements [this message]
2009-01-26 17:32               ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2009-01-26 17:31 Pavel Machek
2009-01-29  1:14 ` Andrew Morton
2009-01-29  1:18 ` Andrew Morton

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=497DEC67.8030709@steeleye.com \
    --to=paul.clements@steeleye.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    /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