Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3124172iob; Mon, 16 May 2022 13:42:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxY+iq44MPJ8su1XtJe1CKeLwgm1A4D1yJqtBI6TWFvCGe6TQc2SQu9bUC+ZDOk0/DMPnSH X-Received: by 2002:a17:907:1c0b:b0:6f5:64f4:91df with SMTP id nc11-20020a1709071c0b00b006f564f491dfmr17123505ejc.750.1652733775596; Mon, 16 May 2022 13:42:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652733775; cv=none; d=google.com; s=arc-20160816; b=n0s3P0VH+gnsPRqwfMqmI+SbyJSASH6iF/ouAiTZpkpQkZ+4W1eBRvnf7/o+OkQ68D m/mEeLVS91rxfHFe8ycsJA+dI9xZJ8LoYvvpCoo38QytaCe5j92mEb/SN0lW8qE1l0Y/ oueGyrEvRNHCmeV66FdHJfKMfLRYJXgLHbPxSj7pMFCqCwUCaeXv8MHDPzA32LNirrnl EPcFmB+bIOd74qX2zcTs4zb/7VQCS0RtfLLOjvE0CjX51ODtoMkqg+7NVqXqJztKdNAv ETRMbSaw/W0WJTl/3fIfTzDaG9uh2ElP5ECiRCUJ8s3PJ3e6aoMapybkQRQ5RzuuMa2u rPig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=1LbC7djwtLM4YZ72y/hNCJx0pEPopsHYbpFNoVttBhA=; b=xYQZZmNyowI1xhwFiEH3PMydyzliF8o76Q17zatPOHCi7iSEqQZfd+0q84xQ5PaNC/ USM9x1LPsriV017KekD9YIWpLIdG/QSb89C+Z42+OiDkYFb9yj2CYDHshhSF2V5La85e /MJS4ccOFNQ8OPKfvl/mpMpoVgL/EuqwG1+r3FK3pFnliVygwVNcSR9n/a9xJg6aDEfG xHaOZWHnvApnWLGRVAcWs9J8f2XTHAQC4BnsP9iZWjssJUsNH5DqBzh5QXRI04vjvlOI Zfiulv5z0kAKiPPSLMkU4i/Y8upb5UEFHAg/yh58VN+ymyMLfEwFstqoMNTYWUkV/wU6 lrYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RCmUuhtj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020a05640227d000b00425fcc5d236si12992164ede.53.2022.05.16.13.42.29; Mon, 16 May 2022 13:42:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RCmUuhtj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbiEPGop (ORCPT + 99 others); Mon, 16 May 2022 02:44:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237066AbiEPGon (ORCPT ); Mon, 16 May 2022 02:44:43 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E7CD36332 for ; Sun, 15 May 2022 23:44:42 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id f4so11236982lfu.12 for ; Sun, 15 May 2022 23:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=1LbC7djwtLM4YZ72y/hNCJx0pEPopsHYbpFNoVttBhA=; b=RCmUuhtjhJeNYEVEw1Rol9WRb4ku+esDkaKAShmsnU5o+Q9m6BZwSLu0PICvvwOcXh 2IN/J1kv0RgTIiQYDUHqWzc4AExXT4nWjeJvI+wLNAghb3kz9Ts5dlKK1B57hZavzY37 RvW51gSY/S9G/jwF/VKioXGgCHR07sVTghcWjdnlhSfEQC+SaSbzhqBUy4gIDbWZ3yhG EZboCW+y1VFmsY6ordwkQq4LmqJo9GYu//djNuAfBDqjeBetka79LaC1SaRdxi1JcNUm +Rm2v/e6ktXMpMq0OaynyTFC5FVuRFiBe1EK1F1MRaDK05Y5saajpz9aTXHxF3TMd+f3 ePOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=1LbC7djwtLM4YZ72y/hNCJx0pEPopsHYbpFNoVttBhA=; b=U/BY7I4rlnriXpmn0skEKEzP9rbUcS24pAz+4xv1X81I80veghpcFKoYa6VBxLxWAi dITBoCir8rIFdLlxmvh+449aaIzeW2XFExNy7wlEQsyiXr7AydUh5DO4kS+JdjCUpI1B KVW8IY3cmLR6ZW6RrsqjPBR4EOmCbXC0tvCnC8XxkbxycXuo47vMOfAHO0AR7KNcWyAz x5OBQVay8xDag8EW9zceNIcINYlFfwk5ihYXw7TIggej2JbFUfi8vZ4hK2fgdRYxeNQJ TSKwxkit62CHDk1C4MHnD6Xthi+xiNSo6foRBYBprJjPoy8EEeV5IM08YGc8We2nTDwl FLug== X-Gm-Message-State: AOAM530kf01VuFEB3rlnKlqN/Y4Uk6sgKTJe9A84HNXgMGw13yCUfWgs EQ0LQLciIUcch+OaAv2vHeruog== X-Received: by 2002:a19:7710:0:b0:472:3486:a49e with SMTP id s16-20020a197710000000b004723486a49emr12318505lfc.600.1652683481024; Sun, 15 May 2022 23:44:41 -0700 (PDT) Received: from [192.168.0.17] (78-11-189-27.static.ip.netia.com.pl. [78.11.189.27]) by smtp.gmail.com with ESMTPSA id y27-20020a2e545b000000b0024f3d1daef3sm1435220ljd.123.2022.05.15.23.44.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 15 May 2022 23:44:40 -0700 (PDT) Message-ID: Date: Mon, 16 May 2022 08:44:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH net] NFC: hci: fix sleep in atomic context bugs in nfc_hci_hcp_message_tx Content-Language: en-US To: Duoming Zhou , linux-kernel@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gregkh@linuxfoundation.org, alexander.deucher@amd.com, broonie@kernel.org, netdev@vger.kernel.org References: <20220516021028.54063-1-duoming@zju.edu.cn> From: Krzysztof Kozlowski In-Reply-To: <20220516021028.54063-1-duoming@zju.edu.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/05/2022 04:10, Duoming Zhou wrote: > There are sleep in atomic context bugs when the request to secure > element of st21nfca is timeout. The root cause is that kzalloc and > alloc_skb with GFP_KERNEL parameter is called in st21nfca_se_wt_timeout > which is a timer handler. The call tree shows the execution paths that > could lead to bugs: > > (Interrupt context) > st21nfca_se_wt_timeout > nfc_hci_send_event > nfc_hci_hcp_message_tx > kzalloc(..., GFP_KERNEL) //may sleep > alloc_skb(..., GFP_KERNEL) //may sleep > > This patch changes allocation mode of kzalloc and alloc_skb from > GFP_KERNEL to GFP_ATOMIC in order to prevent atomic context from > sleeping. The GFP_ATOMIC flag makes memory allocation operation > could be used in atomic context. > > Fixes: 8b8d2e08bf0d ("NFC: HCI support") > Signed-off-by: Duoming Zhou > --- > net/nfc/hci/hcp.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/nfc/hci/hcp.c b/net/nfc/hci/hcp.c > index 05c60988f59..1caf9c2086f 100644 > --- a/net/nfc/hci/hcp.c > +++ b/net/nfc/hci/hcp.c > @@ -30,7 +30,7 @@ int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe, > int hci_len, err; > bool firstfrag = true; > > - cmd = kzalloc(sizeof(struct hci_msg), GFP_KERNEL); > + cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC); No, this does not look correct. This function can sleep, so it can use GFP_KERNEL. Please just look at the function before replacing any flags... Best regards, Krzysztof