Received: by 10.223.185.116 with SMTP id b49csp684778wrg; Wed, 14 Feb 2018 05:30:51 -0800 (PST) X-Google-Smtp-Source: AH8x227GXQVfevLPXKEIff0cJXRiPqkw/qLeYtnsK9bvrUPcEfJ/5cxSZ1Lkf+8px9sipIRMzVE7 X-Received: by 2002:a17:902:74c3:: with SMTP id f3-v6mr4519177plt.444.1518615051588; Wed, 14 Feb 2018 05:30:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518615051; cv=none; d=google.com; s=arc-20160816; b=xcvXCGtQxs3m6cmkK9Ki6u2HsB0N+NWBOKe6QNS3YufM7IS909lnbvdAd3OIRggl3u aGGp3XFt4RsHnC4DuxmYVZNQXTwUw3Sc/o3fAY6NxVVaDtTe4gXHHegX+Z97XwgfcmrO SIwFi+8UQEpUXMXtYvtuZ3/5yJUXEtYcaZ68ALHfSfLyiuW9IMJAQV7DWmlGzN/ErV0K YIsW516hr2F86fE2PtWjXKF6XpfBCIaDuIq1/9E9O5XNKl9iFZt+yxC7X2qcPMkcMKOv Qh0AECGXDWMXtdhLjBw7qOm4UVT6EOrS4W67mx7QzY02sJOofnEyrtjhyjWKA0zd/q39 0fdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=wo/gGFPJ7+oSJC2whpWII1i3N7i2XJmWm2pEFuy3HFg=; b=VqbpE4Nq7z7250JL2OnLcQd3YTUW2GOAr7Mzr/7Yh5G3mFQiMSW2uGZX/0eGHbKEaz ZyW66r4ZAXaAKZXsf2EKDuJijE1DWtT7R3c5L1Fy3/kB3aTUiQeG2rrH7iRM4tsEvfxx VIB2WX7Sis2p0Es9Qam+cPv37P5kxWHY4+RNX5AlYGwL9wTwShmm6AvnEC+H4zhpBZ1F q01lsVbbrpZeGFt/9xpXT5/joV0QVYMUsn5fiQaWq9IJpESr9ieUZGN0helGCC8geeXa DSHORG/CEEM8z7B+wON2k75Hyt71OSEq/QP3tylK9gLO4Z2p3FsX84+Wbi8QFla4kojg O+UA== 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 a8-v6si2193906plz.36.2018.02.14.05.30.35; Wed, 14 Feb 2018 05:30:51 -0800 (PST) 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 S1030371AbeBNN3g (ORCPT + 99 others); Wed, 14 Feb 2018 08:29:36 -0500 Received: from www62.your-server.de ([213.133.104.62]:37492 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030209AbeBNN3d (ORCPT ); Wed, 14 Feb 2018 08:29:33 -0500 Received: from [62.202.221.8] (helo=linux.home) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-SHA:256) (Exim 4.85_2) (envelope-from ) id 1elx7j-0005er-Vr; Wed, 14 Feb 2018 14:29:24 +0100 Subject: Re: WARNING in kvmalloc_node To: Jason Wang , Jesper Dangaard Brouer Cc: Michal Hocko , Matthew Wilcox , syzbot , akpm@linux-foundation.org, dhowells@redhat.com, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mingo@kernel.org, rppt@linux.vnet.ibm.com, syzkaller-bugs@googlegroups.com, vbabka@suse.cz, viro@zeniv.linux.org.uk, Alexei Starovoitov , netdev@vger.kernel.org, "Michael S. Tsirkin" References: <001a1144c4ca5dc9d6056520c7b7@google.com> <20180214025533.GA28811@bombadil.infradead.org> <20180214084308.GX3443@dhcp22.suse.cz> <24351362-a099-3317-2b96-8cdc6835eb1e@redhat.com> <20180214115119.GA3443@dhcp22.suse.cz> <62489a86-b578-b075-3ada-c2f5baf5b787@redhat.com> <20180214132950.2d06e612@redhat.com> From: Daniel Borkmann Message-ID: <0c511cb9-9f3c-eb58-9d33-e4fc873b26a3@iogearbox.net> Date: Wed, 14 Feb 2018 14:29:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.99.3/24314/Wed Feb 14 10:21:29 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/14/2018 01:47 PM, Jason Wang wrote: > On 2018年02月14日 20:29, Jesper Dangaard Brouer wrote: >> On Wed, 14 Feb 2018 13:17:18 +0100 >> Daniel Borkmann wrote: >>> On 02/14/2018 01:02 PM, Jason Wang wrote: >>>> On 2018年02月14日 19:51, Michal Hocko wrote: >>>>> On Wed 14-02-18 19:47:30, Jason Wang wrote: >>>>>> On 2018年02月14日 17:28, Daniel Borkmann wrote: >>>>>>> [ +Jason, +Jesper ] >>>>>>> >>>>>>> On 02/14/2018 09:43 AM, Michal Hocko wrote: >>>>>>>> On Tue 13-02-18 18:55:33, Matthew Wilcox wrote: >>>>>>>>> On Tue, Feb 13, 2018 at 03:59:01PM -0800, syzbot wrote: >>>>>>>> [...] >>>>>>>>>>     kvmalloc include/linux/mm.h:541 [inline] >>>>>>>>>>     kvmalloc_array include/linux/mm.h:557 [inline] >>>>>>>>>>     __ptr_ring_init_queue_alloc include/linux/ptr_ring.h:474 [inline] >>>>>>>>>>     ptr_ring_init include/linux/ptr_ring.h:492 [inline] >>>>>>>>>>     __cpu_map_entry_alloc kernel/bpf/cpumap.c:359 [inline] >>>>>>>>>>     cpu_map_update_elem+0x3c3/0x8e0 kernel/bpf/cpumap.c:490 >>>>>>>>>>     map_update_elem kernel/bpf/syscall.c:698 [inline] >>>>>>>>> Blame the BPF people, not the MM people ;-) >>>>>>> Heh, not really. ;-) >>>>>>>   >>>>>>>> Yes. kvmalloc (the vmalloc part) doesn't support GFP_ATOMIC semantic. >>>>>>> Agree, that doesn't work. >>>>>>> >>>>>>> Bug was added in commit 0bf7800f1799 ("ptr_ring: try vmalloc() when kmalloc() fails"). >>>>>>> >>>>>>> Jason, please take a look at fixing this, thanks! >>>>>> It looks to me the only solution is to revert that commit. >>>>> Do you really need this to be GFP_ATOMIC? I can see some callers are >>>>> under RCU read lock but can we perhaps do the allocation outside of this >>>>> section? >>>> If I understand the code correctly, the code would be called by XDP program (usually run inside a bh) which makes it hard to do this. >>>> >>>> Rethink of this, we can probably test gfp and not call kvmalloc if GFP_ATOMIC is set in __ptr_ring_init_queue_alloc(). >>> That would be one option indeed (probably useful in any case to make the API >>> more robust). Another one is to just not use GFP_ATOMIC in cpumap. Looking at >>> it, update can neither be called out of a BPF prog since prevented by verifier >>> nor under RCU reader side when updating this type of map from syscall path. >>> Jesper, any concrete reason we still need GFP_ATOMIC here? >> Allocations in cpumap (related to ptr_ring) should only be possible to >> be initiated through userspace via bpf-syscall. > > I see verifier guarantees this. > >>   Thus, there isn't any >> reason for GFP_ATOMIC here. > > Want me to send a patch to remove GFP_ATOMIC here? Sounds good, thanks Jason!