Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp649379rwi; Thu, 27 Oct 2022 06:07:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4SFeniDw/AyP20WGSXwUN4w3pzUJCBh11tRLIcKQx8NeE0J+vWsdPb+4/7/4TYmMSVfalS X-Received: by 2002:a17:902:ecc2:b0:181:b55a:f954 with SMTP id a2-20020a170902ecc200b00181b55af954mr48833191plh.32.1666876061725; Thu, 27 Oct 2022 06:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666876061; cv=none; d=google.com; s=arc-20160816; b=D+VRRtwIPDxdXcVzjy2+eZ/mYuEZZXBAfW16HyO6UK+Nc3e9viH03Yl5JKHThOJO5y TRHcLGzP9nSVVMrOKTfmDwC4PMxomsQWCVvX2SBNWz+rFpCBSdSK4GShpEgGQv8sdYwJ +XosrG92fWL1lSxENnAr2Cgse4PbV/cdzFnMPjrx4IYYsqQrdfnXgkUM8UAjxDzLwMzr nPk8z4bEvFNmsKs/yFs8ON1bqa4TjZN4r6zFFXQTDXQ33tyzp4Q91evg+za+zg15M4sU hRO+variKkfisc6Cq74KBpj9DtWvCjT6MbVx7Pt4XSIWgHMOvFUChKC/L2zt1SOAsqpV j09A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pj9a76Gy5EIhvCgh1tn+VtUpUQsCC06v3G1EotgJVMo=; b=CZdF2hE5I5XCEalrVq1d+xEKjWKKt0yJjuE03gYrdNB/7O9kU03Fx8pyv6A6FJQIiK x2hLXLn6tZbylbpyRRP+J6KWhhdknmkrM0YZLszSH43/QA/WCYMzJg9h7+ExU+8JGz6G M/eEG12JXUTypjGT5lYNoh/iRXdLkC72nwqpVKc0+uOCrQs8QyHQpwI0HQ2JgxsPJRF0 TCxhI+8zi+zDpMbL8vbwhkOhKRL52EE9nR19By9Z3TNojNLTbH3ixgD379VNCE5QQkrV BYsrqwmoNRa0L69xzKuIT7NdTPb2ddVHmEUP/bCKayQz2FF59wrDenU8HebpZJPlQr7/ vbtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=LkTirsK8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q4-20020a635044000000b0043bd8458031si1821907pgl.435.2022.10.27.06.07.28; Thu, 27 Oct 2022 06:07:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=LkTirsK8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234105AbiJ0MlF (ORCPT + 99 others); Thu, 27 Oct 2022 08:41:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235731AbiJ0Mkp (ORCPT ); Thu, 27 Oct 2022 08:40:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29BDE50FAF for ; Thu, 27 Oct 2022 05:40:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A1F43622CE for ; Thu, 27 Oct 2022 12:40:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1C13C433C1; Thu, 27 Oct 2022 12:40:37 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="LkTirsK8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1666874436; 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=pj9a76Gy5EIhvCgh1tn+VtUpUQsCC06v3G1EotgJVMo=; b=LkTirsK8nmkzFwQL0kKsg47ZKNB1kGianxNTTV0XlcMhv3oFXN4E9GwBAO5Z/MviCdXvVh J1bpLikrl1KoUR86EsLopow+WagD0UVWMMYmpZAXpgzlvu5v8igNbCtkeML1nCtpvAogGC WzLLRTcssPa6c/TnUdoggNsU8VAMl1A= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 51af9fd4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 27 Oct 2022 12:40:35 +0000 (UTC) Date: Thu, 27 Oct 2022 14:40:14 +0200 From: "Jason A. Donenfeld" To: Mark Rutland Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Marc Zyngier , Eric Biggers , Kees Cook , Suzuki K Poulose , Adam Langley , James Morse Subject: Re: [RFC PATCH] arm64: Enable data independent timing (DIT) in the kernel Message-ID: References: <20221027112741.1678057-1-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 27, 2022 at 01:12:16PM +0100, Mark Rutland wrote: > I appreciate this is a simple way to rule out issues of that sort, but I think > the "may" in that sentence is doing a lot of work, since: > > * IIUC, we don't have a specific case in mind that we're concerned about. I can > believe that we think all the crypto code we intend to be constant time is > theoretically affected. > > * IIUC we haven't gone an audited all constant-time code to check it doesn't > happen to use instructions with data-dependent-timing. So there might be more > work to do atop this to ensure theoretical correctness. > > * AFAIK there are no contemporary implementations where the DIT is both > implemented and it being clear results in data-dependent-timing. i.e. we have > nothing to actually test on. > > I have a slight fear that (as above) if there are future CPUs which do consider > DIT, there's presumably a noticeable performance difference (or the CPU would > just provide data-independent-timing regardless), but I'm not sure if that's > just something we have to live with or could punt on until we notice such > cases. You're heading on a road to disaster reasoning like that. You wrote, "we don't have a specific case in mind that we're concerned about", but actually, all you can say here is that you're not personally aware of a specific case in mind to be concerned about. As somebody who actually works on this code, I do have specific cases I'm worried about, and I know there are certain assumptions I've made about various coding patterns being CT, resulting in various instructions that I assume to be CT, which is something I tend to check by hand, while others have entire frameworks to automatically verify this kind of thing. In other words, one man's theory is another man's practice. Then you write that there aren't any contemporary instructions where this matters, but you fear they could come up in the future. Okay, good, that's a perspective we can both share. The logical thing to do about that would be Ard's patch here. However, you then conclude something vague about performance and suggest punting this down the road. I guess this makes sense to you because you don't think timing attacks are real anyway. You're entitled to your opinion, of course, but I don't think it's a popular one, and it certainly is contrary to that of most implementers of the concerned code. On the contrary, we should be proactive in ensuring the kernel remains a suitable environment for CT code, preventing the problem *before* it happens, rather than having to deal with vulnerability response down the road, "punt[ing]" it, as you said. And perhaps if we handle this now, CPU designers also won't feel like they can get away with silly performance gains at the cost of CT instructions. Jason