Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932805AbcCIODA (ORCPT ); Wed, 9 Mar 2016 09:03:00 -0500 Received: from mr213139.mail.yeah.net ([223.252.213.139]:53673 "EHLO mr213139.mail.yeah.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932763AbcCIOCu (ORCPT ); Wed, 9 Mar 2016 09:02:50 -0500 X-Greylist: delayed 645 seconds by postgrey-1.27 at vger.kernel.org; Wed, 09 Mar 2016 09:02:48 EST Subject: Re: [RESENT PATCH] mmc: block: fix ABI regression of mmc_blk_ioctl To: Jon Hunter , Shawn Lin , Ulf Hansson References: <1457333940-13076-1-git-send-email-shawn.lin@rock-chips.com> <56DFFFF2.5050508@nvidia.com> Cc: shawn.lin@kernel-upstream.org, Seshagiri Holi , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org From: Shawn Lin Message-ID: <56E02A61.6010003@kernel-upstream.org> Date: Wed, 9 Mar 2016 21:51:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56DFFFF2.5050508@nvidia.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUJVTUhCQkJCSENCTU9DT0hDV1kJDhceCFlBWS grPSQrOigoJDI1JDM#Oj8#KUFLVUtANiMkNTQkMjUkMz46Pz4pQU5VS0ArLykkIj4oJDI1JDM#Oj 8#KUFLVUtAKT48MjQ1JDU0KS8zJDo2PikyODpBS1VLQD8iNTo2MjgkMiskNTQkMjUkMz46Pz4pQU tVS0A2LjcvMiQpOCsvJD8yPT0#KT41LyQyNSQzPjo*PilBSVVLQDIrJC80PzoiJDg1LyRLJEpLS0 FLVUtAMiskSEskNjI1Li8#JDg1LyRLJE5LQUtVS0AyKyRKJDYyNS4vPiQ4NS8kSyRKS0FLVUtAMi skSiQzNC4pJDg1LyRLJEpLS0FLVUtAMiskTiQ2MjUuLz4kODUvJEskSktBS1VLQCguOTE#OC8kTi Q2MjUuLz4kODUvJEskSktBS1VLQCguOTE#OC8kSiQzNC4pJDg1LyRLJEpLS0FLVUtAKC45MT44Ly QvND86IiQ4NS8kSyRKS0tBS1VLQD01JDY6IiRPSkIkMzcxJEokS0NLSEtPQUtVSEhAPSskKT4kPS wkMzcxJEtDS0hLTUFWTFVOQD01JCguOSQ#NSw0KT8oJDM3MSRKS0tJS0pBS1VJQ0AoLjkkPkFKVU 5OQD01JC4pNzI1PTQkMzcxJEtMS05LTUFPVUNIQD01JDkyL0wkMzcxJEtMSklLSUFIVUpOQD01JD Y6IiRPSkIkMzcxJEkkS0NLSEtPQUtVS1kG X-HM-Sender-Digest: e1kSHx4VD1lBWUc6NUk6KRw5CDo9EQ86MyEUHhQdKFEKCwhVSlVKT05M TkhKTklLSk1IVTMWGhIXVQgTGgwVVRcSFTsQHgkVHhdWDgsIDwkeGhZVFAkcRVlXWQweGVlBHRoX CB5XWQgBWUFPT0JNN1dZEgtZQVlKS09VSExVTlVKT0lZBg++ X-HM-Tid: 0a535ba600047d8be85c41c1cfa Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2884 Lines: 81 On 2016/3/9 18:50, Jon Hunter wrote: > > 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. yep. So if need to send v2 after comment from Ulf, I will add more into commit-msg. > >> 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; > right, and both are ok to me :). Adding this check for mmc_blk_ioctl_cmd and mmc_blk_ioctl_multi_cmd respectively may also looks like we produce two some code sections that do the same thing. I think it depends on how Ulf want the solution to be? Let's wait for Ulf' comment. > 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. yes, I read V3 and V4 both to see how the patch was going. Thanks for sharing it. > > Cheers > Jon > > [0] http://marc.info/?l=linux-mmc&m=144224289716299&w=2 > -- > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >