Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751257AbeADXdD (ORCPT + 1 other); Thu, 4 Jan 2018 18:33:03 -0500 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:49928 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbeADXdC (ORCPT ); Thu, 4 Jan 2018 18:33:02 -0500 Date: Fri, 5 Jan 2018 00:33:00 +0100 From: Pavel Machek To: Dan Williams Cc: Julia Lawall , Alan Cox , Linus Torvalds , Linux Kernel Mailing List , Mark Rutland , linux-arch@vger.kernel.org, Peter Zijlstra , Greg KH , Thomas Gleixner , Elena Reshetova , Alan Cox , Dan Carpenter Subject: Re: [RFC PATCH] asm/generic: introduce if_nospec and nospec_barrier Message-ID: <20180104233259.GA24680@amd> References: <151502463248.33513.5960736946233335087.stgit@dwillia2-desk3.amr.corp.intel.com> <20180104010754.22ca6a74@alans-desktop> <20180104192648.GA10427@amd> <20180104224455.GA22369@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="MGYHOYXEY6WxJCY8" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: --MGYHOYXEY6WxJCY8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > > What did it leak? Nothing. Attacker had to know > > array+attacker_controlled_index, and he now knows > > (array+attacker_controlled_index)%CACHELINE_SIZE. > > > > With (void) array2[val];, the attack gets interesting -- I now know > > *(array+attacker_controlled_index) % CACHELINE_SIZE ... allowing me to > > get information from arbitrary place in memory -- which is useful for > > .. reading ssh keys, for example. >=20 > Right, but how far away from "val =3D array[attacker_controlled_index];" > in the instruction stream do you need to look before you're > comfortable there's no 'val' dependent reads in the speculation window > on all possible architectures. Until we have variable annotations and > compiler help my guess is that static analysis has an easier time > pointing us to the first potentially bad speculative access. Well, you are already scanning for if (attacker_controlled_index < limit) .... array[attacker_controlled_index] and those can already be far away from each other.... Anyway, likely in the end human should be creating the patch, and if there's no array2[val], we do not need the patch after all. Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --MGYHOYXEY6WxJCY8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlpOuasACgkQMOfwapXb+vJ3CwCdE0uzmPXT1L+DQcMFtkSoZC3L OlMAoL/rdluf4+hii/KvspigMtaaz9rY =Uz4A -----END PGP SIGNATURE----- --MGYHOYXEY6WxJCY8--