Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3819428ybi; Mon, 29 Jul 2019 13:14:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6Zl5GYgC9f/y7b3ivd2fThbvXf70BpA1EhUnagpIFHIXyjk4YqfNDID5YbWchDYgalyvo X-Received: by 2002:a63:f50d:: with SMTP id w13mr105576942pgh.411.1564431289909; Mon, 29 Jul 2019 13:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431289; cv=none; d=google.com; s=arc-20160816; b=LaG4N3jngLmx0FkvaW9cUhUtmd84juUXMIjP9bQZUvUGZpv401TrJrEUr5MFAi1Hho jKw5UsACwfKHrJu9/yhAC4KTnVrQ/Pb2TeABgO32qjSAHALJnINQyv4z8fTttfXXEd8b UVbpFy0q/JCwPTHIYVw2FHiuj2dxH4vHWSZqYqTPmNE75RgrG1bjyn3L2tALWkYOX5Pf TnrZcyL01QBe60hFEt397MZaP5/apmp85aExtyBI4pzfzgTT2JECEir4aEv061XA1hiu pe+xab1W4PISap2pQ1ChYtEYFHZ4odlufzAzxnJK8tceSQ51Ny5NVg1rGa9qCpOu/Wia pvqw== 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=q2+YVnxj9dHkjIBtWNLkQ/J1W80n4y9wSnBQOXrqS3E=; b=fgqY03yj3rFD+ZkWHHZZyZo1CKMHJlz6l3PqyVDRhC3oXIcjWhK/whXr0rVVjDp3J5 PmM4UDzCTQkvTZcERlg1jpoXxHyEAftQQYm25YrucwD4V40PWG9N/4NBd4mCtUIJchRD uTVJi3W90SvqjFaMrItvniqkhRA+VyHp/LOdEEBZO6K1Vn0ICP4maK3duaHBgkjGwg9I MagSVkLgo6CJcr2pK0QdFhiImX2OcHryfiSLwID50XcZaxQ9YUbHZLH9plmNJUdj17oO dvZbZQdbG5fVgioluEacClBd1z97zGUlFnGGwivaZIw8uXK5jsbmOSf1Cp+8Cczc2k+i qvKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QlNQrfJo; 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 s14si29947172pgj.347.2019.07.29.13.14.34; Mon, 29 Jul 2019 13:14:49 -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=QlNQrfJo; 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 S2387815AbfG2TaI (ORCPT + 99 others); Mon, 29 Jul 2019 15:30:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:42858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388072AbfG2TaH (ORCPT ); Mon, 29 Jul 2019 15:30:07 -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 18A0F2070B; Mon, 29 Jul 2019 19:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428606; bh=QRFJk2Cs9CtvaTS/cAOmN4Jgy3mHSXjz53+tvakQ11c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QlNQrfJo/pjyoU6X1qBX/Yn/bcm62dBh1abpJ/jmDYAbne/bP9n4Czf/df9jTtKHn 929ygVapHhTxSU2qnnjJgDcmu9zNKvHGv5W0hTyOiKICz1vgcy6ZjIEQDoDWlqZCct sObAB+kI6L6nFB4TlJ4exS5vuYfSFfGtes90Fp94= 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.14 102/293] gtp: fix Illegal context switch in RCU read-side critical section. Date: Mon, 29 Jul 2019 21:19:53 +0200 Message-Id: <20190729190832.456484955@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 2756edd84abc..c751f87c935e 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -956,7 +956,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