Received: by 10.213.65.68 with SMTP id h4csp2118553imn; Sun, 8 Apr 2018 20:09:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx49kMucLiDRZu+rd4gN4DBn0/WHnz2+tz1h9AEzrbKNRDe7JDzKqK8zlTLF8k+EvQ6HdQA1C X-Received: by 10.98.31.86 with SMTP id f83mr27943007pff.196.1523243303438; Sun, 08 Apr 2018 20:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243303; cv=none; d=google.com; s=arc-20160816; b=uPzHaBA6HBV7mAaqGw0wC1YqOomhAZjmkOlYHQ8sfoAkO0R6wpXNd8VGF7JKTuQd/o dv4mMoFygaQpvsFTAuHTrJpqM9T/ajFBrjp1L1zktQ+l0pvonWOcIC6TQzyOX2M2juax uNAcRD9uhwVaXi6ExQ92LLOr4pI74JOkBaCLskW/gMwYaXwMN+ShpN99wEaJ8xlqxFZQ IwUE22N6NOZ78+goaa4Z1xndPV0/GSpgpKLm4qOJJ2qjmyTR+8c/5OfCU3lgmjVfraSa 5MbAxWVDdPNH5tWuifFPN1b9q4KXUVpDLz7jfFlqgQ+wFyIVNWwCUOIcUo0PwrkVLVdM yTcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=hqNg74MuNOYsmaE4k6Vx40P7qmyT4YKsxnvVGKxc5Ys=; b=oLhX6V5AzqifTzHKYdmEJ7GN+/rM2pCYHlDkwwH/Wc7LkmiSkvkBhyM8oL36KBs5HT yyrFn9PyqVDmAL6my9rZCqCPr6XjRO0om7b9ZRSSqyB4vN5HJQ3V4ZbPiO8Wyc9eDte1 Iy0Xd1jptAjYxrm7mpjLhi+zf2vbNkWBi3IQOIKm3B5fukKZUThsEN+nYL29rjRawavy M9aPpBuUX973ClBrogI8bgIus8iggjyyEdzDifUSJ9Ar7mZ0dRh38EnrdZ3tuEXURD32 C1J3DX9qXtIxk5jt4EU3hOIx/N1g+4s51m86mair7YUhKrJgL5eDX/2SVtJD272RNcdW BntQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pf2NvjP+; 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 t26si11966246pfg.414.2018.04.08.20.07.46; Sun, 08 Apr 2018 20:08:23 -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=fail header.i=@gmail.com header.s=20161025 header.b=pf2NvjP+; 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 S1757379AbeDIB63 (ORCPT + 99 others); Sun, 8 Apr 2018 21:58:29 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:38076 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755291AbeDIB60 (ORCPT ); Sun, 8 Apr 2018 21:58:26 -0400 Received: by mail-pl0-f65.google.com with SMTP id c7-v6so936319plr.5 for ; Sun, 08 Apr 2018 18:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=hqNg74MuNOYsmaE4k6Vx40P7qmyT4YKsxnvVGKxc5Ys=; b=pf2NvjP+0yX32PmLNn/kDmOHD7WHCkC63R3iSFSHfPcKRkGEhLQm8UtTVeYR9TmeM4 k2w2Jn3SvO9EHaAf6fpVhQE/u6s1lUgCPHOvVbTiq8aa4NSngatyYOqMgGbyssP8zxIM BlxGZvKHylXDTnCgEiPh2MpHCTUlyANkQ0xJ0YjPdjLaL1RT0HAFWavmXYxRQdVUUpPY o6avBWZko89H7maQa5W/uQTtmCcgtXaEhEytMg2wCr5ga+PS4FZ7F06CvCl1NUPt55tp Yc/v9P2AdHxGkSJ5CCJj5wESep03xJBqEnTXxnjF12RT+3czqKjiWYHf2vTlXh7w34vv rNgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=hqNg74MuNOYsmaE4k6Vx40P7qmyT4YKsxnvVGKxc5Ys=; b=SXpGDUhiDLTuvNtpx8JMEFBENytKWIf6vaYIZiXgfuv2LplutLOiazzKil3mETQPf7 h7CPyYPrAQz4NcgNNFIi0kphwsjqKDBlvW7sHzsy0LPvTfL0jzv8jH00Has3STvWE+Ns G53E8I9hwY9BFoEiN+viI/b6ZTHk3DXBOsro/+pKRQwzlZyuhTP+rc2UCOrfrX97VO9L pxF3py8VglbrMpqfjj5Nrq8zbl9uJp/HSdVGfK+so+Swo2/O8/HH4sG3hNv34Stg9yug pFOfI0hgtBcGeCCAEBPgDST1FYiWYvIVTgjoOPGLIleTrxGTAXVNEJJblGvOzNux6rRR 3NHA== X-Gm-Message-State: AElRT7F3apU/ZMDp2NP6HhOMFKcP+ociQYmhrqRIfJXZyBfGGEkqdzuR hu4BA/Pua91gimHpCFcPuQ1XKoUP X-Received: by 2002:a17:902:830a:: with SMTP id bd10-v6mr35786976plb.322.1523239105407; Sun, 08 Apr 2018 18:58:25 -0700 (PDT) Received: from bbox-2.seo.corp.google.com ([2401:fa00:d:0:7630:de9:f6f2:276f]) by smtp.gmail.com with ESMTPSA id z27sm14768472pff.7.2018.04.08.18.58.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 18:58:23 -0700 (PDT) From: Minchan Kim To: Andrew Morton Cc: linux-mm , LKML , Minchan Kim , Johannes Weiner , Jan Kara , Chris Fries Subject: [PATCH] mm: workingset: fix NULL ptr dereference Date: Mon, 9 Apr 2018 10:58:15 +0900 Message-Id: <20180409015815.235943-1-minchan@kernel.org> X-Mailer: git-send-email 2.17.0.484.g0c8726318c-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Recently, I got a report like below. [ 7858.792946] [] __list_del_entry+0x30/0xd0 [ 7858.792951] [] list_lru_del+0xac/0x1ac [ 7858.792957] [] page_cache_tree_insert+0xd8/0x110 [ 7858.792962] [] __add_to_page_cache_locked+0xf8/0x4e0 [ 7858.792967] [] add_to_page_cache_lru+0x50/0x1ac [ 7858.792972] [] pagecache_get_page+0x468/0x57c [ 7858.792979] [] __get_node_page+0x84/0x764 [ 7858.792986] [] f2fs_iget+0x264/0xdc8 [ 7858.792991] [] f2fs_lookup+0x3b4/0x660 [ 7858.792998] [] lookup_slow+0x1e4/0x348 [ 7858.793003] [] walk_component+0x21c/0x320 [ 7858.793008] [] path_lookupat+0x90/0x1bc [ 7858.793013] [] filename_lookup+0x8c/0x1a0 [ 7858.793018] [] vfs_fstatat+0x84/0x10c [ 7858.793023] [] SyS_newfstatat+0x28/0x64 v4.9 kenrel already has the d3798ae8c6f3,("mm: filemap: don't plant shadow entries without radix tree node") so I thought it should be okay. When I was googling, I found others report such problem and I think current kernel still has the problem. https://bugzilla.redhat.com/show_bug.cgi?id=1431567 https://bugzilla.redhat.com/show_bug.cgi?id=1420335 It assumes shadow entry of radix tree relies on the init state that node->private_list allocated should be list_empty state. Currently, it's initailized in SLAB constructor which means node of radix tree would be initialized only when *slub allocates new page*, not *new object*. So, if some FS or subsystem pass gfp_mask to __GFP_ZERO, slub allocator will do memset blindly. That means allocated node can have !list_empty(node->private_list). It ends up calling NULL deference at workingset_update_node by failing list_empty check. This patch should fix it. Fixes: 449dd6984d0e ("mm: keep page cache radix tree nodes in check") Reported-by: Chris Fries Cc: Johannes Weiner Cc: Jan Kara Signed-off-by: Minchan Kim --- If it is reviewed and proved with testing, I will resend the patch to Ccing stable@vger.kernel.org. Thanks. lib/radix-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 8e00138d593f..afcbdb6c495f 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -428,6 +428,7 @@ radix_tree_node_alloc(gfp_t gfp_mask, struct radix_tree_node *parent, ret->exceptional = exceptional; ret->parent = parent; ret->root = root; + INIT_LIST_HEAD(&ret->private_list); } return ret; } @@ -2234,7 +2235,6 @@ radix_tree_node_ctor(void *arg) struct radix_tree_node *node = arg; memset(node, 0, sizeof(*node)); - INIT_LIST_HEAD(&node->private_list); } static __init unsigned long __maxindex(unsigned int height) -- 2.17.0.484.g0c8726318c-goog