Received: by 10.223.185.116 with SMTP id b49csp622424wrg; Wed, 14 Feb 2018 04:31:21 -0800 (PST) X-Google-Smtp-Source: AH8x224+xke7DiQ01Lml0QCTFgPiFxF9hnKLq5FE3nsBQhvFuwKMFZrvuZby7EAibORfYvvW0qEp X-Received: by 10.98.86.131 with SMTP id h3mr4626938pfj.208.1518611481612; Wed, 14 Feb 2018 04:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518611481; cv=none; d=google.com; s=arc-20160816; b=lW5LXfeXbbd2yU/CIDNR79H+fIy78rgNq/IoALFhRAgyw2mHigFfA8n/QZT8fNgpfV djxdgDX62AL9vi+XwKPMLpmG/ywpkc5jEVsywaHdvOJm9kgV3+l50RODJcCbPV0jM8tL vcbXOxJ1ZAiZDnreeZcg+sYpgsaCbubLoZRGgaqBrOmwd4nWfMGUq0Cx8ezB7WVaLwqe +cROow/rI+VL3V8o0ZnUQO3V9ONPqNmC2ZB+IAUE94ru1Dv05mT4oVQbrytfoIsfyThC NiQUtnvqm0WQg8W4JsHuNrs/D87PiIePtVAXQtJMRdX6FlQhT406ACBirWhOwjuA4W4g 3Tuw== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=iRW1lhVjZ0CMjAnPqxwl33DlIeRqCX5quvijn1WZQjA=; b=cq3lkAp/CP4rUV8Ze1ZHetU+QL8XqNUMAEUkdbBI3hPGMjAGPBUQMZ2X14z0d4zE+9 0sMeiRLhlvfjaORr/QCD2oAMTQT3RXMfYVk6OJPundSgDQZnuGPjiv7T/7KtQMb2zhyv pO6TNiYtpQ9QwXpHAvlNCBvVPQ90epqNerqVR8+xxlP4Itpeng/xAYJCLFEjJFlt9/8V t7YywZ9oVGbKpZSfKcVsU+z+BaYPc433MnimIUCvvWsu2dazK3ZajUxNTY1CFRGDbQoD fjqawaVMaZ7hTmBZTIt2JD7XurWGdoRxVprGfRxDAzsd6Suu792M3FZpTQSbfsi7b57R m98A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3si1036226pgb.754.2018.02.14.04.31.07; Wed, 14 Feb 2018 04:31:21 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967660AbeBNMaF convert rfc822-to-8bit (ORCPT + 99 others); Wed, 14 Feb 2018 07:30:05 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45980 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967450AbeBNMaB (ORCPT ); Wed, 14 Feb 2018 07:30:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E95A7D840; Wed, 14 Feb 2018 12:30:00 +0000 (UTC) Received: from localhost (ovpn-200-34.brq.redhat.com [10.40.200.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2C3EAE7A1; Wed, 14 Feb 2018 12:29:51 +0000 (UTC) Date: Wed, 14 Feb 2018 13:29:50 +0100 From: Jesper Dangaard Brouer To: Daniel Borkmann Cc: Jason Wang , 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" , brouer@redhat.com Subject: Re: WARNING in kvmalloc_node Message-ID: <20180214132950.2d06e612@redhat.com> In-Reply-To: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 14 Feb 2018 12:30:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 14 Feb 2018 12:30:00 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'brouer@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thus, there isn't any reason for GFP_ATOMIC here. -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer