From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C1B4C433EF for ; Wed, 4 May 2022 08:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651654666; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=EXlV8qXzZbyjGbftLaRnXenoc6bxA3t+g284ckKA+gA=; b=OWBvPYt8+QV3f8X+2cLy2oDWsLr444xTXtYhrHmtOXsH3MXJ2V3vJFOLXkgHTDdNmJ52mF fiI+/JLUwonqTcxWfqH4e30YsrQI6+DPLqSTp1ISz2UfFOSb76YmdjYN8diEcMNn6YwvMK ml6COMzYUiJzIkm9NcZ4ALJmukRhhqw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-163-hMN2H7W8PT2xTvai9OetrA-1; Wed, 04 May 2022 04:57:43 -0400 X-MC-Unique: hMN2H7W8PT2xTvai9OetrA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE43F3810782; Wed, 4 May 2022 08:57:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D63E4403D195; Wed, 4 May 2022 08:57:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7D1741947043; Wed, 4 May 2022 08:57:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8E5761947040 for ; Wed, 4 May 2022 08:57:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6FAC9403D18E; Wed, 4 May 2022 08:57:37 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6EB0B4010E21; Wed, 4 May 2022 08:57:36 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 2448va6o023376; Wed, 4 May 2022 04:57:36 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 2448vZ0c023372; Wed, 4 May 2022 04:57:35 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 4 May 2022 04:57:35 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Stafford Horne In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Subject: Re: [dm-devel] [PATCH v2] hex2bin: make the function hex_to_bin constant-time X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Shevchenko , Mike Snitzer , Herbert Xu , Linux Kernel Mailing List , Mimi Zohar , Milan Broz , device-mapper development , Linux Crypto Mailing List , Jason@zx2c4.com, Linus Torvalds , "David S. Miller" Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed, 4 May 2022, Stafford Horne wrote: > On Mon, Apr 25, 2022 at 08:07:48AM -0400, Mikulas Patocka wrote: > > > From: Mikulas Patocka > > > > -int hex_to_bin(char ch) > > +int hex_to_bin(unsigned char ch) > > { > > - if ((ch >= '0') && (ch <= '9')) > > - return ch - '0'; > > - ch = tolower(ch); > > - if ((ch >= 'a') && (ch <= 'f')) > > - return ch - 'a' + 10; > > - return -1; > > + unsigned char cu = ch & 0xdf; > > + return -1 + > > + ((ch - '0' + 1) & (unsigned)((ch - '9' - 1) & ('0' - 1 - ch)) >> 8) + > > + ((cu - 'A' + 11) & (unsigned)((cu - 'F' - 1) & ('A' - 1 - cu)) >> 8); > > } > > EXPORT_SYMBOL(hex_to_bin); > > Hello, > > Just a heads up it seems this patch is causing some instability with crypto self > tests on OpenRISC when using a PREEMPT kernel (no SMP). > > This was reported by Jason A. Donenfeld as it came up in wireguard testing. > > I am trying to figure out if this is an OpenRISC PREEMPT issue or something > else. Hi That patch is so simple that I can't imagine how could it break the curve25519 test. Are you sure that you bisected it correctly? Mikulas -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACD42C433F5 for ; Wed, 4 May 2022 08:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346881AbiEDJCH (ORCPT ); Wed, 4 May 2022 05:02:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347219AbiEDJCA (ORCPT ); Wed, 4 May 2022 05:02:00 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B761225298 for ; Wed, 4 May 2022 01:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651654661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fvXq2I6YdSSqQfmfOGxLM58nh3ANCa3aK4uOGFmwSCU=; b=holUDCOAfKFsn3LNkle9Cj2MB/qb5+kJU9WTHX+ZBIj4Vc4YSOl+GOZgbtJvtcgx7yauJl kdKKel2jqGe8g1AM24ueOiFJ1Pcnu6dKBvvLdPR76QbibJ+8+v+dXgKkU1w7LObRyRUY2t DcQ/Rtz4puSaHOYJj9dLhsALYrGJzac= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-542-6GjmA59aOUmzLHgsh8KXYA-1; Wed, 04 May 2022 04:57:38 -0400 X-MC-Unique: 6GjmA59aOUmzLHgsh8KXYA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 705533C02B61; Wed, 4 May 2022 08:57:37 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6EB0B4010E21; Wed, 4 May 2022 08:57:36 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 2448va6o023376; Wed, 4 May 2022 04:57:36 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 2448vZ0c023372; Wed, 4 May 2022 04:57:35 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 4 May 2022 04:57:35 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Stafford Horne cc: Linus Torvalds , Andy Shevchenko , device-mapper development , Linux Kernel Mailing List , Linux Crypto Mailing List , Herbert Xu , "David S. Miller" , Mike Snitzer , Mimi Zohar , Milan Broz , Jason@zx2c4.com Subject: Re: [PATCH v2] hex2bin: make the function hex_to_bin constant-time In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, 4 May 2022, Stafford Horne wrote: > On Mon, Apr 25, 2022 at 08:07:48AM -0400, Mikulas Patocka wrote: > > > From: Mikulas Patocka > > > > -int hex_to_bin(char ch) > > +int hex_to_bin(unsigned char ch) > > { > > - if ((ch >= '0') && (ch <= '9')) > > - return ch - '0'; > > - ch = tolower(ch); > > - if ((ch >= 'a') && (ch <= 'f')) > > - return ch - 'a' + 10; > > - return -1; > > + unsigned char cu = ch & 0xdf; > > + return -1 + > > + ((ch - '0' + 1) & (unsigned)((ch - '9' - 1) & ('0' - 1 - ch)) >> 8) + > > + ((cu - 'A' + 11) & (unsigned)((cu - 'F' - 1) & ('A' - 1 - cu)) >> 8); > > } > > EXPORT_SYMBOL(hex_to_bin); > > Hello, > > Just a heads up it seems this patch is causing some instability with crypto self > tests on OpenRISC when using a PREEMPT kernel (no SMP). > > This was reported by Jason A. Donenfeld as it came up in wireguard testing. > > I am trying to figure out if this is an OpenRISC PREEMPT issue or something > else. Hi That patch is so simple that I can't imagine how could it break the curve25519 test. Are you sure that you bisected it correctly? Mikulas