From patchwork Thu Jan 12 13:33:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 91152 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1916613obz; Thu, 12 Jan 2017 05:33:46 -0800 (PST) X-Received: by 10.84.241.66 with SMTP id u2mr21904117plm.107.1484228026628; Thu, 12 Jan 2017 05:33:46 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e28si9285676plj.316.2017.01.12.05.33.46; Thu, 12 Jan 2017 05:33:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@benyossef-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750981AbdALNdo (ORCPT + 5 others); Thu, 12 Jan 2017 08:33:44 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34029 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750755AbdALNdn (ORCPT ); Thu, 12 Jan 2017 08:33:43 -0500 Received: by mail-lf0-f68.google.com with SMTP id q89so1828680lfi.1 for ; Thu, 12 Jan 2017 05:33:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benyossef-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=UQj6EBtMliTxnMhbxQqpkc0cEQlO2SywhIH54IIlKJE=; b=Qy5EqL0pDRZeiI8vVx7MqAd0SixnkY41w9RxlUD5CDvE/wYWnv+y38/8nPHaqFbm+O ihrXu11akx7wgIv0jo7JisDR3JWT1pBGJZuxypw0rAIaHHv3Asn7Ih6O12OszJBojs6j CvqtT4AUJpQjYMcKl/1Gp9uTEIuVHrTQm/tppN46aQO20UcwT1Ivl970nTotpHGHUg0p otvHEwl5V8EYhEkVwy3COu9WAafa/eFCGrfHVNiKqfAyTXq4/m2NCjCMrZ4K3S0qA/q1 NjwzJBWXFAF7TwCTR1fwYLB2qWjYIZoD3blFH9J3guwxtsxXMHSgFS+gR0Ev4FlKoJKl uVyQ== 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; bh=UQj6EBtMliTxnMhbxQqpkc0cEQlO2SywhIH54IIlKJE=; b=MzzhcQMFyN5yK+wz84TZku2oo3EsWZL0wiKkNRuVuP+W8ZDTSSrA51D+n4ZO+Fpq2j Tlxf7xKMnBAQbGygs3w7L0rDTGW0f5qW/qfbzKXwplMsk96Y/pnP5UOVN0bWaHx8phzd yIUSSbcegNg/rsd+HIwjtif2YkBm6MT0pmOpndcIgiN5wZRx/DddzXQJcsREcqDIpTCZ vMhTTHVQLJLx74P4oRdZnqifBhYG/nmyjJ/j3yjrWeRNMEryp6kcMkyJ5QJJybxLDIRb jDpyNQOTJP1iGsgLWyFauD6NGSGluiQ8eadnU4h38bcyykFnEd+OBTT9Y+zMpcFZuHI6 YA8w== X-Gm-Message-State: AIkVDXJXYJFPe7LMxlwJiDXAhfcXlvs42BR9tvT5aCVQJaE/bPXeJFEfSe6oOVBXtEah7w== X-Received: by 10.194.242.66 with SMTP id wo2mr8497298wjc.192.1484228021781; Thu, 12 Jan 2017 05:33:41 -0800 (PST) Received: from localhost.localdomain (bzq-82-81-71-2.red.bezeqint.net. [82.81.71.2]) by smtp.gmail.com with ESMTPSA id d10sm13640865wja.20.2017.01.12.05.33.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Jan 2017 05:33:40 -0800 (PST) From: Gilad Ben-Yossef To: steffen.klassert@secunet.com, herbert@gondor.apana.org.au, davem@davemloft.net, netdev@vger.kernel.org Cc: ofir.drang@arm.com, gilad.benyossef@arm.com, Gilad Ben-Yossef Subject: [PATCH net-next] IPsec: do not ignore crypto err in ah input Date: Thu, 12 Jan 2017 15:33:22 +0200 Message-Id: <1484228002-25078-1-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ah input processing uses the asynchrnous hash crypto API which supplies an error code as part of the operation completion but the error code was being ignored. Treat a crypto API error indication as a verification failure. While a crypto API reported error would almost certainly result in a memcpy of the digest failing anyway and thus the security risk seems minor, performing a memory compare on what might be uninitialized memory is wrong. Signed-off-by: Gilad Ben-Yossef --- The change was boot tested on Arm64 but I did not exercise the specific error code path in question. net/ipv4/ah4.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.1.4 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index f2a7102..22377c8 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c @@ -270,6 +270,9 @@ static void ah_input_done(struct crypto_async_request *base, int err) int ihl = ip_hdrlen(skb); int ah_hlen = (ah->hdrlen + 2) << 2; + if (err) + goto out; + work_iph = AH_SKB_CB(skb)->tmp; auth_data = ah_tmp_auth(work_iph, ihl); icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len);