Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10423129ybi; Wed, 24 Jul 2019 22:58:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/ZwJq86MXJj1PUC9RF9dOUGyxMK2B4zI+gTliif/7kweHX4azb/3hGaNFn+cuyS0dFh2L X-Received: by 2002:aa7:8108:: with SMTP id b8mr15248014pfi.197.1564034283036; Wed, 24 Jul 2019 22:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034283; cv=none; d=google.com; s=arc-20160816; b=l1s1Qt23yVZ5yyVbAX9Hf9btmULTyVXbDLu+B8MfgiMdW3fBRVbAhvOJg/HlKLwWT4 b7s8AI3gKlLSR+D9Bot+fU/Xz/JAmSjkWepHM+OYEGwHM6/5lShq0AemCkdYqeBNiRi7 r/VulWLRZ8+56YvNFQ7+LQi4v9i5dpyif7XUOwOXxVJHL4dvoAlYWFOTPgwVixh/wmC/ GRqQLzCkLTZErFIfyFKZ039N+lNYyGAMvKzVEQFLUp6i7DyYTYpVohC+5qfvotEWsqVc Vwnkl5NtDkYqvoyB60gUClbhCsttkcD7w2LMls7PU+Zn9/xjKCswhWu8krPXRfq7EthJ mqbw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xmmHZFcy820078o54T4BZa/58paZDMlhiCJBbm3xLbU=; b=JInzCXvslPCt5S9nmT8oHAQ6wNWJUfXWhUo/mXKSVUC1aXWe/YQZfkxTL4ppK+IPVG DkPhmZfm7w5OyL6Sy18JKJGLYib7yZypWnvZhtaCIoICvf8sxgSgzIhq/p1d3CLQ8xd8 ySr+57CvAoQvhmHj3uhHPampWcfR59ZEEflmFUUueMsDsPvHgemi1CLUk4C/wpTmtV81 Mtn2MlIp2Aa/ZzbA5uaebPMsCi118lSl79quKDo5gtZrFsf00r7QQwo08kVFUc3m94mH 7yAyhIqtX/7399S336le3VZkRckH+Wd8jhsA93NiNFeI9C+Rs59joi0ERWebs6E8iTZ1 TnEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bl6J9ph4; 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 e4si2301872pgh.434.2019.07.24.22.57.48; Wed, 24 Jul 2019 22:58:03 -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=pass header.i=@kernel.org header.s=default header.b=bl6J9ph4; 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 S2404649AbfGYFl2 (ORCPT + 99 others); Thu, 25 Jul 2019 01:41:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:56252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404634AbfGYFl0 (ORCPT ); Thu, 25 Jul 2019 01:41:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0524221850; Thu, 25 Jul 2019 05:41:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033285; bh=bJYU+BBdlRGXP2j5ps58YvTfzAMLYvWUtZycSO9cWgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bl6J9ph4r7Vh1f3qXIpAmwo+as2IAzZmEbOqAVBI3OIRj4QvYOrGnxYpCJsMEksYe GXEqvohoIEs+fePTK6gluRo2iuwWLbLX03fdqgkMQAoaLsg3cIWIEs7F0Rq8oa/ZCV 1bza40w9MbKmGOHizAdQ6NrnDXr5WyncdoQxvzps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 155/271] gtp: fix Illegal context switch in RCU read-side critical section. Date: Wed, 24 Jul 2019 21:20:24 +0200 Message-Id: <20190724191708.483372021@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 3f167e1921865b379a9becf03828e7202c7b4917 ] ipv4_pdp_add() is called in RCU read-side critical section. So GFP_KERNEL should not be used in the function. This patch make ipv4_pdp_add() to use GFP_ATOMIC instead of GFP_KERNEL. Test commands: gtp-link add gtp1 & gtp-tunnel add gtp1 v1 100 200 1.1.1.1 2.2.2.2 Splat looks like: [ 130.618881] ============================= [ 130.626382] WARNING: suspicious RCU usage [ 130.626994] 5.2.0-rc6+ #50 Not tainted [ 130.627622] ----------------------------- [ 130.628223] ./include/linux/rcupdate.h:266 Illegal context switch in RCU read-side critical section! [ 130.629684] [ 130.629684] other info that might help us debug this: [ 130.629684] [ 130.631022] [ 130.631022] rcu_scheduler_active = 2, debug_locks = 1 [ 130.632136] 4 locks held by gtp-tunnel/1025: [ 130.632925] #0: 000000002b93c8b7 (cb_lock){++++}, at: genl_rcv+0x15/0x40 [ 130.634159] #1: 00000000f17bc999 (genl_mutex){+.+.}, at: genl_rcv_msg+0xfb/0x130 [ 130.635487] #2: 00000000c644ed8e (rtnl_mutex){+.+.}, at: gtp_genl_new_pdp+0x18c/0x1150 [gtp] [ 130.636936] #3: 0000000007a1cde7 (rcu_read_lock){....}, at: gtp_genl_new_pdp+0x187/0x1150 [gtp] [ 130.638348] [ 130.638348] stack backtrace: [ 130.639062] CPU: 1 PID: 1025 Comm: gtp-tunnel Not tainted 5.2.0-rc6+ #50 [ 130.641318] Call Trace: [ 130.641707] dump_stack+0x7c/0xbb [ 130.642252] ___might_sleep+0x2c0/0x3b0 [ 130.642862] kmem_cache_alloc_trace+0x1cd/0x2b0 [ 130.643591] gtp_genl_new_pdp+0x6c5/0x1150 [gtp] [ 130.644371] genl_family_rcv_msg+0x63a/0x1030 [ 130.645074] ? mutex_lock_io_nested+0x1090/0x1090 [ 130.645845] ? genl_unregister_family+0x630/0x630 [ 130.646592] ? debug_show_all_locks+0x2d0/0x2d0 [ 130.647293] ? check_flags.part.40+0x440/0x440 [ 130.648099] genl_rcv_msg+0xa3/0x130 [ ... ] Fixes: 459aa660eb1d ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)") Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/gtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index f45a806b6c06..6f1ad7ccaea6 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -958,7 +958,7 @@ static int ipv4_pdp_add(struct gtp_dev *gtp, struct sock *sk, } - pctx = kmalloc(sizeof(struct pdp_ctx), GFP_KERNEL); + pctx = kmalloc(sizeof(*pctx), GFP_ATOMIC); if (pctx == NULL) return -ENOMEM; -- 2.20.1