lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 19 Nov 2014 08:21:39 +0900
From:	Minchan Kim <minchan@...nel.org>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Seth Jennings <sjennings@...iantweb.net>,
	linux-kernel@...r.kernel.org, linux-mm@...ck.org,
	Nitin Gupta <ngupta@...are.org>,
	Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
	Dan Streetman <ddstreet@...e.org>,
	Jerome Marchand <jmarchan@...hat.com>
Subject: Re: [PATCH] zsmalloc: correct fragile [kmap|kunmap]_atomic use

Hello Andrew,

On Tue, Nov 18, 2014 at 03:01:38PM -0800, Andrew Morton wrote:
> On Fri, 14 Nov 2014 09:07:32 -0600 Seth Jennings <sjennings@...iantweb.net> wrote:
> 
> > On Fri, Nov 14, 2014 at 10:11:01AM +0900, Minchan Kim wrote:
> > > The kunmap_atomic should use virtual address getting by kmap_atomic.
> > > However, some pieces of code in zsmalloc uses modified address,
> > > not the one got by kmap_atomic for kunmap_atomic.
> > > 
> > > It's okay for working because zsmalloc modifies the address
> > > inner PAGE_SIZE bounday so it works with current kmap_atomic's
> > > implementation. But it's still fragile with potential changing
> > > of kmap_atomic so let's correct it.
> 
> It is a bit alarming, but I've seen code elsewhere in which a modified
> pointer is passed to kunmap_atomic().  So the kunmap_atomic() interface
> is "kvaddr should point somewhere into the page" and that won't be
> changing without a big effort.
> 
> > Seems like you could just use PAGE_MASK to get the base page address
> > from link like this:
> 
> I think Minchan's approach is better: it explicitly retains the
> kmap_atomic() return value for passing to kunmap_atomic().  That's
> nicer than modifying it and then setting it back again.
> 
> I mean, a cleaner way of implementing your suggestion would be
> 
> void kunmap_atomic_unaligned(void *p)
> {
> 	kunmap_atomic(void *)((unsigned long)p & PAGE_MASK);
> }
> 
> but then one looks at
> 
> void __kunmap_atomic(void *kvaddr)
> {
> 	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
> 
> and asks "what the heck".
> 
> 
> So I dunno.  We could leave the code as-is.  I have no strong feelings
> either way.  Minchan's patch has no effect on zsmalloc.o section sizes
> with my compiler.

I hope to merge my patch.

Main reason I sent the patch is I got a subtle bug when I implement
new feature of zsmalloc(ie, compaction) due to link's mishandling
(ie, link was over page boundary by my fault).
Although it was totally my mistake, it took time for a while
to find a root cause because unpredictable kmapped address should
be unmapped so it's almost random crash.

IOW, it's fragile to depend on kunmap_atomic's internal and at least,
I wanted to make zram code more robust.

Thanks.

> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@...ck.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@...ck.org"> email@...ck.org </a>

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ