From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE92CC04AB6 for ; Tue, 28 May 2019 06:23:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66EDB20883 for ; Tue, 28 May 2019 06:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559024583; bh=1CB0C0zfXTXpOSMP0XU5dcyt8a//BlGzArw5VBnZZJQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=uql+NNWiAn2IDUXGGqw94WELD7hQ/GOqd6pm8kUX4gZHUslnLFVHmB9RVtf/Krq7v /tCC4RknnPKaO+Qm4TRIOvshZfwr2T95G++aQ3kfjt48PFQyBynEH4zskhL7N6yjy+ gC89b1+Tp1ou6UnLCJ+EBsj/BwStygcXnZtJcVxM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727039AbfE1GXC (ORCPT ); Tue, 28 May 2019 02:23:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:44066 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725904AbfE1GXC (ORCPT ); Tue, 28 May 2019 02:23:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BF63CAF98; Tue, 28 May 2019 06:22:59 +0000 (UTC) Date: Tue, 28 May 2019 08:22:57 +0200 From: Michal Hocko To: Shakeel Butt Cc: Kirill Tkhai , Vladimir Davydov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, syzbot+f90a420dfe2b1b03cb2c@syzkaller.appspotmail.com Subject: Re: [PATCH] list_lru: fix memory leak in __memcg_init_list_lru_node Message-ID: <20190528062257.GJ1658@dhcp22.suse.cz> References: <20190528043202.99980-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190528043202.99980-1-shakeelb@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 27-05-19 21:32:02, Shakeel Butt wrote: > Syzbot reported following memory leak: > > ffffffffda RBX: 0000000000000003 RCX: 0000000000441f79 > BUG: memory leak > unreferenced object 0xffff888114f26040 (size 32): > comm "syz-executor626", pid 7056, jiffies 4294948701 (age 39.410s) > hex dump (first 32 bytes): > 40 60 f2 14 81 88 ff ff 40 60 f2 14 81 88 ff ff @`......@`...... > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [<0000000018f36b56>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline] > [<0000000018f36b56>] slab_post_alloc_hook mm/slab.h:439 [inline] > [<0000000018f36b56>] slab_alloc mm/slab.c:3326 [inline] > [<0000000018f36b56>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553 > [<0000000055b9a1a5>] kmalloc include/linux/slab.h:547 [inline] > [<0000000055b9a1a5>] __memcg_init_list_lru_node+0x58/0xf0 mm/list_lru.c:352 > [<000000001356631d>] memcg_init_list_lru_node mm/list_lru.c:375 [inline] > [<000000001356631d>] memcg_init_list_lru mm/list_lru.c:459 [inline] > [<000000001356631d>] __list_lru_init+0x193/0x2a0 mm/list_lru.c:626 > [<00000000ce062da3>] alloc_super+0x2e0/0x310 fs/super.c:269 > [<000000009023adcf>] sget_userns+0x94/0x2a0 fs/super.c:609 > [<0000000052182cd8>] sget+0x8d/0xb0 fs/super.c:660 > [<0000000006c24238>] mount_nodev+0x31/0xb0 fs/super.c:1387 > [<0000000006016a76>] fuse_mount+0x2d/0x40 fs/fuse/inode.c:1236 > [<000000009a61ec1d>] legacy_get_tree+0x27/0x80 fs/fs_context.c:661 > [<0000000096cd9ef8>] vfs_get_tree+0x2e/0x120 fs/super.c:1476 > [<000000005b8f472d>] do_new_mount fs/namespace.c:2790 [inline] > [<000000005b8f472d>] do_mount+0x932/0xc50 fs/namespace.c:3110 > [<00000000afb009b4>] ksys_mount+0xab/0x120 fs/namespace.c:3319 > [<0000000018f8c8ee>] __do_sys_mount fs/namespace.c:3333 [inline] > [<0000000018f8c8ee>] __se_sys_mount fs/namespace.c:3330 [inline] > [<0000000018f8c8ee>] __x64_sys_mount+0x26/0x30 fs/namespace.c:3330 > [<00000000f42066da>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301 > [<0000000043d74ca0>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > This is a simple off by one bug on the error path. I suspect fault injection has been used here because the object is tiny to fail the allocation but definitely worth fixing. Thanks! > Reported-by: syzbot+f90a420dfe2b1b03cb2c@syzkaller.appspotmail.com > Signed-off-by: Shakeel Butt Acked-by: Michal Hocko > --- > mm/list_lru.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/list_lru.c b/mm/list_lru.c > index 0bdf3152735e..92870be4a322 100644 > --- a/mm/list_lru.c > +++ b/mm/list_lru.c > @@ -358,7 +358,7 @@ static int __memcg_init_list_lru_node(struct list_lru_memcg *memcg_lrus, > } > return 0; > fail: > - __memcg_destroy_list_lru_node(memcg_lrus, begin, i - 1); > + __memcg_destroy_list_lru_node(memcg_lrus, begin, i); > return -ENOMEM; > } > > -- > 2.22.0.rc1.257.g3120a18244-goog > -- Michal Hocko SUSE Labs