Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753206AbcCIKun (ORCPT ); Wed, 9 Mar 2016 05:50:43 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:18761 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752768AbcCIKud (ORCPT ); Wed, 9 Mar 2016 05:50:33 -0500 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Wed, 09 Mar 2016 02:49:58 -0800 Subject: Re: [RESENT PATCH] mmc: block: fix ABI regression of mmc_blk_ioctl To: Shawn Lin , Ulf Hansson References: <1457333940-13076-1-git-send-email-shawn.lin@rock-chips.com> CC: Seshagiri Holi , , , From: Jon Hunter Message-ID: <56DFFFF2.5050508@nvidia.com> Date: Wed, 9 Mar 2016 10:50:26 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1457333940-13076-1-git-send-email-shawn.lin@rock-chips.com> X-Originating-IP: [10.21.132.159] X-ClientProxiedBy: UKMAIL101.nvidia.com (10.26.138.13) To UKMAIL101.nvidia.com (10.26.138.13) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2114 Lines: 58 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 > --- > > 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