[PATCH] smbfs chroot issue (CVE-2006-1864)

Linux Kernel Mailing List <[email protected]> Fri, 12 May 2006 18:59:17 GMT
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
commit aaf1e07ac554b9674bf22394911ec8dd3a927826
tree 64c9154b6ddacafe9b10893558ef01758198ddb4
parent 0b070a5b47b7378768d0f14fb49c5ebf2ba1d07e
author Olaf Kirch <[email protected]> Fri, 05 May 2006 08:40:41 -0700
committer Willy TARREAU <willy@pcw.(none)> Sun, 07 May 2006 21:11:33 +0200

[PATCH] smbfs chroot issue (CVE-2006-1864)

Mark Moseley reported that a chroot environment on a SMB share can be
left via "cd ..\\".  Similar to CVE-2006-1863 issue with cifs, this fix
is for smbfs.

Steven French <[email protected]> wrote:

Looks fine to me.  This should catch the slash on lookup or equivalent,
which will be all obvious paths of interest.

Back-ported to 2.4 by Willy Tarreau.
Signed-off-by: Willy Tarreau <[email protected]>

 fs/smbfs/dir.c |    5 +++++
 1 files changed, 5 insertions(+)

diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c
index 7c0a0de..9ace0a4 100644
--- a/fs/smbfs/dir.c
+++ b/fs/smbfs/dir.c
@@ -416,6 +416,11 @@ smb_lookup(struct inode *dir, struct den
 	if (dentry->d_name.len > SMB_MAXNAMELEN)
 		goto out;
 
+	/* Do not allow lookup of names with backslashes in */
+	error = -EINVAL;
+	if (memchr(dentry->d_name.name, '\\', dentry->d_name.len))
+		goto out;
+
 	error = smb_proc_getattr(dentry, &finfo);
 #ifdef SMBFS_PARANOIA
 	if (error && error != -ENOENT)