lkml.org 
[lkml]   [2006]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH] adjust /dev/{kmem,mem,port} write handlers
    "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;
    }
    _
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-03-05 09:47    [W:0.029 / U:181.892 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site