From patchwork Sun Sep 30 19:51:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10621471 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12A07A6A for ; Sun, 30 Sep 2018 19:51:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E80A2290B1 for ; Sun, 30 Sep 2018 19:51:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D80FC291C1; Sun, 30 Sep 2018 19:51:27 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 7D35D290B1 for ; Sun, 30 Sep 2018 19:51:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728509AbeJACZp (ORCPT ); Sun, 30 Sep 2018 22:25:45 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37030 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728507AbeJACZp (ORCPT ); Sun, 30 Sep 2018 22:25:45 -0400 Received: by mail-wr1-f65.google.com with SMTP id u12-v6so11487356wrr.4 for ; Sun, 30 Sep 2018 12:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Ngo5slU+TD8pvrgy5iT3tSDW4YaXasb5LD684v8luYY=; b=e7Vi37EdeS5O2sGBAVd1xdShaY1J7R2OahEX+cKvghetxg7vZhmZbllS/Py76AVEEG 7uiRJr6FGGZM9CydSN08mz13ua3/om4hTT+NmGNP/AJINmuwyNIr1F2c2rh0ca01n/+i vRUCr1sXQ/0slolZeyGcg4VjW4NsHvizQnXGA= 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=Ngo5slU+TD8pvrgy5iT3tSDW4YaXasb5LD684v8luYY=; b=e95eh7v0FGPSjlH8SP0O7FHQbukBT2EUkkO98F3GDUVVZYU/3EkeGefRP4gH9L/kbg C4TN0K8z5GsWfHIvSF9yQLGgkTKXOZFEApjU3bxDogupE7dwfxnYcGx+ZriYy1HBEy3s i4UXarUIWLyjvJ05mnGOv8TMOKPyI/QSgT0jJqIMiC1TL5ONEAvXsfrNg9AuC+fQIkWL dVstwyi+2RYOm1DlVv/lqcjmoZNrilK7sWfg92823oXZJms0mH6QNuZM4HN6kwlKRqRr 5s3VYdC6dWsChJOe9LeZp/XNZGFOkKKjNrwq0VDjU9MmxrZQP4nct0DT2MzNVzAVdwOc 7g6g== X-Gm-Message-State: ABuFfojWml9QXMGfds/aPrIHZpqFXVyI4Iwh+CSYFqkJKMi6n0cp5COP ig76b2Qvlc3sEk5j7RWHm4dVV8PdzC4= X-Google-Smtp-Source: ACcGV62TPSS2Ixm/NPlaoYvdPVUYolX2Ix8gxkqduaDEPZ9ED/AXnRyRrpiXCB1nZqXGNpzBx7KqBQ== X-Received: by 2002:a5d:6a11:: with SMTP id m17-v6mr292589wru.192.1538337084588; Sun, 30 Sep 2018 12:51:24 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:6d26:fb49:4a42:a358]) by smtp.gmail.com with ESMTPSA id j133-v6sm9027783wmd.12.2018.09.30.12.51.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Sep 2018 12:51:23 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, ebiggers@google.com, omosnace@redhat.com, Ard Biesheuvel Subject: [PATCH] crypto: lrw - fix rebase error after out of bounds fix Date: Sun, 30 Sep 2018 21:51:16 +0200 Message-Id: <20180930195116.31658-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Due to an unfortunate interaction between commit fbe1a850b3b1 ("crypto: lrw - Fix out-of bounds access on counter overflow") and commit c778f96bf347 ("crypto: lrw - Optimize tweak computation"), we ended up with a version of next_index() that always returns 127. Fixes: c778f96bf347 ("crypto: lrw - Optimize tweak computation") Signed-off-by: Ard Biesheuvel Reviewed-by: Ondrej Mosnacek --- crypto/lrw.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crypto/lrw.c b/crypto/lrw.c index 6fcf0d431185..0430ccd08728 100644 --- a/crypto/lrw.c +++ b/crypto/lrw.c @@ -122,10 +122,9 @@ static int next_index(u32 *counter) int i, res = 0; for (i = 0; i < 4; i++) { - if (counter[i] + 1 != 0) { - res += ffz(counter[i]++); - break; - } + if (counter[i] + 1 != 0) + return res + ffz(counter[i]++); + counter[i] = 0; res += 32; }