From: "Arvin Moezzi" <moezzia@gmail.com>
To: "James Pearson" <james-p@moving-picture.com>,
linux-kernel@vger.kernel.org
Cc: aarapov@redhat.com, akpm@linux-foundation.org, hpa@zytor.com
Subject: Re: [PATCH -mm] Don't truncate /proc/PID/environ at 4096 characters
Date: Fri, 21 Sep 2007 14:47:04 +0200 [thread overview]
Message-ID: <3402120c0709210547mb66162fv759a8f088beb0437@mail.gmail.com> (raw)
In-Reply-To: <46F39319.9090705@moving-picture.com>
> >>+
> >>+ if (copy_to_user(buf, page, retval)) {
> >
> > ^^^^
> > shouldn't you only copy min(count,retval) bytes? otherwise you could
> > write beyond the users buffer "buf", right?
>
> AFAIK, 'retval' can never be greater than 'this_len', which can never be
> greater than 'max_len', which can never be greater than 'count'
I think that's not true. 'count' is changing through the iteration.
The difference in the mem_read():
* while (count > 0) {
* int this_len, retval;
*
* this_len = (count > PAGE_SIZE) ? PAGE_SIZE : count;
* retval = access_process_vm(task, src, page, this_len, 0);
*
* ...
* }
is the fact, that this_len = min(PAGE_SIZE, count) is in the
iteration block, hence retval <= this_len <= count in each iteration
step. So this is ok. But IMHO in your code 'retval' may be bigger than
'count' in the last iteration of the block, because 'max_len' is fix
through your iteration but 'count' is changing. Or am i missing
something?
> James Pearson
Arvin
next prev parent reply other threads:[~2007-09-21 12:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-19 13:35 James Pearson
2007-09-20 23:46 ` Andrew Morton
2007-09-21 9:41 ` James Pearson
2007-09-21 10:00 ` Mel Gorman
2007-09-21 1:56 ` Arvin Moezzi
2007-09-21 9:47 ` James Pearson
2007-09-21 12:47 ` Arvin Moezzi [this message]
2007-09-21 13:47 ` James Pearson
2007-09-19 14:54 Mikael Pettersson
2007-09-19 15:59 ` H. Peter Anvin
2007-09-19 18:35 ` Mikael Pettersson
2007-09-19 19:29 ` Hugh Dickins
2007-09-25 16:44 James Pearson
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=3402120c0709210547mb66162fv759a8f088beb0437@mail.gmail.com \
--to=moezzia@gmail.com \
--cc=aarapov@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=james-p@moving-picture.com \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®