lkml.org 
[lkml]   [2007]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 1/1] support for user-space buffers in kfifo
On 6/12/07, Stelian Pop <stelian@popies.net> wrote:
> Le lundi 11 juin 2007 à 16:26 -0500, Nelson Castillo a écrit :
> > Hi.
> >
> > I just added support for user space buffers in kfifo. I found useful
> > __kfifo_get_user to copy data to a user buffer in a read call. I didn't
> > like the idea of having an extra buffer.
> >
> > * Is it ok to add this support?
>
> I suppose it is, however:
>
> > + spin_lock_irqsave(fifo->lock, flags);
> > +
> > + ret = __kfifo_put_user(fifo, buffer, len);
> > +
> > + spin_unlock_irqrestore(fifo->lock, flags);
> [...]
>
> > +int __kfifo_put_user(struct kfifo *fifo, const unsigned char __user *buffer,
> > + unsigned int len)
> [...]
>
> > + if(copy_from_user(fifo->buffer + (fifo->in & (fifo->size - 1)),
> > + buffer, l))
> > + return -EFAULT;
> [...]
>
> accessing userspace memory with a spinlock taken (moreover an irqsave()
> one) is bad bad bad.

Yes.

Perhaps then only the functions __kfifo_put_user and __kfifo_get_user should
be allowed. Those are the ones I'm using now , anyway.
I added the others for completeness but adding them is probably a mistake.

Regards,
Nelson.-

--
http://arhuaco.org
http://emQbit.com
-
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: 2007-06-12 16:57    [W:0.071 / U:0.104 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site