Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1206287

Re: Unmapping of UIO logical memory causing a trace

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject Re: Unmapping of UIO logical memory causing a trace
Date 2015-08-12 19:20 +0200
Message-ID <pWHR0-2rD-13@gated-at.bofh.it> (permalink)
References <pWfL4-3t4-5@gated-at.bofh.it> <pWpAK-No-15@gated-at.bofh.it> <pWz73-6vp-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Aug 12, 2015 at 01:25:53PM +0530, Ankit Jindal wrote:
> Hi Greg,
> 
> On Wed, Aug 12, 2015 at 3:15 AM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > On Tue, Aug 11, 2015 at 04:39:08PM +0530, Ankit Jindal wrote:
> >> Hi,
> >>
> >> We have observed an issue where kmalloc of a small sized memory causes
> >> an occasional trace when unmapping the mmaped memory via UIO framework
> >> This trace is coming when kernel sees a negative value in
> >> page->_mapcount. Trace is pasted at the end of the mail.
> >>
> >> After debugging this issue further, we realized following sequence
> >> occurs when kmalloc is used to allocate small memory using slub
> >> allocator:
> >> 1. Frozen bit (msb) of the page from which memory has been allocated
> >> is set (which is an union with _mapcount).
> >> 2. If there are free objects in the the same page then this frozen bit
> >> remains set even after kernel boots completely.
> >> 3. When user space calls unmap of this memory, vma_unmap_single()
> >> treats the _mapcount as a negative (as frozen bit is set), causing a
> >> trace.
> >>
> >> We are not sure whether exposing kernel memory of size
> >> less than PAGE_SIZE via UIO is a valid use case ? In case this is an invalid
> >> use case then shouldn't the UIO framework restrict mapping of non
> >> PAGE_SIZE aligned memory and size not in order of PAGE_SIZE.
> >
> > We've had a few discussions about this in the past, and one proposed
> > patch which had to be reverted because it broke some working systems, so
> > it's a messy thing.
> >
> > What UIO driver are you using that causes this behavior?
> 
> We have observed this during the development of new UIO driver for our
> soc. In our driver, we need to parse non probable properties of device
> and provide these details to our user application.

What exactly do you mean by this?

> For this we do a kmalloc of device info(approx size 80 bytes) and pass
> this address to user space via UIO mem logical.

For such tiny sizes, why not just use a normal sysfs file?

Do you have a pointer to your driver so that I can see exactly what it
is doing here?

thanks,

greg k-h
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Unmapping of UIO logical memory causing a trace Ankit Jindal <ajindal@apm.com> - 2015-08-11 13:20 +0200
  Re: Unmapping of UIO logical memory causing a trace Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-11 23:50 +0200
    Re: Unmapping of UIO logical memory causing a trace Ankit Jindal <ajindal@apm.com> - 2015-08-12 10:00 +0200
      Re: Unmapping of UIO logical memory causing a trace Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-12 19:20 +0200
        Re: Unmapping of UIO logical memory causing a trace Ankit Jindal <ajindal@apm.com> - 2015-08-19 12:00 +0200
          Re: Unmapping of UIO logical memory causing a trace Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-19 16:10 +0200

csiph-web