From patchwork Fri Nov 2 18:02:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Kartashev X-Patchwork-Id: 992482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="C/TE9g1S"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jUR8xOEG"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42mqhN5jSxzB4Y7 for ; Sat, 3 Nov 2018 05:04:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=96gV0Ypwtx24272PsshUZ4M8hkLz9oNHxJ02lmde9kI=; b=C/TE9g1SV4Z0Pre/eRxXiTwUcV beJvcp8QWS+fC7ohWlcRKn7oyvvnHeVCdMN4xDlQC01iBTn1ShqhhOMuGMGRyeT51KTa56ZpXBsbW VJat3MZOuE6CaLUbGv7J+dFtK78y6znR9TY0IpOFdlN7lqXu1VB4F2il6p7A19jwhhBLfylIxMiab nRQuA2cYwfY650hpkiTp+LOdC5HNpPg3qvZrO05/FzQQuiF8P3qDXegOiwqsI8OuSwhOn5XtQm19/ ph3ThL1A76HekbZIbn7l/dbl3RHVvgYPCsht1mNLDNOAVmPfc03cnote6F3/8uH1E+NSSivCsMrVv 0QDvllbQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gIdnN-00036w-9o; Fri, 02 Nov 2018 18:03:45 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gIdmv-0002Wv-EP for hostap@lists.infradead.org; Fri, 02 Nov 2018 18:03:18 +0000 Received: by mail-lj1-x241.google.com with SMTP id x3-v6so2471267lji.13 for ; Fri, 02 Nov 2018 11:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i4X0YItwhT4M0DsrxJS8ZvhyJI+70fcWFwICkPbzDi8=; b=jUR8xOEGTXVQjJ/FpUqvXyjQBbT8WQx4rdFOpxz50V/R3/pJRvZ1u2YNV8bk82lqWl UnG8l7b7Bs13Bh1bZc+HosjdTtvMAVH3cXEQegPPg0stntq43PvkTUmmWDld6V55c8hb 4Xwyv8JuXiJb0C2W/uF+rrgdtdlfHaaIgUhNzSEKHfcktG4dRNxkPE4hBaUl5UWclw/o zuSFmJSrSAEgrkJJwa2jUrRzhp4F1WxfD+5VH9rO+XMn4R7gM595jgG26wSf/WZJgRa0 YHtjd2AzMOPtyZ6q2T3HECFJ7WxtkFXONNksbByP15/JZrntKqUnhB01X9NZC3zFnBtA dspg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i4X0YItwhT4M0DsrxJS8ZvhyJI+70fcWFwICkPbzDi8=; b=c0prb2E7ogY4drT1U+2cDowTI1GNGV77VZpL7gUBqUofyTnJruq/GBt80l0nu6NYZI E695X0ZM8f2j3VpSQfh955Wym4f6Rmtgo/HaKMbsgIIHBQ5/yXCCY7woa7UhzqSqpIw4 P28gU7LBhj0Tm98dIY3H2GKY5KROKwQdzc1yp6GcyxhZ0VTpJRIL2E7couYLuyJpf402 5wepk8Cy7KBmS8uy2yB6Vc9B0y8rPHpmvsWwjp7jw0xTx/0i09K5t8rRfbH4aByurQsU N5IMaTM4JOFQ9l7G0DDCDdM9QOzaPQbb23L6RYKQEqxweFxOYh/+zT7EqVnDvTHNKG0Z LF1Q== X-Gm-Message-State: AGRZ1gIZ9wbZTpMH2xaveFPQbXT/WNULpvVH7CZ5KrWOeRJt7h3XHtRT dKiS2pSu9639M7qI+TuZLxtAnNhG X-Google-Smtp-Source: AJdET5eSpj1YmS4Q0w9Ldoli592krAWC3qJszV5MKx+zQe7P4k+T3YSrsKoGd7NP1CmO/Z3hbkpauw== X-Received: by 2002:a2e:8e89:: with SMTP id z9-v6mr3833861ljk.126.1541181785101; Fri, 02 Nov 2018 11:03:05 -0700 (PDT) Received: from localhost.localdomain ([194.103.244.100]) by smtp.gmail.com with ESMTPSA id a9sm1002595lfa.19.2018.11.02.11.03.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 11:03:04 -0700 (PDT) From: Andrey Kartashev To: hostap@lists.infradead.org Subject: [PATCH 4/8] mka: Check for errors on create Secure Channel Date: Fri, 2 Nov 2018 19:02:16 +0100 Message-Id: <20181102180220.20948-4-a.s.kartashev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181102180220.20948-1-a.s.kartashev@gmail.com> References: <20181102180220.20948-1-a.s.kartashev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181102_110317_481200_1867E7F5 X-CRM114-Status: GOOD ( 14.41 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (a.s.kartashev[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrey Kartashev MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Andrey Kartashev It is possible that driver fails to create Secure Channel (due to hardware limitations for example). This patch adds check of create_*_sc result code and breaks procedure in case of fail. Also this patch fix minor memory leak in ieee802_1x_kay_create_mka() in case of derive KEK/ICK fail. Signed-off-by: Andrey Kartashev --- src/pae/ieee802_1x_kay.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c index e508b38de..6703531e4 100644 --- a/src/pae/ieee802_1x_kay.c +++ b/src/pae/ieee802_1x_kay.c @@ -601,9 +601,14 @@ ieee802_1x_kay_create_live_peer(struct ieee802_1x_mka_participant *participant, return NULL; } + if (secy_create_receive_sc(participant->kay, rxsc)) + { + os_free(rxsc); + os_free(peer); + return NULL; + } dl_list_add(&participant->live_peers, &peer->list); dl_list_add(&participant->rxsc_list, &rxsc->list); - secy_create_receive_sc(participant->kay, rxsc); wpa_printf(MSG_DEBUG, "KaY: Live peer created"); ieee802_1x_kay_dump_peer(peer); @@ -661,10 +666,16 @@ ieee802_1x_kay_move_live_peer(struct ieee802_1x_mka_participant *participant, ieee802_1x_kay_dump_peer(peer); dl_list_del(&peer->list); + if (secy_create_receive_sc(participant->kay, rxsc)) + { + wpa_printf(MSG_ERROR, "KaY: Can't create SC, discard peer"); + os_free(rxsc); + os_free(peer); + return NULL; + } dl_list_add_tail(&participant->live_peers, &peer->list); dl_list_add(&participant->rxsc_list, &rxsc->list); - secy_create_receive_sc(participant->kay, rxsc); return peer; } @@ -3381,7 +3392,8 @@ ieee802_1x_kay_create_mka(struct ieee802_1x_kay *kay, secy_cp_control_protect_frames(kay, kay->macsec_protect); secy_cp_control_replay(kay, kay->macsec_replay_protect, kay->macsec_replay_window); - secy_create_transmit_sc(kay, participant->txsc); + if (secy_create_transmit_sc(kay, participant->txsc)) + goto fail; /* to derive KEK from CAK and CKN */ participant->kek.len = mka_alg_tbl[kay->mka_algindex].kek_len; @@ -3429,6 +3441,7 @@ ieee802_1x_kay_create_mka(struct ieee802_1x_kay *kay, return participant; fail: + os_free(participant->txsc); os_free(participant); return NULL; }