[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/altcall: silence undue warning


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Tue, 1 Mar 2022 14:23:28 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4ObiUhpeQyuA1VDFdAzZ7biM4EWMeMxqTrJB4a4yTsA=; b=GfHzAxsrgnyzMoTD1DHGmgptAq5PTVbQnpWfJ7rzLlcgaP/rmhDsfqxVhwZX19ULjKzqaoSsX1XIkGA91Umape0ot0UqDCXNZ/gMtsufCsW5EwtG5Pcc0VCwSPfzlwqyfHni6gJria939q0xdzzhmRzr2st1wz0IG5z0TADoLpvmA2nqyKwQKWSmGwZ9pyaH27h+GHgnmtTrtYCvD63vsh/V6wzn8gHDyUVbEFov1llKeNRBQ/ESBG0GQO39VL2MW1wTThLQOUWi67WDGcF2o6Kt/8+RPbTnlgSb9hCbcbHiN2orFrdhdas62dYe02TWM1oeh5egEf3HGvzoBMG5pg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HNJhvVO02XFWh/WZepET+ULDebW+yJ23PkpJjXl0ib7t/9NgZbIrGDs5ulDdWAQy2ltFEoamPF3lRB9CdRi22bqKCuwms45vUeiSmk2FLKO9aUKQxifWaplI0RSgseEE+qEH0V2pKXUBxwHyKUztSlfJiHaWeV9dOXOTWmd1sWcLOEUFpvf6alvQ3ET6x2D2YFgsNtY0/IHdqMDe0r1gylqElSM5R8/0zadWilUz6Wo4/tF/Ja0tOdN/7h6cy9uKyESDrcR+92/1WIYDL4lLocwihtKVaFs0O5ASOoKUQjQd+zjLT34scmhgWAVrHmR1jJhvMQVPgTD2RCQBIyWG3A==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 01 Mar 2022 14:23:42 +0000
  • Ironport-data: A9a23:bmHkfq+YLqfsyhZhVSpoDrUDnX6TJUtcMsCJ2f8bNWPcYEJGY0x3x moYCmrTPviJZWCge48naY6x908Cup/QzdcxG1Rt+S88E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si+Fa+Sn9T8mvU2xbuKU5NTsY0idfic5DnZ54f5fs7Rh2NQw2oDgW1nlV e7a+KUzBnf0g1aYDUpMg06zgEsHUCPa4W5wUvQWPJinjXeG/5UnJMt3yZKZdhMUdrJ8DO+iL 9sv+Znilo/vE7XBPfv++lrzWhVirrc/pmFigFIOM0SpqkAqSiDfTs/XnRfTAKtao2zhojx/9 DlCncysVyNqGbLroec6XjN3CHxmEaQF6IaSdBBTseTLp6HHW37lwvEoB0AqJ4wIvO1wBAmi9 9RBdmpLNErawbvrnvTrEYGAhex6RCXvFKoZtmtt0nfyCvE+TIqYa67L+cVZzHE7gcUm8fP2O ZdHM2s1NUqojxtnEHxQAZgVs9iRuyO4djRhr3CkvqMu/D2GpOB2+Oe0a4eEEjCQfu1Fk0Ddq m/Y8mDRBhABKMfZ2TeD6mirhOLEgWX8Qo16PKK83u5nhhuU3GN7IB8cWEa/oPK5olWjQN8ZI EsRkhfCtoBrqhbtFIOkGUTl/jjU5XbwRua8DcVq9B+piY3LxD+aIWUuYSUccPAv998PEGlCO kCyo/vlAjlmsbuwQH2b96uJoT7aBRX5PVPudgdfE1JbvoCLTJUby0uWE409SPLdYsjdRGmoq w1muhTSkFn6YSQj86ygtW7KjDu3znQiZl5kv16HNo5JA+4QWWJEW2BKwQWDhRqjBNzAJrVkg JTis5LGhAzpJcvQ/BFhuM1XQNmUCw+taVUwe2JHEZg77CiK8HW+Z41W6zwWDB43bphcJmS3P BaK4FI5CHpv0J2CN/Qfj2WZUZlC8EQdPY69CqC8giRmOPCdizNrDAkxPBXNjggBYWAnkL0lO IfzTCpfJS1yNEiT9xLvH711+eZynkgWnDqPLbimn0XP+efPPxa9FOZaWGZim8hktctoVi2Oq I0BXyZLoj0CONDDjt7/qtZCfQhXdiFgXfgbaaV/L4a+H+avI0l4Y9f5yrI9YY112aNTk+bD5 HamXUFEjlH4gBX6xc+iNxiPtJuHsU5DkE8G
  • Ironport-hdrordr: A9a23:+vD6lqP9ksTr2sBcTuijsMiBIKoaSvp037B87TEIdfUzSL39qy nOpoV/6feX4Ax6ZJhEo7290ca7LU80maQb3WBzB8bBYOCFgguVxdpZnPLfKlTbckWUygc678 ldmsNFeb7N5DZB7PoTT2ODYq0dKHXsytHOuQ9+pU0dKz1XVw==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYLWCYr1nVwle0TEu9TqkN6fmfJ6yqeogAgAAMyICAAA3FAA==
  • Thread-topic: [PATCH] x86/altcall: silence undue warning

On 01/03/2022 13:34, Jan Beulich wrote:
> On 01.03.2022 13:48, Andrew Cooper wrote:
>> On 01/03/2022 11:36, Jan Beulich wrote:
>>> Suitable compiler options are passed only when the actual feature
>>> (XEN_IBT) is enabled, not when merely the compiler capability was found
>>> to be available.
>>>
>>> Fixes: 12e3410e071e ("x86/altcall: Check and optimise altcall targets")
>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> Hmm yes.  This is fallout from separating CONFIG_HAS_CC_CET_IBT and
>> CONFIG_XEN_IBT.
>>
>> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Thanks.
>
>>> ---
>>> Furthermore, is "Optimised away ..." really appropriate in what
>>> 37ed5da851b8 ("x86/altcall: Optimise away endbr64 instruction where
>>> possible") added? If this really was an optimization (rather than
>>> hardening), shouldn't we purge ENDBR also when !cpu_has_xen_ibt, and
>>> then ideally all of them? Whereas if this is mainly about hardening,
>>> wouldn't the message better say "Purged" or "Clobbered"?
>> I did have an RFC about this.  Turning ENDBR into NOP4 matters, on a
>> CET-IBT-active system, to restrict the available options an attacker has
>> when they have already managed to hijack a function pointer (i.e.
>> already got a partial write gadget).
>>
>> From that point of view, it is hardening.
> But then you don't say whether there's any optimization aspect here.
> My question was really about the wording of that log message.

The optimisation aspect is direct branch target +4, because that is what
saves on decode bandwidth.

>
>> The first version of this logic was trying to use UD1 in the same way as
>> Linux does, to harden non-CET builds too, but that does depend on having
>> objtool so all direct branches can have their targets updated to miss
>> the UD1 instruction.
> I think it would be possible (but likely cumbersome) to arrange for
> this also without objtool.

It's only useful non-CET hardware to cross-check that things won't
explode when CET is enabled, due to mispositioned branches/etc.

An actual attacker on non-CET hardware would just adjust the function
pointer +4 to skip the UD1.

>> P.S. I'd still like to have "away %u of %u endbr64's".  It occurs to me
>> that now we have check-endbr64.sh, we could `wc -l` the $VALID file and
>> re-link this back in, but then we couldn't check the final objects.
> I was thinking about this wish of yours as well; I simply didn't know how
> important you view it to have this information.

The most useful piece of information is how many ENDBR64's remain,
because those denote the extent of the attackers ability to hijack
function pointers without suffering #CP.  Ideally, the number produced
at boot wants cross-checking with script which can take xen-syms,
calculate $VALID - $CF_CLOBBER and identify all the expected
runtime-active targets.

At the moment, I can guestimate based on knowing how many where disabled
at boot time, and how many were in the original build, but I don't
expect anyone else to know that an all-enabled build of Xen is ~1600
ENDBR64's.

~Andrew

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.