lkml.org 
[lkml]   [1999]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectUnchecked kmalloc return in fs/isofs/namei.c
Hello world...

The subject says it all. I was grokking through the isofs stuff and saw
a "naked" kmalloc() in isofs_find_entry(). I don't think it's too
dangerous, since I couldn't cross that particular path in testing with a
number of CDs.

Also, its 'priority' is GFP_KERNEL, which indicates it may block to get
memory. (Is that correct?) Which begs the question... How likely is a
GFP_KERNEL
kmalloc to fail?

As you might guess I'm a kernel newbie. Below, I've attached a patch
which handles a failed allocation in a manner consistent with the rest
of isofs_find_entry() -> break out of the loop and return below... The
patch is against 2.3.5 (I've been trying to keep up with the
Joneses...), but I believe the problem is in 2.2.x as well.

Anyhow, like I said, I don't think its terribly dangerous. And I
couldn't hit that code to test it. I think the fix is right.

BTW, feel free to ignore the first part of the patch ;) It's just a
reflection of certain anal tendencies that fortunately only manifest
themselves when I program.

I didn't see anyone in the MAINTAINERS list, but I did CC
james@bpgc.com, since his address appeared in a comment mentioning the
kmalloc.

I've also been playing in isofs/dir.c. I saw the "should _really_ be
cleaned up" comment above do_isofs_readdir() and though what a good way
to start playing with the kernel. I'll probably have something
presentable
this week, if I don't get distracted. Nothing too stunning for the linux
gods that dwell here, but we gotta start somewhere.

Please CC me if you have any response. I subscribe to
linux-kernel-digest, but would appreciate a direct email response as
well. Thanks.

Sam Hunter <shunter@bigsky.net>


Index: linux/fs/isofs/namei.c
===================================================================
RCS file: /usr/local/src/cvsroot/linux/fs/isofs/namei.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- linux/fs/isofs/namei.c 1999/06/03 02:06:34 1.1.1.1
+++ linux/fs/isofs/namei.c 1999/06/05 07:06:33 1.2
@@ -20,7 +20,7 @@

/*
* ok, we cannot use strncmp, as the name is not in our data space.
- * Thus we'll have to use isofs_match. No big problem. Match also makes
+ * Thus we'll have to use isofs_cmp. No big problem. Isofs_cmp also
makes
* some sanity tests.
*/
static int
@@ -147,6 +147,8 @@

de = (struct iso_directory_record *)
kmalloc(offset - old_offset, GFP_KERNEL);
+ if(!de) break;
+
memcpy((char *)de, bh->b_data + old_offset,
bufsize - old_offset);
memcpy((char *)de + bufsize - old_offset,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.351 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site