Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1624966
| From | Minchan Kim <minchan@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") |
| Date | 2017-04-18 02:10 +0200 |
| Message-ID | <txoSt-7uv-1@gated-at.bofh.it> (permalink) |
| References | <tx3XH-2FQ-9@gated-at.bofh.it> <txgLg-2iD-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Apr 17, 2017 at 10:20:42AM -0500, Christoph Lameter wrote: > On Mon, 17 Apr 2017, Sergey Senozhatsky wrote: > > > Minchan reported that doing copy_page() on a kmalloc(PAGE_SIZE) page > > with DEBUG_SLAB enabled can cause a memory corruption (See below or > > lkml.kernel.org/r/1492042622-12074-2-git-send-email-minchan@kernel.org ) > > Yes the alignment guarantees do not require alignment on a page boundary. > > The alignment for kmalloc allocations is controlled by KMALLOC_MIN_ALIGN. > Usually this is either double word aligned or cache line aligned. > > > that's an interesting problem. arm64 copy_page(), for instance, wants src > > and dst to be page aligned, which is reasonable, while generic copy_page(), > > on the contrary, simply does memcpy(). there are, probably, other callpaths > > that do copy_page() on kmalloc-ed pages and I'm wondering if there is some > > sort of a generic fix to the problem. > > Simple solution is to not allocate pages via the slab allocator but use > the page allocator for this. The page allocator provides proper alignment. > > There is a reason it is called the page allocator because if you want a > page you use the proper allocator for it. It would be better if the APIs works with struct page, not address but I can imagine there are many cases where don't have struct page itself and redundant for kmap/kunmap. Another approach is the API does normal thing for non-aligned prefix and tail space and fast thing for aligned space. Otherwise, it would be happy if the API has WARN_ON non-page SIZE aligned address.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-04-17 03:50 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Christoph Lameter <cl@linux.com> - 2017-04-17 17:30 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Minchan Kim <minchan@kernel.org> - 2017-04-18 02:10 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Michal Hocko <mhocko@kernel.org> - 2017-04-18 09:40 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Michal Hocko <mhocko@kernel.org> - 2017-04-18 13:10 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-04-19 08:20 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-04-18 13:10 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Minchan Kim <minchan@kernel.org> - 2017-04-19 08:10 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Matthew Wilcox <willy@infradead.org> - 2017-04-19 14:00 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-04-20 03:50 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Minchan Kim <minchan@kernel.org> - 2017-04-20 09:00 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-04-18 12:50 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Christoph Lameter <cl@linux.com> - 2017-04-18 15:30 +0200
Re: copy_page() on a kmalloc-ed page with DEBUG_SLAB enabled (was "zram: do not use copy_page with non-page alinged address") Matthew Wilcox <willy@infradead.org> - 2017-04-18 15:20 +0200
csiph-web