Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH -next] mtd: fix missing unlock on error in mtdchar_compat_ioctl()
@ 2020-07-25  6:34 Wei Yongjun
  2020-07-25  6:37 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2020-07-25  6:34 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Greg Kroah-Hartman
  Cc: linux-mtd, kernel-janitors, Wei Yongjun, linux-kernel, Hulk Robot

Add the missing unlock before return from function mtdchar_compat_ioctl()
in the error handling case.

Fixes: 210bec567936 ("mtd: properly check all write ioctls for permissions")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/mtd/mtdchar.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 52c120f9fb0d..b40f46a43fc6 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1064,8 +1064,10 @@ static long mtdchar_compat_ioctl(struct file *file, unsigned int cmd,
 		struct mtd_oob_buf32 buf;
 		struct mtd_oob_buf32 __user *buf_user = argp;
 
-		if (!(file->f_mode & FMODE_WRITE))
-			return -EPERM;
+		if (!(file->f_mode & FMODE_WRITE)) {
+			ret = -EPERM;
+			break;
+		}
 
 		if (copy_from_user(&buf, argp, sizeof(buf)))
 			ret = -EFAULT;




______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH -next] mtd: fix missing unlock on error in mtdchar_compat_ioctl()
  2020-07-25  6:34 [PATCH -next] mtd: fix missing unlock on error in mtdchar_compat_ioctl() Wei Yongjun
@ 2020-07-25  6:37 ` Greg Kroah-Hartman
  2020-07-25  8:13   ` Richard Weinberger
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2020-07-25  6:37 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Vignesh Raghavendra, Richard Weinberger, kernel-janitors,
	linux-kernel, Hulk Robot, linux-mtd, Miquel Raynal

On Sat, Jul 25, 2020 at 06:34:16AM +0000, Wei Yongjun wrote:
> Add the missing unlock before return from function mtdchar_compat_ioctl()
> in the error handling case.
> 
> Fixes: 210bec567936 ("mtd: properly check all write ioctls for permissions")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/mtd/mtdchar.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index 52c120f9fb0d..b40f46a43fc6 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c
> @@ -1064,8 +1064,10 @@ static long mtdchar_compat_ioctl(struct file *file, unsigned int cmd,
>  		struct mtd_oob_buf32 buf;
>  		struct mtd_oob_buf32 __user *buf_user = argp;
>  
> -		if (!(file->f_mode & FMODE_WRITE))
> -			return -EPERM;
> +		if (!(file->f_mode & FMODE_WRITE)) {
> +			ret = -EPERM;
> +			break;
> +		}
>  
>  		if (copy_from_user(&buf, argp, sizeof(buf)))
>  			ret = -EFAULT;
> 
> 
> 

I think Richard already resolved this in his tree, but I could be wrong.

And nice detection by your bot, that's good to see.

thanks,

greg k-h

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH -next] mtd: fix missing unlock on error in mtdchar_compat_ioctl()
  2020-07-25  6:37 ` Greg Kroah-Hartman
@ 2020-07-25  8:13   ` Richard Weinberger
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2020-07-25  8:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Vignesh Raghavendra, kernel-janitors, linux-kernel, Hulk Robot,
	linux-mtd, Miquel Raynal, Wei Yongjun

----- Ursprüngliche Mail -----
> Von: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
> An: "Wei Yongjun" <weiyongjun1@huawei.com>
> CC: "Miquel Raynal" <miquel.raynal@bootlin.com>, "richard" <richard@nod.at>, "Vignesh Raghavendra" <vigneshr@ti.com>,
> "linux-mtd" <linux-mtd@lists.infradead.org>, "linux-kernel" <linux-kernel@vger.kernel.org>, "kernel-janitors"
> <kernel-janitors@vger.kernel.org>, "Hulk Robot" <hulkci@huawei.com>
> Gesendet: Samstag, 25. Juli 2020 08:37:01
> Betreff: Re: [PATCH -next] mtd: fix missing unlock on error in mtdchar_compat_ioctl()
> I think Richard already resolved this in his tree, but I could be wrong.

Yes, fixed in git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes
and should be visible in linux-next very soon.
 
> And nice detection by your bot, that's good to see.

Yeah, good to see that such issues are being detected automatically.

Thanks,
//richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-25  6:34 [PATCH -next] mtd: fix missing unlock on error in mtdchar_compat_ioctl() Wei Yongjun
2020-07-25  6:37 ` Greg Kroah-Hartman
2020-07-25  8:13   ` Richard Weinberger

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org
	public-inbox-index linux-mtd

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git