From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751186AbdISKPR (ORCPT ); Tue, 19 Sep 2017 06:15:17 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:55522 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750747AbdISKPQ (ORCPT ); Tue, 19 Sep 2017 06:15:16 -0400 X-Google-Smtp-Source: AOwi7QAcQ7KNYeXsOnq98PYvmZUghxXj/W5TV6QfjvHLXINxicKoUeja/mm5KyVYojiW70qqXSf4gw== Date: Tue, 19 Sep 2017 19:15:11 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Sergey Senozhatsky , Andrew Morton , linux-kernel@vger.kernel.org, kernel-team , Sergey Senozhatsky Subject: Re: [PATCH] zram: fix null dereference of handle Message-ID: <20170919100941.GA401@jagdpanzerIV.localdomain> References: <1505788488-26723-1-git-send-email-minchan@kernel.org> <20170919053934.GC16991@jagdpanzerIV.localdomain> <20170919065924.GA29971@bbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170919065924.GA29971@bbox> User-Agent: Mutt/1.9.0 (2017-09-02) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Minchan, On (09/19/17 15:59), Minchan Kim wrote: [..] > > another question, "!handle == value & ZRAM_SAME"? if so, then why not > > just check for `flags & ZRAM_SAME'? if not then: > > > > - for `value & ZRAM_SAME' you fill the page with zram_get_element(zram, index) > > and return 0. ok. > > > > - for !handle.... you also fill the page with zram_get_element(zram, index) > > and return 0. is this ok? shouldn't !handle return error in this case? > > We discussed it before that we shouldn't return error. > Userspace can ask reading unallocated buffer freely. ok, so this is intentional behaviour. > And in this case, it fills the buffer zero because handle and element is unified. > However, if your concern is readability, I will make it more explict. correct. ... but I thought that we would also return an error. > > I really suspect that there are some paths that can lead to !handle > > entry, that will not be ZRAM_SAME. e.g. error return from compression > > path. > > Could you be more specific? I just meant that there are error paths in zram write, which will leave us both with !handle entries and !ZRAM_SAME. but it seems that this is the intentional behaviour. -ss