All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Pearson <james-p@moving-picture.com>
To: Arvin Moezzi <moezzia@gmail.com>
Cc: linux-kernel@vger.kernel.org, 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 10:47:05 +0100	[thread overview]
Message-ID: <46F39319.9090705@moving-picture.com> (raw)
In-Reply-To: <3402120c0709201856j58c3775bq8dc7886785a11344@mail.gmail.com>

Arvin Moezzi wrote:
> 2007/9/19, James Pearson <james-p@moving-picture.com>:
> 
>>+       while (count > 0) {
>>+               int this_len, retval;
>>+
>>+               this_len = mm->env_end - (mm->env_start + src);
>>+
>>+               if (this_len <= 0)
>>+                       break;
>>+
>>+               if (this_len > max_len)
>>+                       this_len = max_len;
>>+
>>+               retval = access_process_vm(task, (mm->env_start + src),
>>+                       page, this_len, 0);
>>+
>>+               if (retval <= 0) {
>>+                       ret = retval;
>>+                       break;
>>+               }
>>+
>>+               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'

James Pearson

  reply	other threads:[~2007-09-21  9:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-19 13:35 [PATCH -mm] Don't truncate /proc/PID/environ at 4096 characters 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 [this message]
2007-09-21 12:47     ` Arvin Moezzi
2007-09-21 13:47       ` James Pearson
  -- strict thread matches above, loose matches on Subject: below --
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=46F39319.9090705@moving-picture.com \
    --to=james-p@moving-picture.com \
    --cc=aarapov@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=moezzia@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.