From patchwork Sun Jan 15 06:09:43 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: 91524 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp890862qgi; Sat, 14 Jan 2017 22:10:08 -0800 (PST) X-Received: by 10.98.10.198 with SMTP id 67mr31464180pfk.157.1484460608004; Sat, 14 Jan 2017 22:10:08 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 193si5767821pgb.330.2017.01.14.22.10.07; Sat, 14 Jan 2017 22:10:07 -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 S1750772AbdAOGJy (ORCPT + 5 others); Sun, 15 Jan 2017 01:09:54 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35041 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750718AbdAOGJx (ORCPT ); Sun, 15 Jan 2017 01:09:53 -0500 Received: by mail-wm0-f67.google.com with SMTP id d140so5840065wmd.2 for ; Sat, 14 Jan 2017 22:09:53 -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=d7rUkGPXqnDn2Q1LReclQU3wly31IlxZH+Y3YIKZFPs=; b=UrQLFi9IczYOz+x1P2AgYMQM6HDN2WWoRPR8xq+vPAZEXtD/df0HTDMYzVly7fQeyX WPI0qjzmSVTt0pDSJAOydVKRvI5x8NKGiCSzpq5Tu8zet8WKq6FzXAQlL2FWsUA7RDKc Ih6qKzLEVzEo5PrmO+SSt2g/4RGNRSrCMRoJfQTPa3OYsLK3t1+ZHilC7Sva+UOMv6/9 uz8izhfLr31mgtkC3VpYd9CGr1XTugYloK2stS1fgv3GgoyPKeyze21+OlEE3/6GYya7 LQz3LnMxW4G8mx244GMmQMdLm74FahINDEeDQfMZK0qTqvMUywwFiqLaDmALN5L9LBNw hZhQ== 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=d7rUkGPXqnDn2Q1LReclQU3wly31IlxZH+Y3YIKZFPs=; b=mPcratDaIatJLn6JhaBJ3fsn0JM/WC+HHFFIdEHjHWB/Shk0krwonCWsTahgy/GduW vt1vQfLSm+G2zOgEx5v6OeRwM/cK7qF8+dBqVnXSIVmqDv00IoJDsJBC1wq3qM95iZCO qvZB6/jSYTWs7qi7RS/ojkXuhgbfG+9PqrpsxVQ+9A/vgUu0V+cqMaSQLoLMOiVcpirV ML7ldnneT7mT6suyzxGWbHE5UnbAYGIaAptCEoYBqqopAi1Doa9uvMMUaznUpRz2fnkN eWhQ6uMn8NKyWztPAPRAy7fgGpA3lFhvULNj7XrTrRSdcIRYEghO85vfjiPCbeXdwzlc shdA== X-Gm-Message-State: AIkVDXI22M+byHfFg8TKb5OPDlE2qW9JzGTO3Li9sLjfB8m0Jj1bNB7haC97oi2/Ke/s3A== X-Received: by 10.28.84.14 with SMTP id i14mr4372652wmb.51.1484460592224; Sat, 14 Jan 2017 22:09:52 -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 w18sm18191231wme.9.2017.01.14.22.09.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Jan 2017 22:09:51 -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 , Alexander Alemayhu Subject: [PATCH v2 net-next] IPsec: do not ignore crypto err in ah input Date: Sun, 15 Jan 2017 08:09:43 +0200 Message-Id: <1484460583-2303-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 asynchronous 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 memcmp 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 CC: Alexander Alemayhu --- The change was boot tested on Arm64 but I did not exercise the specific error code path in question. Changes from v1: - Fixed typo in patch description pointed out by Alexander 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);