Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9983024ybi; Wed, 24 Jul 2019 13:31:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDgvECOi5viL7UzlVmL4upqf3w+bFWa1Yfws18ItLyavXuyz7YEeEGFsk0DruvDrlAW58D X-Received: by 2002:a62:be02:: with SMTP id l2mr13388744pff.63.1564000274693; Wed, 24 Jul 2019 13:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000274; cv=none; d=google.com; s=arc-20160816; b=btoed/3CxJFg6hHAjn1DQUi/6KgVHt4kbv34tDeOJvfanAOVVJ/IDlVvmGf/TPWlGv GLiVcBGiSEGO5KEPSe1SgLBIMfYu++U40MJB5DZv3D6k/X6wS7B7dGE4iVjZfN3XCxVi VDOalDMb5t2F6Xk6o8G1aGOOZZKvtzc5TObDrMnx3SCeNNnSC+fXvzy9qF+QRPFQ+oOc X7N28gJATHFmUv1gq2YOFtwamdYODKcBdkXPX4+VotKcFjL7+DvjucZCgRF/xReeT30A Ot4EhFT5dSorkJloNdgq0ap3Y9UvD9jH3ZykApR2JrWlJY4XVV9Xbkn9wZxoIYnQgqxi Rl5g== 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=ynLIZccG4n0kMvquBBUlUEmar+mwSZL8nKPYfDxyoyk=; b=ei0Cg29jR6T8WQ/aAVYPB0HPNiF40q9rUP3W55RjdT+gm5kpEXkVllozLiisBWYRDm ySq8hhK/ECgAf/ArC5iDDAqRp8px9bmfGkoVw+XGA4IInIZxcFoBOogeg1LZcJrTjfkh rXsnUt8TI1eJYankrWAUkbfe/lDuD0BxZao0zi2OK85FevHmyVXsAdA/yuCIk3uh1BSu pUEo1FQo2zMjcwQ6Anc+DKzSYHBopdqHQfYjsIblzvcqO8uZ7rGwt56952dVVRylSL1A fVjUsLXcFfoAYMthqv4wu3u3q22patw49HW588sbEaCvaK4HnUm3MYWeJ7jzGdd6Rdqo oSrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jhuHlJA8; 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 y134si16073821pfc.285.2019.07.24.13.30.59; Wed, 24 Jul 2019 13:31:14 -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=jhuHlJA8; 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 S2389076AbfGXTeT (ORCPT + 99 others); Wed, 24 Jul 2019 15:34:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:56570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388457AbfGXTeQ (ORCPT ); Wed, 24 Jul 2019 15:34:16 -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 8229B22ADA; Wed, 24 Jul 2019 19:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996856; bh=g8Y/uJKuBxjYelXRJK66MD+Ve4OmTAUHD0BuRp7YMwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jhuHlJA8sk68fzhQBT++k3EEIDs3EHt/GpADyLOHSoMmKK/XWWAYYuAKSILK59Cc2 EqArBv4jnXWja038C0gWnaZ5bRIaKkvIKUjXNwd3ZA2yPyMSGl/rCIZBUx0SMrAYxV QzbpUDxi7zny74UjCdczU366A5dE5S0nDqte0GPE= 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 5.2 239/413] gtp: fix Illegal context switch in RCU read-side critical section. Date: Wed, 24 Jul 2019 21:18:50 +0200 Message-Id: <20190724191752.434296034@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 61f19e66be55..b770335c03c1 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -954,7 +954,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