From: Jon Hunter <jonathanh@nvidia.com>
To: Shawn Lin <shawn.lin@rock-chips.com>,
Ulf Hansson <ulf.hansson@linaro.org>
Cc: Seshagiri Holi <sholi@nvidia.com>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [RESENT PATCH] mmc: block: fix ABI regression of mmc_blk_ioctl
Date: Wed, 9 Mar 2016 10:50:26 +0000 [thread overview]
Message-ID: <56DFFFF2.5050508@nvidia.com> (raw)
In-Reply-To: <1457333940-13076-1-git-send-email-shawn.lin@rock-chips.com>
On 07/03/16 06:59, Shawn Lin wrote:
> We should return -EINVAL if cmd is not MMC_IOC_CMD or MMC_IOC_MULTI_CMD,
> otherwise blkdev_roset will return -EPERM.
>
> Android-adb calls make_block_device_writable with ioctl(BLKROSET), which
> will return error, make remount failed:
> remount of /system failed;
> couldn't make block device writable: Operation not permitted
I think you should elaborate here why the behaviour between -EINVAL and
-EPERM is different as they are both errors. In other words, add your
comment about how the ADB code is checking for a supported command.
> openat(AT_FDCWD, "/dev/block/platform/ff420000.dwmmc/by-name/system", O_RDONLY) = 3
> ioctl(3, BLKROSET, 0) = -1 EPERM (Operation not permitted)
>
> Fixes: a5f5774c55a2 ("mmc: block: Add new ioctl to send multi commands")
> Cc: stable@vger.kernel.org
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
> drivers/mmc/card/block.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 47bc87d..170f099 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -688,6 +688,9 @@ cmd_err:
> static int mmc_blk_ioctl(struct block_device *bdev, fmode_t mode,
> unsigned int cmd, unsigned long arg)
> {
> + if (cmd != MMC_IOC_CMD && cmd != MMC_IOC_MULTI_CMD)
> + return -EINVAL;
> +
> /*
> * The caller must have CAP_SYS_RAWIO, and must be calling this on the
> * whole block device, not on a partition. This prevents overspray
The change is fine with me, but I agree with Seshagiri's comment that
instead of the above, move the following test to the mmc_blk_ioctl_cmd
and mmc_blk_ioctl_multi_cmd functions:
if ((!capable(CAP_SYS_RAWIO)) || (bdev != bdev->bd_contains))
return -EPERM;
There is a case statement that then would return -EINVAL if the command
is not supported.
If you look at V3 of the patch "mmc: block: Add new ioctl to send multi
commands" [0] this is how we had it and only in V4 (the final version)
did we move it.
Cheers
Jon
[0] http://marc.info/?l=linux-mmc&m=144224289716299&w=2
WARNING: multiple messages have this Message-ID (diff)
From: Jon Hunter <jonathanh@nvidia.com>
To: Shawn Lin <shawn.lin@rock-chips.com>,
Ulf Hansson <ulf.hansson@linaro.org>
Cc: Seshagiri Holi <sholi@nvidia.com>, <linux-mmc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [RESENT PATCH] mmc: block: fix ABI regression of mmc_blk_ioctl
Date: Wed, 9 Mar 2016 10:50:26 +0000 [thread overview]
Message-ID: <56DFFFF2.5050508@nvidia.com> (raw)
In-Reply-To: <1457333940-13076-1-git-send-email-shawn.lin@rock-chips.com>
On 07/03/16 06:59, Shawn Lin wrote:
> We should return -EINVAL if cmd is not MMC_IOC_CMD or MMC_IOC_MULTI_CMD,
> otherwise blkdev_roset will return -EPERM.
>
> Android-adb calls make_block_device_writable with ioctl(BLKROSET), which
> will return error, make remount failed:
> remount of /system failed;
> couldn't make block device writable: Operation not permitted
I think you should elaborate here why the behaviour between -EINVAL and
-EPERM is different as they are both errors. In other words, add your
comment about how the ADB code is checking for a supported command.
> openat(AT_FDCWD, "/dev/block/platform/ff420000.dwmmc/by-name/system", O_RDONLY) = 3
> ioctl(3, BLKROSET, 0) = -1 EPERM (Operation not permitted)
>
> Fixes: a5f5774c55a2 ("mmc: block: Add new ioctl to send multi commands")
> Cc: stable@vger.kernel.org
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
> drivers/mmc/card/block.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 47bc87d..170f099 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -688,6 +688,9 @@ cmd_err:
> static int mmc_blk_ioctl(struct block_device *bdev, fmode_t mode,
> unsigned int cmd, unsigned long arg)
> {
> + if (cmd != MMC_IOC_CMD && cmd != MMC_IOC_MULTI_CMD)
> + return -EINVAL;
> +
> /*
> * The caller must have CAP_SYS_RAWIO, and must be calling this on the
> * whole block device, not on a partition. This prevents overspray
The change is fine with me, but I agree with Seshagiri's comment that
instead of the above, move the following test to the mmc_blk_ioctl_cmd
and mmc_blk_ioctl_multi_cmd functions:
if ((!capable(CAP_SYS_RAWIO)) || (bdev != bdev->bd_contains))
return -EPERM;
There is a case statement that then would return -EINVAL if the command
is not supported.
If you look at V3 of the patch "mmc: block: Add new ioctl to send multi
commands" [0] this is how we had it and only in V4 (the final version)
did we move it.
Cheers
Jon
[0] http://marc.info/?l=linux-mmc&m=144224289716299&w=2
next prev parent reply other threads:[~2016-03-09 10:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-07 6:59 [RESENT PATCH] mmc: block: fix ABI regression of mmc_blk_ioctl Shawn Lin
2016-03-09 7:55 ` John Stultz
2016-03-09 10:50 ` Jon Hunter [this message]
2016-03-09 10:50 ` Jon Hunter
2016-03-09 13:51 ` Shawn Lin
2016-03-16 9:21 ` Ulf Hansson
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=56DFFFF2.5050508@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=sholi@nvidia.com \
--cc=stable@vger.kernel.org \
--cc=ulf.hansson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.