Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3575689ybi; Tue, 2 Jul 2019 09:57:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyz9HwtQo/GtSOGUwyM7c96xI9VwXEh/3P4GIsX3/wfEm60AeSSXbWgES1q38wx8BkaHG3q X-Received: by 2002:a63:4c14:: with SMTP id z20mr31420755pga.360.1562086672167; Tue, 02 Jul 2019 09:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562086672; cv=none; d=google.com; s=arc-20160816; b=cY32CSR44vdh8BN76nCG9XGcxuZbZ3RvPSYeFkV8HSjZQWPv8qh2gzMURwn7fFWjTF Ir0JJ+XhYiwcX3jT4winLmmWpYK49dR/qwJXh7Ld6sjGMt40cN+kWEAqsagxc81DOcS/ /5u/2cDkisOnlodeEjZFSOJywSs2XqzrxePRmtnzqvMmMhlXkN7xvjSwkFcb57rKjTaY HObS/sJkSdTAdUPgauZ+cOcDii/5x6dTIANwP8MLLOU9I7Dl4pP70TbB//R3Wzl78sFN uxinHLMZMd3NQo4DBq+vdWJVZClbZgzmOoJ4sniBnAVu7/EsDOdBPTY3eFuwI6Juh0qo O0lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=d3ruOHdYru6Rpy+BKpMXi/6c+V83W2zZQqeLjuI07mA=; b=B1wM1UFMtcq+ETd//BGB0olimvOQHxOaVYF1bsvW9TiWEMzORuPV5j12QxVIPO1ij5 H+Ru36YKgrhYnXIKEK4zrXYgx4HZtyOZWFeMBLLFAAgjAEC2zYz2c4saEQc9v0mA1GD+ dQA3dBq/gNZhohqF1PP5w1mkm7xniIMERmnVFbkPo1xMXsNdEwWdGxEX80vCrxBll6gY +QPkchawHfM/zPrXKpCMxs+OWPy/Lg69nZ/VAE5ztaZC8W6yADd1RxKWpQb/zlT2OpjV luXZfiv0sC/+TSsRbi20/Uu+pCIL5yeOi1sIB3QG6T5tfPkz6EEzJr7AHTHeV/0k6ZZv gdpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ErLvOg6E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 12si13671744pfi.213.2019.07.02.09.57.36; Tue, 02 Jul 2019 09:57:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ErLvOg6E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbfGBQ5L (ORCPT + 99 others); Tue, 2 Jul 2019 12:57:11 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:39983 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbfGBQ5L (ORCPT ); Tue, 2 Jul 2019 12:57:11 -0400 Received: by mail-io1-f68.google.com with SMTP id n5so38621713ioc.7 for ; Tue, 02 Jul 2019 09:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d3ruOHdYru6Rpy+BKpMXi/6c+V83W2zZQqeLjuI07mA=; b=ErLvOg6Ev6zdphtHAlsPI/i4E1PAFFXuaLmpX6JcmhUUgS/xmdRuySXKCpIRtG+kX1 FsBNUdt7zVXIciKH78drKjYo4PYJhD0tQnv5rYwR3/PbGcFitIGiyFOgRNQv0cqHlGeu 9y928edF1AI0QN3d9ySA6ju08SKBpvuUyqAVUUTBKxMF/hoGVeig2TwgtMcmDhk5bwON ytRV6TMwbAXFECT+G69te6UyI4Y/HZtbTAL2PPKYiox8zBVdb6HWzEWgwyGh9YaT0+o5 RvasPdi/clcVZRh3FzLopILMMo7MJkLlQhmUJLYkDyArxNRZCsan6cYz+PMwXxGZXyRc 2XAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d3ruOHdYru6Rpy+BKpMXi/6c+V83W2zZQqeLjuI07mA=; b=dfESU2jNGoMqFVRlIXDb+955pCOiQhAUjamaIRAazGKEDlyUNoyjxA2lKU5UVHB/yk IxWFjMY/i1unDTAJYOWlA5Ur+F/DOz3fwUXqg6PCzX/Av5fmpmwJc39rey+yf6mPDCVU RHFw060sFn/YywnU7mGYqCeakkyVJRH5ejRBlSrIgzCrn/Kfljr1srxFxjWSCbmtnPY8 lHlu8APy3dX5MGe5UxBVr3/te5OfuocFUaj0td2oepRtIgv55xN9jnRwopN1htuVyvI/ qBfZtnsYugpOAzj/VOrb2+F+4X8rZ3EHxMHuDrhVeGB/5OtP/2qQhVSXdsE2EuZ+pdcy d+qQ== X-Gm-Message-State: APjAAAUurb68heGTDCLdVSVpmlrxA0kSG89XdGPBGfAfJWpk5afvWmja sB0Shl9W1Q/b7qL05I/whaW6XO3bnaqS76QjqdnyRA== X-Received: by 2002:a5d:9e48:: with SMTP id i8mr22818920ioi.51.1562086630549; Tue, 02 Jul 2019 09:57:10 -0700 (PDT) MIME-Version: 1.0 References: <20190701173042.221453-1-henryburns@google.com> In-Reply-To: From: Henry Burns Date: Tue, 2 Jul 2019 09:56:34 -0700 Message-ID: Subject: Re: [PATCH] mm/z3fold: Fix z3fold_buddy_slots use after free To: Vitaly Wool Cc: Andrew Morton , Vitaly Vul , Mike Rapoport , Xidong Wang , Shakeel Butt , Jonathan Adams , Linux-MM , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 2, 2019 at 12:45 AM Vitaly Wool wrote: > > Hi Henry, > > On Mon, Jul 1, 2019 at 8:31 PM Henry Burns wrote: > > > > Running z3fold stress testing with address sanitization > > showed zhdr->slots was being used after it was freed. > > > > z3fold_free(z3fold_pool, handle) > > free_handle(handle) > > kmem_cache_free(pool->c_handle, zhdr->slots) > > release_z3fold_page_locked_list(kref) > > __release_z3fold_page(zhdr, true) > > zhdr_to_pool(zhdr) > > slots_to_pool(zhdr->slots) *BOOM* > > Thanks for looking into this. I'm not entirely sure I'm all for > splitting free_handle() but let me think about it. > > > Instead we split free_handle into two functions, release_handle() > > and free_slots(). We use release_handle() in place of free_handle(), > > and use free_slots() to call kmem_cache_free() after > > __release_z3fold_page() is done. > > A little less intrusive solution would be to move backlink to pool > from slots back to z3fold_header. Looks like it was a bad idea from > the start. > > Best regards, > Vitaly We still want z3fold pages to be movable though. Wouldn't moving the backink to the pool from slots to z3fold_header prevent us from enabling migration?