From patchwork Tue Nov 29 13:05:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 84795 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1585611qgi; Tue, 29 Nov 2016 05:05:59 -0800 (PST) X-Received: by 10.99.129.200 with SMTP id t191mr48444400pgd.180.1480424758962; Tue, 29 Nov 2016 05:05:58 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si59873107pfe.68.2016.11.29.05.05.58; Tue, 29 Nov 2016 05:05:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933398AbcK2NFm (ORCPT + 1 other); Tue, 29 Nov 2016 08:05:42 -0500 Received: from mail-wj0-f170.google.com ([209.85.210.170]:36612 "EHLO mail-wj0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933366AbcK2NFm (ORCPT ); Tue, 29 Nov 2016 08:05:42 -0500 Received: by mail-wj0-f170.google.com with SMTP id qp4so144596140wjc.3 for ; Tue, 29 Nov 2016 05:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v4CpNEERH1ak/GI2ZKQMOE/GAcgUUTQ5bJ5lL/HYUbA=; b=Sv4mNHmMhwxqmtF+WEa8JD6TN30izhRx//EzuDzudbFl18T/sIwByZQB7Z7nfQCzEx f+XKn0KtoJ5S9hxKs2NJIF39TdNEnW18bYX7cA8tZhuXxvQwJ96/6dfmtWwNy5qtJ9z6 PfF8RgCYpG3W10oscbIkT399Cp1aSgv8mO7b8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v4CpNEERH1ak/GI2ZKQMOE/GAcgUUTQ5bJ5lL/HYUbA=; b=LvK9rqzMhIGWS2jMghoe7cgDNEyyjFGnjeQgwMc+GsTzQhjzZkVJ7O7YT1UczQAIhf dqHHixOh7vc/ChAAMEkU1D8YbK9+59DKHU3kJcEvLg8RVAZGwmEQfRjqtvZGhtIFUIyE e4EOih1ashXlRaodtTyqRuDSe+UR+ZZwhbuJbaJI91Ylg/77DKFZZ5gX+FDPhvlBiFrE GVls/yTirB6POgSjkRAhlG5nkbb19WxEo8qbuTlzw+CoSDOe0VDdPTbhiINuyIfy890i A4dvx5gJxJboEtnhvXIIK0h5H3KLkOawexHRer2IEEqiEQR/it4taVeRzI1cAjrW+FXh Vkeg== X-Gm-Message-State: AKaTC02CIaQHvltRzvLjO2Qk/HZ8PwQY5/106G8yS+d28SBOyoFW8bDrZOCCc3FbIInzo7cd X-Received: by 10.194.221.4 with SMTP id qa4mr27430322wjc.179.1480424740576; Tue, 29 Nov 2016 05:05:40 -0800 (PST) Received: from localhost.localdomain ([105.138.199.36]) by smtp.gmail.com with ESMTPSA id n5sm2749312wmf.0.2016.11.29.05.05.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Nov 2016 05:05:39 -0800 (PST) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel Subject: [PATCH 2/4] crypto: skcipher - fix crash in skcipher_walk_aead() Date: Tue, 29 Nov 2016 13:05:31 +0000 Message-Id: <1480424733-10797-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480424733-10797-1-git-send-email-ard.biesheuvel@linaro.org> References: <1480424733-10797-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The new skcipher_walk_aead() may crash in the following way due to the walk flag SKCIPHER_WALK_PHYS not being cleared at the start of the walk: Unable to handle kernel NULL pointer dereference at virtual address 00000001 [..] Internal error: Oops: 96000044 [#1] PREEMPT SMP [..] PC is at skcipher_walk_next+0x208/0x450 LR is at skcipher_walk_next+0x1e4/0x450 pc : [] lr : [] pstate: 40000045 sp : ffffb925fa517940 [...] [] skcipher_walk_next+0x208/0x450 [] skcipher_walk_first+0x54/0x148 [] skcipher_walk_aead+0xd4/0x108 [] ccm_encrypt+0x68/0x158 So clear the flag at the appropriate time. Signed-off-by: Ard Biesheuvel --- crypto/skcipher.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/crypto/skcipher.c b/crypto/skcipher.c index 0f3071991b13..5367f817b40e 100644 --- a/crypto/skcipher.c +++ b/crypto/skcipher.c @@ -506,6 +506,8 @@ int skcipher_walk_aead(struct skcipher_walk *walk, struct aead_request *req, struct crypto_aead *tfm = crypto_aead_reqtfm(req); int err; + walk->flags &= ~SKCIPHER_WALK_PHYS; + scatterwalk_start(&walk->in, req->src); scatterwalk_start(&walk->out, req->dst);