public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org, torvalds@osdl.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Dave Jones <davej@redhat.com>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	Chris Wedgwood <reviews@ml.cw.f00f.org>,
	akpm@osdl.org, alan@lxorguk.ukuu.org.uk,
	Diego Calleja <diegocg@gmail.com>, Jens Kilian <jjk@acm.org>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [patch 06/20] Fix BeFS slab corruption
Date: Mon, 21 Aug 2006 11:46:25 -0700	[thread overview]
Message-ID: <20060821184625.GG21938@kroah.com> (raw)
In-Reply-To: <20060821184527.GA21938@kroah.com>

[-- Attachment #1: fix-befs-slab-corruption.patch --]
[-- Type: text/plain, Size: 2207 bytes --]

-stable review patch.  If anyone has any objections, please let us know.

------------------
From: Diego Calleja <diegocg@gmail.com>

In bugzilla #6941, Jens Kilian reported:

"The function befs_utf2nls (in fs/befs/linuxvfs.c) writes a 0 byte past the
end of a block of memory allocated via kmalloc(), leading to memory
corruption.  This happens only for filenames which are pure ASCII and a
multiple of 4 bytes in length.  [...]

Without DEBUG_SLAB, this leads to further corruption and hard lockups; I
believe this is the bug which has made kernels later than 2.6.8 unusable
for me.  (This must be due to changes in memory management, the bug has
been in the BeFS driver since the time it was introduced (AFAICT).)

Steps to reproduce:
Create a directory (in BeOS, naturally :-) with files named, e.g.,
"1", "22", "333", "4444", ...  Mount it in Linux and do an "ls" or "find""

This patch implements the suggested fix. Credits to Jens Kilian for
debugging the problem and finding the right fix.

Signed-off-by: Diego Calleja <diegocg@gmail.com>
Cc: Jens Kilian <jjk@acm.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 fs/befs/linuxvfs.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

--- linux-2.6.17.8.orig/fs/befs/linuxvfs.c
+++ linux-2.6.17.8/fs/befs/linuxvfs.c
@@ -512,7 +512,11 @@ befs_utf2nls(struct super_block *sb, con
 	wchar_t uni;
 	int unilen, utflen;
 	char *result;
-	int maxlen = in_len; /* The utf8->nls conversion can't make more chars */
+	/* The utf8->nls conversion won't make the final nls string bigger
+	 * than the utf one, but if the string is pure ascii they'll have the
+	 * same width and an extra char is needed to save the additional \0
+	 */
+	int maxlen = in_len + 1;
 
 	befs_debug(sb, "---> utf2nls()");
 
@@ -588,7 +592,10 @@ befs_nls2utf(struct super_block *sb, con
 	wchar_t uni;
 	int unilen, utflen;
 	char *result;
-	int maxlen = 3 * in_len;
+	/* There're nls characters that will translate to 3-chars-wide UTF-8
+	 * characters, a additional byte is needed to save the final \0
+	 * in special cases */
+	int maxlen = (3 * in_len) + 1;
 
 	befs_debug(sb, "---> nls2utf()\n");
 

--

  parent reply	other threads:[~2006-08-21 18:48 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060821183818.155091391@quad.kroah.org>
2006-08-21 18:45 ` [patch 00/20] 2.6.17-stable review Greg KH
2006-08-21 18:45   ` [patch 01/20] Have ext3 reject file handles with bad inode numbers early Greg KH
2006-08-21 18:45   ` [patch 02/20] sky2: phy power problem on 88e805x Greg KH
2006-08-21 18:46   ` [patch 03/20] Kill HASH_HIGHMEM from route cache hash sizing Greg KH
2006-08-21 18:46   ` [patch 04/20] Fix timer race in dst GC code Greg KH
2006-08-21 18:46   ` [patch 05/20] Fix IFLA_ADDRESS handling Greg KH
2006-08-21 18:46   ` Greg KH [this message]
2006-08-21 18:46   ` [patch 07/20] disable debugging version of write_lock() Greg KH
2006-08-21 18:46   ` [patch 08/20] ipx: header length validation needed Greg KH
2006-08-21 18:46   ` [patch 09/20] tpm: interrupt clear fix Greg KH
2006-08-21 18:46   ` [patch 10/20] : ulog: fix panic on SMP kernels Greg KH
2006-08-21 18:47   ` [patch 11/20] sys_getppid oopses on debug kernel Greg KH
2006-08-21 18:47   ` [patch 12/20] SERIAL: icom: select FW_LOADER Greg KH
2006-08-21 18:47   ` [patch 13/20] PCI: fix ICH6 quirks Greg KH
2006-08-21 18:47   ` [patch 14/20] : ip_tables: fix table locking in ipt_do_table Greg KH
2006-08-21 18:47   ` [patch 15/20] IA64: local DoS with corrupted ELFs Greg KH
2006-08-21 18:47   ` [patch 16/20] Fix ipv4 routing locking bug Greg KH
2006-08-21 18:47   ` Greg KH
2006-08-21 18:48   ` [patch 17/20] dm: BUG/OOPS fix Greg KH
2006-08-21 18:48   ` [patch 18/20] swsusp: Fix swap_type_of Greg KH
2006-08-21 18:48   ` [patch 19/20] MD: Fix a potential NULL dereference in md/raid1 Greg KH
2006-08-21 18:48   ` [patch 20/20] 1394: fix for recently added firewire patch that breaks things on ppc Greg KH
2006-08-22  9:03     ` Stefan Richter
2006-08-21 19:46   ` [patch 00/20] 2.6.17-stable review Dave Jones
2006-08-21 21:43     ` Greg KH
2006-08-22 13:49       ` John Stoffel
2006-08-22 13:59         ` Kyle Moffett
2006-08-22 14:53           ` John Stoffel
2006-08-22 19:13   ` Herbert Xu's paged unique skb trimming patch? Nix
2006-08-22 19:17     ` Greg KH
2006-08-22 20:41       ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060821184625.GG21938@kroah.com \
    --to=gregkh@suse.de \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=diegocg@gmail.com \
    --cc=jjk@acm.org \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    --cc=reviews@ml.cw.f00f.org \
    --cc=stable@kernel.org \
    --cc=torvalds@osdl.org \
    --cc=tytso@mit.edu \
    --cc=zwane@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox