From: Martin Gadbois <martin.gadbois@colubris.com>
To: linux-fsdevel@vger.kernel.org
Subject: [PATCH] fix in fs/proc/generic.c: comparing unsigned int
Date: Fri, 22 Oct 2004 14:45:41 -0400 [thread overview]
Message-ID: <41795555.5020308@colubris.com> (raw)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
In function proc_file_read(), if variable nbytes becomes "negative" it lead to a possibe overrun and
segfault.
It can become negative if the function dp->read_proc() returns n > nbytes.
When nbyte is negative, the while comparaison is unsigned (size_t nbytes), and the check is always TRUE.
This patch corrects the problem by using a int variable.
diff -ur linux-2.4.28-pre4/fs/proc/generic.c linux-2.4.28-pre4-fix/fs/proc/generic.c
- --- linux-2.4.28-pre4/fs/proc/generic.c 2004-10-22 11:40:42.000000000 -0400
+++ linux-2.4.28-pre4-fix/fs/proc/generic.c 2004-10-22 11:33:19.000000000 -0400
@@ -57,14 +57,15 @@
~ char *start;
~ struct proc_dir_entry * dp;
~ loff_t pos = *ppos;
+ int bytes_left = nbytes;
~ dp = (struct proc_dir_entry *) inode->u.generic_ip;
~ if (!(page = (char*) __get_free_page(GFP_KERNEL)))
~ return -ENOMEM;
- - while ((nbytes > 0) && !eof)
+ while ((bytes_left > 0) && !eof)
~ {
- - count = MIN(PROC_BLOCK_SIZE, nbytes);
+ count = MIN(PROC_BLOCK_SIZE, bytes_left);
~ if ((unsigned)pos > INT_MAX)
~ break;
@@ -115,7 +116,7 @@
~ }
~ pos += start < page ? (long)start : n; /* Move down the file */
- - nbytes -= n;
+ bytes_left -= n;
~ buf += n;
~ retval += n;
~ }
- --
============== +----------------------------------------------+
Martin Gadbois | "Politics may come and go, but Greed goes on |
S/W Developper | forever" --Qeng Ho motto, Fire upon the Deep |
Colubris Networks Inc. +----------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFBeVVV9Y3/iTTCEDkRAgjaAJ4tH4U7g/kP23DI96i8/h9jUcM/EgCfa56F
S8oRN77DrSNBMjr2b++HkO4=
=szpU
-----END PGP SIGNATURE-----
reply other threads:[~2004-10-22 18:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=41795555.5020308@colubris.com \
--to=martin.gadbois@colubris.com \
--cc=linux-fsdevel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).