Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Shashidhar hiremath <shashidharh@vayavyalabs.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Chris Ball <cjb@laptop.org>,
	Andrei Warkentin <awarkentin@vmware.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-mmc@vger.kernel.org
Subject: Re: [PATCH 1/1] mmc: Check to disable IOCTL when card is mounted
Date: Wed, 28 Dec 2011 14:09:16 +0200	[thread overview]
Message-ID: <4EFB06EC.1050100@intel.com> (raw)
In-Reply-To: <1325069180-16319-1-git-send-email-shashidharh@vayavyalabs.com>

On 28/12/11 12:46, Shashidhar hiremath wrote:
> From: Shashidhar Hiremath <shashidharh@vayavyalabs.com>
> 
> The Patch adds a check to disable the IOCTL from running when the card is mounted
> or device is opened elsewhere.

What if someone wants to do that.

Generally the kernel does not prevent access to raw block devices
just because a file system is mounted on them, so I guess MMC should
not either.


> 
> Signed-off-by: Shashidhar Hiremath <shashidharh@vayavyalabs.com>
> ---
>  drivers/mmc/card/block.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 0cad48a..e680929 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -387,6 +387,12 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
>  		err = -EINVAL;
>  		goto cmd_done;
>  	}
> +	/* Disallow the IOCTL run if card is already mounted or device is
> +	 * opened elsewhere */
> +	if (md->usage > 3) {
> +		err = -EINVAL;
> +		goto cmd_done;
> +	}

Checking the usage will not work consistently e.g.
if there is a sysfs access or another ioctl access at the
same time, or just some other kernel user of the device.

>  
>  	card = md->queue.card;
>  	if (IS_ERR(card)) {


  parent reply	other threads:[~2011-12-28 12:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-28 10:46 [PATCH 1/1] mmc: Check to disable IOCTL when card is mounted Shashidhar hiremath
2011-12-28 11:11 ` Kishore Kadiyala
2011-12-28 12:09 ` Adrian Hunter [this message]
2011-12-28 12:46   ` Shashidhar Hiremath
2011-12-28 13:11     ` Adrian Hunter

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=4EFB06EC.1050100@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=arnd@arndb.de \
    --cc=awarkentin@vmware.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=shashidharh@vayavyalabs.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