From: inaky@linux.intel.com
To: "Paul Jackson" <pj@sgi.com>
Cc: "Joe Korty" <joe.korty@ccur.com>,
akpm@osdl.org, reinette.chatre@linux.intel.com,
linux-kernel@vger.kernel.org, inaky@linux.intel.com
Subject: Re: [PATCH] bitmap: bitmap_parse takes a kernel buffer instead of a user buffer
Date: Wed, 4 Oct 2006 08:52:03 -0700 (PDT) [thread overview]
Message-ID: <4082.10.24.212.168.1159977123.squirrel@linux.intel.com> (raw)
In-Reply-To: <20061004080637.0bd19042.pj@sgi.com>
> Joe wrote:
>> I guess I am a sucker for no-transient-buffer (bufferless?)
>
> Ah - that explains Joe's preference for putting the actual implementing
> code in the user version - it gets to pull in the user string one
> char at a time, avoiding a malloc'd buffer.
I tend to gree w/ Joe there.
I wonder if a hybrid would be ok, although I the pseudo impl
I propose below is kind of dirty, but some people might find it
justified enough:
static
__bitmap_parse(const void *_buf, size_t size, enum { KERNEL, USER } type,
unsigned long *dst, int nbits)
{
const char __user *ubuf = _buf;
const char *buf = _buf;
...
switch(type) {
case USER:
if (get_user(c, ubuf++))
return -EFAULT;
break;
case KERNEL:
c = *buf++;
break;
default:
BUG();
...
}
int bitmap_parse(const char *buf, unsigned int buflen,
unsigned long *maskp, int nmaskbits) {
return __bitmap_parse(buf, buflen, KERNEL, maskp, nmaskbits);
}
int bitmap_parse_user(const char __user *buf, unsigned int buflen,
unsigned long *maskp, int nmaskbits) {
return __bitmap_parse(buf, buflen, USER, maskp, nmaskbits);
}
[that or exposing __bitmap_user() as a extern / EXPORT and putting
bitmap_parse{,_user}() as an inline in the header file]
It's nitty-gritty, but it removes the kmalloc from the equation...
--
Inaky
next prev parent reply other threads:[~2006-10-04 15:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-03 15:16 [PATCH] bitmap: bitmap_parse takes a kernel buffer instead of a user buffer Reinette Chatre
2006-10-03 15:20 ` inaky
2006-10-03 23:39 ` Andrew Morton
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 [this message]
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=4082.10.24.212.168.1159977123.squirrel@linux.intel.com \
--to=inaky@linux.intel.com \
--cc=akpm@osdl.org \
--cc=joe.korty@ccur.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