Re: [PATCH 1/2] zram: factor-out zram_decompress_page() function (v2)

From: Sergey Senozhatsky
Date: Mon Oct 29 2012 - 14:59:32 EST


On (10/29/12 11:32), Nitin Gupta wrote:
>
> Nothing should be printed (even a debug only message) for
> the ZRAM_ZERO case. This case can be quite common for certain
> kinds of data and would cause a huge log spew. Also (!handle) case
> is not the same as zero-filled page case, so this message would
> be misleading.
>
> So, we should either get rid of this warning entirely or only do
> pr_debug("Read before write ....") for (!handle) case and log nothing
> for ZRAM_ZERO case.
>

I'd rather remove this message. Will resend.



By the way, about use after-free. I'm afraid you fix is not covering 100% of the
cases.

The problem is with this case:
[..]
334
335 if (unlikely(clen > max_zpage_size)) {
336 zram_stat_inc(&zram->stats.bad_compress);
337 src = uncmem;
338 clen = PAGE_SIZE;
339 }
340
[..]

where uncmem could be:
-- kmap'ed page
-- kmalloc'ed page

both of which were unmap'ed/kfree'd before. you moved kfree to the end of the function,
while kunmap_atomic(user_mem) is still happening before src = uncmem/memcpy(cmem, src, clen)
pair.


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