From patchwork Tue Jul 31 14:10:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinbum Park X-Patchwork-Id: 10550817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2776114E2 for ; Tue, 31 Jul 2018 14:11:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 082772B046 for ; Tue, 31 Jul 2018 14:11:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0568A2AF95; Tue, 31 Jul 2018 14:11:11 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 0019B2B039 for ; Tue, 31 Jul 2018 14:11:03 +0000 (UTC) Received: (qmail 26003 invoked by uid 550); 31 Jul 2018 14:11:00 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 25970 invoked from network); 31 Jul 2018 14:10:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=DIdKv9Pqy5ibPUBuIdtbeDMZ3EsvI4Zo5Zj0c/0E5us=; b=nimNPq8SyRVJ5q6CzhXyRjd1d2O6CK2dw5ysq14Ve6VnEQy2a1jURQS21iJnkCFNXk 3HEMuxrSf+iknPM7mC2EimSsBEKqwjJZJnFoRz90MQSYHiEeLE1qKkAI0RTIXpx5lC61 TV/w/uDS8OnrL7TvGAuOzrOBxKcI94k4yvzP1XX89i0Jg4C5DZtI3KhH8NFSUjXBWpXf U8B/Vj2KIIeBtcqMG/imRfZLrDYakT4qMEOcchSZDEeqF8QaN/QZ0vE5F2QacsGsW7bX KZ5gr1L7d7/XghkquyKkVkPaFx2k0KrUxXwA03u8GCIr1/87pOI5eAHv8jboE3WtIcsV XI1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=DIdKv9Pqy5ibPUBuIdtbeDMZ3EsvI4Zo5Zj0c/0E5us=; b=WbNOdx0kkXGg/+kui4AOYvpGiiswKRRaHnTs77Y2U9WgqKntw7X6kLdNXyio4LQgnA lc6jQOKchLSnOSDt9hDSc1yk10rq2tfzGN8R1R/T2anAsnBlbJ07KrgnpLzrzfKpgPsH oDKwLzP8GidNo0aY7ubKFJPNM5g6U+OivhhGwGbN8maJpAwTn+ds3O8D++vo/wPmMRXV N6ZVQ0zC+DQcEcDA5US90vMtgHIXD+8Cv1TO5DMSAGoovmy/UaAZAhMrbWyo4r/DMZLi 8lH1P+sGg276MRkFS08q5fPcV6uXrQLRyIROxS8bqQNrJb0acsVW8xWx3Tx/cq/lzRvb ddvg== X-Gm-Message-State: AOUpUlFeVknkOrVlm4WyX44ioTb4913P4K1T21Yaqd2Nf+IKVxtwkHKu 0tsXj/1J3zMLnRjXA9f93J8= X-Google-Smtp-Source: AAOMgpc1FWDxuNTJwmyWe15ecx1y7KK0bD+Wf6TwSTeDLLhoRSUd1grrJsLXVrOOavla77PjHV4taQ== X-Received: by 2002:a17:902:8482:: with SMTP id c2-v6mr20749341plo.45.1533046247247; Tue, 31 Jul 2018 07:10:47 -0700 (PDT) Date: Tue, 31 Jul 2018 23:10:40 +0900 From: Jinbum Park To: johannes@sipsolutions.net, kvalo@codeaurora.org, davem@davemloft.net Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH] mac80211_hwsim: Fix possible Spectre-v1 for hwsim_world_regdom_custom Message-ID: <20180731141040.GA8936@pjb1027-Latitude-E5410> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: ClamAV using ClamSMTP User controls @idx which to be used as index of hwsim_world_regdom_custom. So, It can be exploited via Spectre-like attack. (speculative execution) This kind of attack leaks address of hwsim_world_regdom_custom, It leads an attacker to bypass security mechanism such as KASLR. So sanitize @idx before using it to prevent attack. I leveraged strategy [1] to find and exploit this gadget. [1] https://github.com/jinb-park/linux-exploit/ tree/master/exploit-remaining-spectre-gadget/ Signed-off-by: Jinbum Park --- drivers/net/wireless/mac80211_hwsim.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 998dfac..b41fdc3 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "mac80211_hwsim.h" #define WARN_QUEUE 100 @@ -3350,6 +3351,9 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info) kfree(hwname); return -EINVAL; } + + idx = array_index_nospec(idx, + ARRAY_SIZE(hwsim_world_regdom_custom)); param.regd = hwsim_world_regdom_custom[idx]; }