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-next>] [day] [month] [year] [list]
Message-ID: <4A086D9E.60308@suse.com>
Date:	Mon, 11 May 2009 14:25:34 -0400
From:	Jeff Mahoney <jeffm@...e.com>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Cc:	Al Viro <viro@....linux.org.uk>
Subject: [PATCH] dup2: Fix return value with oldfd == newfd and invalid fd

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 The return value of dup2 when oldfd == newfd and the fd isn't valid is not
 getting properly sign extended. We end up with 4294967287 instead of -EBADF.

 I've reproduced this on SLE11 (2.6.27.21), openSUSE Factory (2.6.29-rc5),
 and Ubuntu 9.04 (2.6.28).

 This patch uses a signed int for the error value so it is properly extended.

 Commit 6c5d0512a091480c9f981162227fdb1c9d70e555 introduced this regression.

Reported-by: Jiri Dluhos <jdluhos@...ell.com>
Signed-off-by: Jeff Mahoney <jeffm@...e.com>
- ---
 fs/fcntl.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

- --- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -115,13 +115,14 @@ out_unlock:
 
 SYSCALL_DEFINE2(dup2, unsigned int, oldfd, unsigned int, newfd)
 {
+	int ret = oldfd;
 	if (unlikely(newfd == oldfd)) { /* corner case */
 		struct files_struct *files = current->files;
 		rcu_read_lock();
 		if (!fcheck_files(files, oldfd))
- -			oldfd = -EBADF;
+			ret = -EBADF;
 		rcu_read_unlock();
- -		return oldfd;
+		return ret;
 	}
 	return sys_dup3(oldfd, newfd, 0);
 }

- -- 
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iEYEARECAAYFAkoIbZcACgkQLPWxlyuTD7JBVACgnNFiWRb4lhW9JgqR36BnT6SD
4uQAoJDcfqV2jsjCV340HlQLkk585Yw6
=IBqW
-----END PGP SIGNATURE-----
--
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