Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11812624pjo; Thu, 2 Jan 2020 14:43:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxcnqTR/ZnhDlE4ZcRL9ABA5e/RPJXA09329B+h+EA+CD3TRyF3veV2q90YYeVeDzwph9HD X-Received: by 2002:a05:6830:158:: with SMTP id j24mr96541597otp.316.1578004988220; Thu, 02 Jan 2020 14:43:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578004988; cv=none; d=google.com; s=arc-20160816; b=TGlEOzHcAvY4lQB+7NG7SyIVzTGQZq0Se1aoesNp2kajrJjYeBrXxNIC3WAyVqSmuR e2/HuBvK8VORP9cisGcI/S8EkWGY1WSEAa8VjIFUAOmJbpOpTYl1dUYuQ2vdNlKAJb/K jjNAcJq+VCdB60IJNjRXY0iWuKA9c6A53W+yd1j13LYdHKETJhOsVJg8vD/N2RQUWNHY NfLmFZr3Cv1y1xTGpOap6G1a1n4Pxu2jwGoNdTmr54OaNFnZ4G/YknxiYx18MxN2tMB2 +FDY2P2VyButGyqR3XXJHiErX+6/FJg0vSubeyPqpKkNnudGljT3P9qIrBtNcmbyKgYy bcRw== 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=LZS7gPMovrg1zvfdvZLjLyC3spc2blOzMTbWdzhiO7M=; b=xZd2NAd4MOcxhM0me9UrMhI4AIksflZ0RSlSpyj47w5dH0fm4IBMl2O3rEHp7Zpr4f KOzWs1dUoKOiLYgDsKwAYI4BGgsrZzmllavXLJaiSRsiD3U0jZpDklRPala4+NqCzOdm 6wqwDexC6vvjY52htmbBgMoF/WSBtoNZ+EkAyp0HkKj48CnsBZuApynMm/DLW/jMAtPi bPAtATHm5ENj8Zqb3RhKBRHqn6jXJNicsRJo37gIPc8BwwlVz7E/oYfAgXXzDwcqxAlX CdoaQ0+16Hu2zasQlcTuQTYiowwUZ9t5J5g1JyP40XDIJL0kSmirQbHzUAxCRvijGpQO Du2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bY+9jX+4; 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 o8si29635257oti.47.2020.01.02.14.42.56; Thu, 02 Jan 2020 14:43:08 -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=bY+9jX+4; 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 S1730736AbgABWgu (ORCPT + 99 others); Thu, 2 Jan 2020 17:36:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:48432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730991AbgABWgr (ORCPT ); Thu, 2 Jan 2020 17:36:47 -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 03FBE20863; Thu, 2 Jan 2020 22:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004607; bh=aWwajad3FFOd5MGX83mrg5evnt4kXJ3VwXi8MagwZ7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bY+9jX+4TQRyLrFHUHYOcTgn/wxGyO7HpgouOHjzI6fnjfcwCAYnXfnw/dKIEPW8J 4qfd2rX42zqCNIaJHvB03NI5D35avANdjVl4XZofgBBISTpTjQEEplIfO1WFiZ+Syf BHm6+y6OMfHvLHJYmpu8BYbZYgNWfDGT6W+Jx5k4= 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.4 077/137] net: nfc: nci: fix a possible sleep-in-atomic-context bug in nci_uart_tty_receive() Date: Thu, 2 Jan 2020 23:07:30 +0100 Message-Id: <20200102220557.086899682@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.618583146@linuxfoundation.org> References: <20200102220546.618583146@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 @@ -355,7 +355,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; }