Received: by 10.213.65.68 with SMTP id h4csp3842396imn; Tue, 10 Apr 2018 05:38:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx49rw31Tq5uX6GoPbAWgOq3tCU/fZNiDVbKY/r3uSHvrF2NNfZrLGh6xJzIk/d6xJ2Yi7OU/ X-Received: by 10.99.49.74 with SMTP id x71mr190980pgx.160.1523363897234; Tue, 10 Apr 2018 05:38:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523363897; cv=none; d=google.com; s=arc-20160816; b=iZlUqiSG9af5daifejP0aIUBmhXDim2DhRDqxUv6NH9XP/dLTIcQx64E7NPm6g4dFm o9ih9F69Rp9XoJ1ZZFoKfdCd/5RImrPi1N5dENiCyqQzFNIWvCbGjb6DX3l5X0WvxyJK 9d0hyo9WstM0GRjACa8xkjYhrsOtEQwmRP7FUfRZn9pbFSv0VZhSrhNoHhY82B1xYsgi Q/ruKit/Z1kgCpK6wT9nfuK/Ai+ZEy1C+sKMnwM0wH+Uehgd5YezONWiFxHTPhEusVz1 QcC7+4gpmmxehO2INuac4mikdgCm6FWKeFgDmhjxjsg4iY/6zaf1H8m2zG7SNG8ocGzh hGTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=hN3X1YGG6K1T8+PLlh9RtVJ55WwMAeaSNX2YktqOPw0=; b=oZFMfKlvsNlFfealbMK1roAYZQOpA4Iw4axCLXsmkbtrxlZKBPiF9tk2PzzI2hot3K dVtyRaiq63rNt0Y1Qyq7B0mDQGhufGeVc9awL+53q/Hxi6U6Ocgovee/ov3E7nEND1Ls qfH1ouIh8ycCNI5VAOru3UcJpuK09K5egGFYKLM7ugg8QfYEKaLiF4Wxt+0t8QrvwBR1 mxUQlCCycbrAv9Y7wO/NWIEW7PZZuq6gRw/qM5c1NSQhqabFlDNLl+1w/IJjCkzHiL/Q 30sFYowmnSbs4H1dnQdbXdmLdQeqX/KW3FKIXJd8xbTVrYjYQQUG75+1J8DP8qdZOzjW LG9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si1728823pgp.817.2018.04.10.05.37.40; Tue, 10 Apr 2018 05:38:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753198AbeDJMdM (ORCPT + 99 others); Tue, 10 Apr 2018 08:33:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:42301 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753044AbeDJMdK (ORCPT ); Tue, 10 Apr 2018 08:33:10 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 76D2DAD7F; Tue, 10 Apr 2018 12:33:08 +0000 (UTC) Date: Tue, 10 Apr 2018 14:33:06 +0200 From: Michal Hocko To: Matthew Wilcox Cc: Jaegeuk Kim , Minchan Kim , Christopher Lameter , Andrew Morton , linux-mm , LKML , Johannes Weiner , Jan Kara , Chris Fries , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] mm: workingset: fix NULL ptr dereference Message-ID: <20180410123306.GI21835@dhcp22.suse.cz> References: <20180409015815.235943-1-minchan@kernel.org> <20180409024925.GA21889@bombadil.infradead.org> <20180409030930.GA214930@rodete-desktop-imager.corp.google.com> <20180409111403.GA31652@bombadil.infradead.org> <20180409112514.GA195937@rodete-laptop-imager.corp.google.com> <20180409183827.GD17558@jaegeuk-macbookpro.roam.corp.google.com> <20180409194044.GA15295@bombadil.infradead.org> <20180410082643.GX21835@dhcp22.suse.cz> <20180410120528.GB22118@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180410120528.GB22118@bombadil.infradead.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 10-04-18 05:05:28, Matthew Wilcox wrote: > On Tue, Apr 10, 2018 at 10:26:43AM +0200, Michal Hocko wrote: > > On Mon 09-04-18 12:40:44, Matthew Wilcox wrote: > > > The problem is that the mapping gfp flags are used not only for allocating > > > pages, but also for allocating the page cache data structures that hold > > > the pages. F2FS is the only filesystem that set the __GFP_ZERO bit, > > > so it's the first time anyone's noticed that the page cache passes the > > > __GFP_ZERO bit through to the radix tree allocation routines, which > > > causes the radix tree nodes to be zeroed instead of constructed. > > > > > > I think the right solution to this is: > > > > This just hides the underlying problem that the node is not fully and > > properly initialized. Relying on the previous released state is just too > > subtle. > > That's the fundamental design of slab-with-constructors. The user provides > a constructor, so all newly allocagted objects are initialised to a known > state, then the user will restore the object to that state when it frees > the object to slab. And that is fundamentally subtle semantic and leads to bugs. So we should reconsider whether that is really worth keeping for the radix tree. > > Are you going to blacklist all potential gfp flags that come > > from the mapping? This is just unmaintainable! If anything this should > > be an explicit & with the allowed set of allowed flags. > > Oh, I agree that using the set of flags used to allocate the page > in order to allocate the radix tree nodes is a pretty horrible idea. > > Your suggestion, then, is: > > - error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM); > + error = radix_tree_preload(gfp_mask & GFP_RECLAIM_MASK); > > correct? Something like that, yes. -- Michal Hocko SUSE Labs