public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] mmc: block: remove the check for whole block device for ioctl.
  2016-03-15 15:26 [PATCH] mmc: block: remove the check for whole block device for ioctl Yin, Fengwei
@ 2016-03-15 14:31 ` Christoph Hellwig
  2016-03-15 23:44   ` fengwei.yin
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2016-03-15 14:31 UTC (permalink / raw)
  To: Yin, Fengwei; +Cc: jonathanh, ulf.hansson, linux-kernel

On Tue, Mar 15, 2016 at 11:26:07AM -0400, Yin, Fengwei wrote:
> From: Fengwei Yin <fengwei.yin@linaro.org>
> 
> a5f5774c55a2e3ed75f4d6c5556b7bfcb726e6f0 introduced the whole block
> device checking for MMC_IOC_CMD while the old code has no such check.
> 
> It breaks some ioctl call like BLKROSET from user space. An example
> is "adb remount" cmd. It prints out following error message:
> "remount of /system failed; couldn't make block device XXXX writable: \
> Operation not permitted."
> while the command worked fine.
> 
> This change move the whole block device checking only for MMC_IOC_MULTI_CMD.

I think mmc_blk_ioctl_cmd will need this as well, as will probably
do any new ioctl.

So I think the right fix is to simply return -EINVAL instead of
EPERM if on a partition, which will make all the block layer ioctls
works fine.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] mmc: block: remove the check for whole block device for ioctl.
@ 2016-03-15 15:26 Yin, Fengwei
  2016-03-15 14:31 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Yin, Fengwei @ 2016-03-15 15:26 UTC (permalink / raw)
  To: jonathanh, ulf.hansson, linux-kernel; +Cc: fengwei.yin

From: Fengwei Yin <fengwei.yin@linaro.org>

a5f5774c55a2e3ed75f4d6c5556b7bfcb726e6f0 introduced the whole block
device checking for MMC_IOC_CMD while the old code has no such check.

It breaks some ioctl call like BLKROSET from user space. An example
is "adb remount" cmd. It prints out following error message:
"remount of /system failed; couldn't make block device XXXX writable: \
Operation not permitted."
while the command worked fine.

This change move the whole block device checking only for MMC_IOC_MULTI_CMD.

Signed-off-by: Fengwei Yin <fengwei.yin@linaro.org>
---
 drivers/mmc/card/block.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index fe207e5..72b9053 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -693,7 +693,7 @@ static int mmc_blk_ioctl(struct block_device *bdev, fmode_t mode,
 	 * whole block device, not on a partition.  This prevents overspray
 	 * between sibling partitions.
 	 */
-	if ((!capable(CAP_SYS_RAWIO)) || (bdev != bdev->bd_contains))
+	if (!capable(CAP_SYS_RAWIO))
 		return -EPERM;
 
 	switch (cmd) {
@@ -701,6 +701,9 @@ static int mmc_blk_ioctl(struct block_device *bdev, fmode_t mode,
 		return mmc_blk_ioctl_cmd(bdev,
 				(struct mmc_ioc_cmd __user *)arg);
 	case MMC_IOC_MULTI_CMD:
+        if (bdev != bdev->bd_contains)
+            return -EPERM;
+
 		return mmc_blk_ioctl_multi_cmd(bdev,
 				(struct mmc_ioc_multi_cmd __user *)arg);
 	default:
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: block: remove the check for whole block device for ioctl.
  2016-03-15 14:31 ` Christoph Hellwig
@ 2016-03-15 23:44   ` fengwei.yin
       [not found]     ` <56E947F8.2040105@nvidia.com>
  0 siblings, 1 reply; 4+ messages in thread
From: fengwei.yin @ 2016-03-15 23:44 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jonathanh, ulf.hansson, linux-kernel



On 2016/3/15 22:31, Christoph Hellwig wrote:
> On Tue, Mar 15, 2016 at 11:26:07AM -0400, Yin, Fengwei wrote:
>> From: Fengwei Yin <fengwei.yin@linaro.org>
>>
>> a5f5774c55a2e3ed75f4d6c5556b7bfcb726e6f0 introduced the whole block
>> device checking for MMC_IOC_CMD while the old code has no such check.
>>
>> It breaks some ioctl call like BLKROSET from user space. An example
>> is "adb remount" cmd. It prints out following error message:
>> "remount of /system failed; couldn't make block device XXXX writable: \
>> Operation not permitted."
>> while the command worked fine.
>>
>> This change move the whole block device checking only for MMC_IOC_MULTI_CMD.
>
> I think mmc_blk_ioctl_cmd will need this as well, as will probably
> do any new ioctl.
>
> So I think the right fix is to simply return -EINVAL instead of
> EPERM if on a partition, which will make all the block layer ioctls
> works fine.
Fair enough.

I will wait for one more day for further comments to the patch. And update
the patch tomorrow. Thanks a lot for looking into the patch.

Regards
Yin, Fengwei

>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: block: remove the check for whole block device for ioctl.
       [not found]     ` <56E947F8.2040105@nvidia.com>
@ 2016-03-16 13:49       ` fengwei.yin
  0 siblings, 0 replies; 4+ messages in thread
From: fengwei.yin @ 2016-03-16 13:49 UTC (permalink / raw)
  To: Jon Hunter, Christoph Hellwig; +Cc: ulf.hansson, linux-kernel



On 2016/3/16 19:48, Jon Hunter wrote:
>
> On 15/03/16 23:44, fengwei.yin wrote:
>>
>>
>> On 2016/3/15 22:31, Christoph Hellwig wrote:
>>> On Tue, Mar 15, 2016 at 11:26:07AM -0400, Yin, Fengwei wrote:
>>>> From: Fengwei Yin <fengwei.yin@linaro.org>
>>>>
>>>> a5f5774c55a2e3ed75f4d6c5556b7bfcb726e6f0 introduced the whole block
>>>> device checking for MMC_IOC_CMD while the old code has no such check.
>>>>
>>>> It breaks some ioctl call like BLKROSET from user space. An example
>>>> is "adb remount" cmd. It prints out following error message:
>>>> "remount of /system failed; couldn't make block device XXXX writable: \
>>>> Operation not permitted."
>>>> while the command worked fine.
>>>>
>>>> This change move the whole block device checking only for
>>>> MMC_IOC_MULTI_CMD.
>>>
>>> I think mmc_blk_ioctl_cmd will need this as well, as will probably
>>> do any new ioctl.
>>>
>>> So I think the right fix is to simply return -EINVAL instead of
>>> EPERM if on a partition, which will make all the block layer ioctls
>>> works fine.
>> Fair enough.
>>
>> I will wait for one more day for further comments to the patch. And update
>> the patch tomorrow. Thanks a lot for looking into the patch.
>
> There is already a patch in the works for this [0].
>
> Cheers
> Jon
>
> [0] http://marc.info/?l=linux-mmc&m=145812340114153&w=2

Thanks a lot for the information. I will drop my patch.

Regards
Yin, Fengwei

>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-16 13:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-15 15:26 [PATCH] mmc: block: remove the check for whole block device for ioctl Yin, Fengwei
2016-03-15 14:31 ` Christoph Hellwig
2016-03-15 23:44   ` fengwei.yin
     [not found]     ` <56E947F8.2040105@nvidia.com>
2016-03-16 13:49       ` fengwei.yin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox