From patchwork Tue Dec 12 09:26:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10106533 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20726602B3 for ; Tue, 12 Dec 2017 09:26:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1661929996 for ; Tue, 12 Dec 2017 09:26:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09B7529B66; Tue, 12 Dec 2017 09:26:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81E8B29996 for ; Tue, 12 Dec 2017 09:26:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752247AbdLLJ0N (ORCPT ); Tue, 12 Dec 2017 04:26:13 -0500 Received: from m12-17.163.com ([220.181.12.17]:56670 "EHLO m12-17.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750915AbdLLJ0J (ORCPT ); Tue, 12 Dec 2017 04:26:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=BoVo8oXXio8Y2ydFNw aJD5YgY9VYmtkzcbiUBuiSFXM=; b=oYfcTX4QIcwOLIjTN0gvepiNn4NvOVrybX 2oqsuPxaJJcxUZTekf7dbiYV7Zor/UFgzgE4s1eb5R+z3caKR+7HeQoSd9mGKIPc oNar4Xv69OSwJdk4y4qAM1EfoBEV3SjICPWnQ9aVwEPnoriiM6cVW21KZz3NC2eP rP/jyd2Ps= Received: from bai-oslab.tsinghua.edu.cn (unknown [166.111.70.15]) by smtp13 (Coremail) with SMTP id EcCowAD3_9c9oC9asZlGDQ--.62860S2; Tue, 12 Dec 2017 17:24:18 +0800 (CST) From: Jia-Ju Bai To: johannes@sipsolutions.net, kvalo@codeaurora.org, j@w1.fi, jlopex@gmail.com Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] mac80211_hwsim: Fix a possible sleep-in-atomic bug in hwsim_get_radio_nl Date: Tue, 12 Dec 2017 17:26:36 +0800 Message-Id: <1513070796-24283-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: EcCowAD3_9c9oC9asZlGDQ--.62860S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7GF48CF4DXrWxAr1xKr4Durg_yoWDAFX_Wr 4xXrnxAr97JwnI9r40krW29FW2krWUWr18ua9aqrWSyws8JrW5Jas5Zry7Cr9xWa1xAFWr XwsrJFn5Aw12qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUb0387UUUUU== X-Originating-IP: [166.111.70.15] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiHgKselSIYTcztgAAsF Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver may sleep under a spinlock. The function call path is: hwsim_get_radio_nl (acquire the spinlock) nlmsg_new(GFP_KERNEL) --> may sleep To fix it, GFP_KERNEL is replaced with GFP_ATOMIC. This bug is found by my static analysis tool(DSAC) and checked by my code review. Signed-off-by: Jia-Ju Bai --- drivers/net/wireless/mac80211_hwsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 10b075a..f2ebf4a 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3215,7 +3215,7 @@ static int hwsim_get_radio_nl(struct sk_buff *msg, struct genl_info *info) if (!net_eq(wiphy_net(data->hw->wiphy), genl_info_net(info))) continue; - skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); if (!skb) { res = -ENOMEM; goto out_err;