Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10402746ybi; Wed, 24 Jul 2019 22:34:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsy+S4IwfONsdxFYEQEBzEzuyKBexJtudoKElTBPukyNksb6U0241355HVV9VE8AE/qjDD X-Received: by 2002:a65:44cc:: with SMTP id g12mr7186188pgs.409.1564032861346; Wed, 24 Jul 2019 22:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564032861; cv=none; d=google.com; s=arc-20160816; b=XB7V/eVaLL0IoKPS2c+UBdQVooDJqNILOmkGdEh/GwBsp4I9ztfXLd0lRTgz1hjgta sy+OnvBxCWL6rs1S2gdgkk2g9jeU83Qe0PwnQTByHEZtcrcpzW0V27Po6yr854Hhd+cy gFuhpmotMRgb4pquvyrPkWDLejDhlgqVvrwvIUPcU8LbivZRl+sXFqGsZH/y/vWtjFU4 FDDAkyCO7HKVmTrRZoAOM8dh2NBTNEFZOoJdIZwd0q8HJ2b54Jq3uUbN4pkoUOoMI8OM Ag1+i5mdr1zMQIh9s+r4b5J+31QbhfXrOlp5kotDZ3AKglsSvhyzAaOLHkeC7Ukmplri MfBg== 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=qdXwejd2jFvaytNGqaLL2fZvu7g3eOKaDHjS08GdOcGiXFOb0eaRAWCySa8aT5JgTd QitnvuF6afoj3MCB1d77aWMjGmEVnma4ehInjFDictz5O4D1x6FPh1pQoWIi2Sd1+tF5 hddewBhzyev3cy535faBN0UgvhCJjNkQ6TeTEKRvL8PFGRVqfMA81xEHb9fdzAsPYqbI cc+WXSio5lyzGFzTLWqtMxorjTwxzAvtIQM01Bv4akIIMkBt7iG0CxalkPnrjwy6dQs1 aXYo/bNoobIDCWlPcxj76Ew05dModH7l34oFk+5x4jT5izgb9LZM9JzkF+Xq9i5qWNyT EZNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KYAX6HXK; 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 186si17431995pgc.248.2019.07.24.22.33.37; Wed, 24 Jul 2019 22:34:21 -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=KYAX6HXK; 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 S2404532AbfGXTzg (ORCPT + 99 others); Wed, 24 Jul 2019 15:55:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:39304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404508AbfGXTzc (ORCPT ); Wed, 24 Jul 2019 15:55:32 -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 20572205C9; Wed, 24 Jul 2019 19:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998131; bh=bJYU+BBdlRGXP2j5ps58YvTfzAMLYvWUtZycSO9cWgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KYAX6HXKl8xaFxrR1hRBTiaUrjJ7yQwJGBkSHKr8lrtDv2cr4ipd9qI2gzI6IlQzS +Kpa2tdbqX3soSB3UVNndooSrVNn8kuehdn7/1VF0zqdMIG5VIXkAsawytPp4XF15A Tzfpn3BQz5td56YdSpIJi6O5nBzaL4hXYJX9tzAA= 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.1 215/371] gtp: fix Illegal context switch in RCU read-side critical section. Date: Wed, 24 Jul 2019 21:19:27 +0200 Message-Id: <20190724191740.731183797@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@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