From patchwork Tue Oct 17 18:32:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 10012747 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 F10C060235 for ; Tue, 17 Oct 2017 18:32:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7758289DA for ; Tue, 17 Oct 2017 18:32:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA6FF289DE; Tue, 17 Oct 2017 18:32:19 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 C72D1289DA for ; Tue, 17 Oct 2017 18:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934565AbdJQScP (ORCPT ); Tue, 17 Oct 2017 14:32:15 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:41439 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753108AbdJQScO (ORCPT ); Tue, 17 Oct 2017 14:32:14 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 7df0a3d1; Tue, 17 Oct 2017 18:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=mail; bh=CyX6 FA9LMcIgOJIZ9KVXRRiNi8w=; b=CrD+Ip0NZMLfF17rgYAedAkVjF++e2NtoU9p 2QEJhO1sb4uWnB23fsmozriXbdansVqwaQaJDQkfPQOZqpTlEy/VL+fOXdf6fdA6 Sp6WCNHrVz+3kMdwZh4x8mRBOmCEkCNA9wzl1WGE+G5NNmO9cdTpKGSQJGnaiJeb hePNXaDvjtw0ggxXIGSJcPsmuz/GpQz53jifpo1YHehk6m13rVNiKP+IqkPOxG7J V63gSEZYpo73rw1gtROviT2OZiU1jKOUEfvSniGb00J2vu0td+htJlgXCAkC9VTt ELCveQI/Z1Xsg2LTt1bDL3BSLUJYk37FPDdOPvOC1ByPznMLZA== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 6270381a (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Tue, 17 Oct 2017 18:31:35 +0000 (UTC) From: "Jason A. Donenfeld" To: Johannes Berg , David Miller , netdev@vger.kernel.org, linux-wireless@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH] mac80211: use constant time comparison with keys Date: Tue, 17 Oct 2017 20:32:07 +0200 Message-Id: <20171017183207.23124-1-Jason@zx2c4.com> In-Reply-To: References: 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 Otherwise we risk leaking information via timing side channel. Fixes: fdf7cb4185b6 ("mac80211: accept key reinstall without changing anything") Signed-off-by: Jason A. Donenfeld --- net/mac80211/key.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mac80211/key.c b/net/mac80211/key.c index ae995c8480db..035d16fe926e 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "ieee80211_i.h" #include "driver-ops.h" @@ -635,7 +636,7 @@ int ieee80211_key_link(struct ieee80211_key *key, * new version of the key to avoid nonce reuse or replay issues. */ if (old_key && key->conf.keylen == old_key->conf.keylen && - !memcmp(key->conf.key, old_key->conf.key, key->conf.keylen)) { + !crypto_memneq(key->conf.key, old_key->conf.key, key->conf.keylen)) { ieee80211_key_free_unused(key); ret = 0; goto out;