mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Reinette Chatre <reinette.chatre@linux.intel.com>
Cc: linux-kernel@vger.kernel.org,
	Inaky Perez-Gonzalez <inaky@linux.intel.com>,
	Paul Jackson <pj@sgi.com>
Subject: Re: [PATCH] bitmap: bitmap_parse takes a kernel buffer instead of a user buffer
Date: Tue, 3 Oct 2006 16:39:36 -0700	[thread overview]
Message-ID: <20061003163936.d8e26629.akpm@osdl.org> (raw)
In-Reply-To: <200610030816.27941.reinette.chatre@linux.intel.com>

On Tue, 3 Oct 2006 08:16:27 -0700
Reinette Chatre <reinette.chatre@linux.intel.com> wrote:

> lib/bitmap.c:bitmap_parse() is a library function that received as input a  user buffer. This seemed to have originated from the way the write_proc function of the /proc filesystem operates.
> 
> This function will be useful for other uses as well; for example, taking input  for /sysfs instead of /proc, so it was changed to accept kernel buffers. We have this use for the Linux UWB project, as part as the upcoming bandwidth allocator code.
> 
> Only a few routines used this function and they were changed too.

Fair enough.  But this:

>  
> -	err = cpumask_parse(buffer, count, new_value);
> +	kbuf = kmalloc(count, GFP_KERNEL);
> +	if (kbuf == NULL)
> +		return -ENOMEM;
> +	ret = copy_from_user(kbuf, buffer, count);
> +	if (ret != 0) {
> +		kfree(kbuf);
> +		return -EFAULT;
> +	}
> +	err = cpumask_parse(kbuf, count, new_value);
> +	kfree(kbuf);
>  	if (err)
>  		return err;
>
> ...
>
> -	err = cpumask_parse(buffer, count, new_value);
> +	kbuf = kmalloc(count, GFP_KERNEL);
> +	if (kbuf == NULL)
> +		return -ENOMEM;
> +	ret = copy_from_user(kbuf, buffer, count);
> +	if (ret != 0) {
> +		kfree(kbuf);
> +		return -EFAULT;
> +	}
> +	err = cpumask_parse(kbuf, count, new_value);
> +	kfree(kbuf);
>  	if (err)
>  		return err;
>  

is sending us a message ;)

How about adding a new bitmap_parse_user() (and cpumask_parse_user()) which
does the above?

  parent reply	other threads:[~2006-10-03 23:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-03 15:16 Reinette Chatre
2006-10-03 15:20 ` inaky
2006-10-03 23:39 ` Andrew Morton [this message]
2006-10-04  2:03   ` Paul Jackson
2006-10-04 14:14   ` Joe Korty
2006-10-04 14:27     ` Paul Jackson
2006-10-04 14:55       ` Joe Korty
2006-10-04 15:06         ` Paul Jackson
2006-10-04 15:52           ` inaky
2006-10-04 16:40     ` Andrew Morton
2006-10-04 17:14       ` Joe Korty
2006-10-04 17:57         ` Inaky Perez-Gonzalez

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=20061003163936.d8e26629.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=inaky@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pj@sgi.com \
    --cc=reinette.chatre@linux.intel.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

all inboxes | Powered by JetHome®