From: Andrew Morton <akpm@osdl.org>
To: "Jan Beulich" <JBeulich@novell.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] adjust /dev/{kmem,mem,port} write handlers
Date: Sat, 4 Mar 2006 22:15:50 -0800 [thread overview]
Message-ID: <20060304221550.6892c7ba.akpm@osdl.org> (raw)
In-Reply-To: <44081B03.76F0.0078.0@novell.com>
"Jan Beulich" <JBeulich@novell.com> wrote:
>
> The /dev/mem and /dev/kmem write handlers weren't fully POSIX compliant in
> that they wouldn't always force the file pointer to be updated when returning
> success status.
> The /dev/port write handler was inconsistent with the /dev/mem and /dev/kmem
> handlers in that when encountering a -EFAULT condition after already having
> written a number of items it would return -EFAULT rather than the number of
> bytes written.
>
> ...
>
> @@ -514,11 +510,10 @@ static ssize_t write_kmem(struct file *
> if (len) {
> written = copy_from_user(kbuf, buf, len);
> if (written) {
> - ssize_t ret;
> -
> + if (wrote + virtr)
> + break;
> free_page((unsigned long)kbuf);
> - ret = wrote + virtr + (len - written);
> - return ret ? ret : -EFAULT;
> + return -EFAULT;
> }
> }
> len = vwrite(kbuf, (char *)p, len);
I think write_kmem() still isn't quie right - it needs to update `p' (and
hence *ppos) to account for a partial copy_from_user(). (Please double-check)
--- devel/drivers/char/mem.c~adjust-dev-kmemmemport-write-handlers-fix 2006-03-04 22:10:55.000000000 -0800
+++ devel-akpm/drivers/char/mem.c 2006-03-04 22:15:19.000000000 -0800
@@ -504,8 +504,11 @@ static ssize_t write_kmem(struct file *
if (len) {
written = copy_from_user(kbuf, buf, len);
if (written) {
- if (wrote + virtr)
+ if (wrote + virtr) {
+ p += len - written;
+ virtr += len - written;
break;
+ }
free_page((unsigned long)kbuf);
return -EFAULT;
}
_
next prev parent reply other threads:[~2006-03-05 6:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-03 9:31 [PATCH] adjust /dev/{kmem,mem,port} write handlers Jan Beulich
2006-03-03 9:38 ` Arjan van de Ven
2006-03-03 12:48 ` Robin Holt
2006-03-03 13:45 ` Andi Kleen
2006-03-06 0:11 ` Anton Blanchard
2006-03-05 6:15 ` Andrew Morton [this message]
2006-03-06 8:08 ` Jan Beulich
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=20060304221550.6892c7ba.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=JBeulich@novell.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 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.