lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090203205857.a2b4b1c1.akpm@linux-foundation.org>
Date:	Tue, 3 Feb 2009 20:58:57 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Dan Carpenter <error27@...il.com>
Cc:	R.E.Wolff@...Wizard.nl, linux-kernel@...r.kernel.org
Subject: Re: [patch] unlock_kernel() on error path in sx_fw_ioctl()

On Tue, 3 Feb 2009 11:14:21 +0300 (EAT) Dan Carpenter <error27@...il.com> wrote:

> If we return directly with -EPERM then lock_kernel() is still held.
> 
> This was found with a code checker (http://repo.or.cz/w/smatch.git/). 
> Compile tested only, sorry.
> 
> regards,
> dan carpenter
> 
> Signed-off-by: Dan Carpenter <error27@...il.com>
> 
> --- orig/drivers/char/sx.c	2009-02-03 08:27:59.000000000 +0300
> +++ devel/drivers/char/sx.c	2009-02-03 08:28:31.000000000 +0300
> @@ -1747,7 +1747,8 @@
>   		break;
>   	case SXIO_DO_RAMTEST:
>   		if (sx_initialized)	/* Already initialized: better not ramtest the board.  */
> -			return -EPERM;
> +			rc = -EPERM;
> +			break;
>   		if (IS_SX_BOARD(board)) {
>   			rc = do_memtest(board, 0, 0x7000);
>   			if (!rc)

Yawn.  return-deep-inside-a-large-function strikes again.

We might as well fix the other one while we're there:

From: Andrew Morton <akpm@...ux-foundation.org>

fix another such path - missed func_exit().

Cc: Dan Carpenter <error27@...il.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
---

 drivers/char/sx.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff -puN drivers/char/sx.c~sxc-fix-missed-unlock_kernel-on-error-path-in-sx_fw_ioctl-fix drivers/char/sx.c
--- a/drivers/char/sx.c~sxc-fix-missed-unlock_kernel-on-error-path-in-sx_fw_ioctl-fix
+++ a/drivers/char/sx.c
@@ -1713,8 +1713,8 @@ static long sx_fw_ioctl(struct file *fil
 		for (i = 0; i < SX_NBOARDS; i++)
 			sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags);
 		sx_dprintk(SX_DEBUG_FIRMWARE, "\n");
-		unlock_kernel();
-		return -EIO;
+		rc = -EIO;
+		goto out;
 	}
 
 	switch (cmd) {
@@ -1845,6 +1845,7 @@ static long sx_fw_ioctl(struct file *fil
 		rc = -ENOTTY;
 		break;
 	}
+out:
 	unlock_kernel();
 	func_exit();
 	return rc;
_

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ