From: Akinobu Mita <mita@miraclelinux.com>
To: marcelo.tosatti@cyclades.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2.4][RESEND] Bug in reading some files in /proc/<pid>/
Date: Wed, 7 Jan 2004 14:10:22 +0900 [thread overview]
Message-ID: <200401071410.22490.mita@miraclelinux.com> (raw)
Hi Marcelo,
I found the bug in 2.4. this problem has already been fixed in 2.6.
The following program could not detect Bad address
with /proc/<pid>/cmdline, stat, statm, ...
-----
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
int main(int argc, char **argv)
{
int fd, ret;
fd = open(argv[1], O_RDONLY);
ret = read(fd, NULL, 4*1024); // Bad address
printf("%s: %d\n", strerror(errno), ret);
}
-----
For example.
$ ./a.out a.out
Bad Address: -1
This result could be expected.
but..
$ ./a.out /proc/1/stat
Success: 214
--- linux-2.4.x/fs/proc/base.c.orig 2003-12-26 11:34:19.000000000 +0900
+++ linux-2.4.x/fs/proc/base.c 2004-01-07 13:32:12.000000000 +0900
@@ -357,8 +357,10 @@ static ssize_t proc_info_read(struct fil
if (count + *ppos > length)
count = length - *ppos;
end = count + *ppos;
- copy_to_user(buf, (char *) page + *ppos, count);
- *ppos = end;
+ if (copy_to_user(buf, (char *) page + *ppos, count))
+ count = -EFAULT;
+ else
+ *ppos = end;
free_page(page);
return count;
}
reply other threads:[~2004-01-07 5:15 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=200401071410.22490.mita@miraclelinux.com \
--to=mita@miraclelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.tosatti@cyclades.com \
/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
Powered by JetHome