Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13328643ybl; Sun, 29 Dec 2019 09:24:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxQU/1FTpb+bppSvMTo/zl/Pdgoe5EjPzOmawt22EuqFW4Txmb8yv2TUKwcLSAFV97Qjnja X-Received: by 2002:a05:6830:4c2:: with SMTP id s2mr72218168otd.144.1577640297473; Sun, 29 Dec 2019 09:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577640297; cv=none; d=google.com; s=arc-20160816; b=g1Leox3Lz8F+8zAN8FHTt6ELEOzD4y4f6W170EAOO47Nh7nQrQDviGjX93Iy772Kdt sURD74dcRiGwgcKUgwTCQeovmjSqZIBW8hi2pqMuygfM9SCCWTSKgTzAUfi965GfXpVH Ohg4UgeJBBYYDQTrhOTuNuOc9Ok0AvYYh36PDtbayUx4ELRw8SkjiuVRdQSO2upNSFzq VWFWEEmPtmrx5l42GguZgq5APhA8DvchZh2kcXKo3T04urLV9u1PGBX7HkmBdKtVvxXe yDXfSdI6e2jsj+JgC3cdokDpIr2hHF4N8aAg+sTI/uGHgmA68P9k0J6thLII4CeurriG tDRQ== 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=6FnhzECPO7hEyDL3eVFan3gWwZcU3M7xDM17i2lTj8M=; b=hYyAOblNSujg87U9GGpzla1UPRgX0PIMmP6LAueNBsmuqvJseyIHGVRCZ8STFdTest 8c/Z5jIDkm77ozM4mux73E1Zx7/rZK2psbgq7nW+Ot11zPTcggEe22vfG/UY8rh4R4ED fEJtFO23Tp507s6oJF9RFoVpIouCmfUuOmkUvb2P+bMNgqm24UqpD3noYgPaYJAIpHQm jwW0TMpRhwBM10KCOirsVofbmXF264iZ5BssxprMokBxeefsI+y2IDhii6TWS7Bq4d5W tsF+EG5DJUPteuEu6U2kYJjKAMwPb69URhBSAV9cgdJ33tpHhyLnFaz8lZlVdaLeK9+K j0xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d4DsM1Gn; 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 z10si22513957oto.36.2019.12.29.09.24.46; Sun, 29 Dec 2019 09:24:57 -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; dkim=pass header.i=@kernel.org header.s=default header.b=d4DsM1Gn; 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 S1727387AbfL2RWn (ORCPT + 99 others); Sun, 29 Dec 2019 12:22:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:39160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727355AbfL2RWg (ORCPT ); Sun, 29 Dec 2019 12:22:36 -0500 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 90913207FD; Sun, 29 Dec 2019 17:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640156; bh=iT8ha0g8v8WDWsKNDeVxAqM6YfuJogpdYejcBs+bGI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d4DsM1Gnn/fhbn5htEgXCAPvTYYyXQoS1+3nuy5ppPIMIIITEOXPxdVM6ZElMzyga 268663WpkE6CiANYpIZks95tGBkgpOaNzJ/NS1qT8ZuxnLNR3aRp6KdFStDfjMUvHq huT2mJueD3KaYuM8SgDH34pxDn9dDVr5SIASMxrI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , "David S. Miller" Subject: [PATCH 4.14 006/161] net: nfc: nci: fix a possible sleep-in-atomic-context bug in nci_uart_tty_receive() Date: Sun, 29 Dec 2019 18:17:34 +0100 Message-Id: <20191229162357.440178357@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@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 From: Jia-Ju Bai [ Upstream commit b7ac893652cafadcf669f78452329727e4e255cc ] The kernel may sleep while holding a spinlock. The function call path (from bottom to top) in Linux 4.19 is: net/nfc/nci/uart.c, 349: nci_skb_alloc in nci_uart_default_recv_buf net/nfc/nci/uart.c, 255: (FUNC_PTR)nci_uart_default_recv_buf in nci_uart_tty_receive net/nfc/nci/uart.c, 254: spin_lock in nci_uart_tty_receive nci_skb_alloc(GFP_KERNEL) can sleep at runtime. (FUNC_PTR) means a function pointer is called. To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC for nci_skb_alloc(). This bug is found by a static analysis tool STCheck written by myself. Signed-off-by: Jia-Ju Bai Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/nfc/nci/uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/nfc/nci/uart.c +++ b/net/nfc/nci/uart.c @@ -348,7 +348,7 @@ static int nci_uart_default_recv_buf(str nu->rx_packet_len = -1; nu->rx_skb = nci_skb_alloc(nu->ndev, NCI_MAX_PACKET_SIZE, - GFP_KERNEL); + GFP_ATOMIC); if (!nu->rx_skb) return -ENOMEM; }