/srv/irclogs.ubuntu.com/2022/03/18/#ubuntu-kernel.txt

SvenKieskehey there, someone here familiar with spectre_v2 attacks/mitigations? if I understand this report correctly it is not possible currently to allow virtualized guests on ubuntu 20.04. to take advantage of the IBRS mitigation? https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/192175407:42
ubottuLaunchpad bug 1921754 in qemu (Ubuntu Hirsute) "Add missing cpu feature bits in EPYC-Rome model" [Undecided, Fix Released]07:42
SvenKieskesorry, I meant 18.0407:44
cpaelzerah, I just wondered as it is fix released for focal and later07:44
cpaelzerThere are various ways to get newer virt stacks onto 18.04 like https://wiki.ubuntu.com/OpenStack/CloudArchive or https://launchpad.net/~canonical-server/+archive/ubuntu/server-backports - but at some point things start to show its age (and it isn't broken, just not able to use the speedup of the mitigation). And that also only on very recent chips as e.g. a bunch of -IBRS chips are even in bionic07:57
cpaelzerback in the day there was no reasonable backport as AMD also changed a lot of other structural things, maybe there is something nowadays and it would be good to re-evaluate07:57
cpaelzerI have not much time, but I see your bug update which is great to give this a new look07:59
tomreynisn't the issue there just that there is no EPYC-Rome CPU model for 18.04 (and thus no need to provide Epyc-Rome-IBRS either)?07:59
cpaelzeryeah, that is part of the truth tomreyn. But the follow up would be how would I IBRS on an EPYC* then?08:00
cpaelzerI'd need to have a look ...08:00
cpaelzerupstreams 2.11.2 stable tree also has only the intel IBRS models (we have that) and EPYC-IBPB (mind the characters, not the same) we have that as well08:03
tomreynHmm, apparently CVE-2017-5715 is generally non-mitigated on 18.04 amd64 with HWE (5.4.0-104-generic #118~18.04.1-Ubuntu). "cat /sys/devices/system/cpu/vulnerabilities/spectre_v2" reports "Mitigation: LFENCE, IBPB: conditional, STIBP: disabled, RSB filling" (on this Ryzen 7 1800X), so it seems the kernel has not been compiled with a retpoline-aware compiler08:22
ubottuSystems with microprocessors utilizing speculative execution and indirect branch prediction may allow unauthorized disclosure of information to an attacker with local user access via a side-channel analysis. <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5715>08:22
apwtomreyn, that would be supprising, i am relativly sure that bionic was current when spectre was first in the frame, and it got retpolines added.  i am fairly sure the kernel won't compile if retpoline is not available as it always builds those as alternatives.09:04
tomreynapw: do you have any means to check this on your end, or is there a good test i could do?09:06
tomreyni guess i could boot a current 18.04 installer iso09:07
apwtomreyn, a good question.  though i had the feeling that we don't expect retpoline turned on in the default case do we?  where you have ibrs it is assume good enough if you have user-bpf turned off.  but if you are more paranoid you can select ibrs+retpoline09:08
apwas no other gadgets are known but that does not mean they are not present.09:09
tomreyni don't have IBRS either, though, just LFENCE09:10
apwyeah sorry, lfence+retpoline for amd09:11
tomreynapw: a Debian 11.2 running Linux 5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18) x86_64 (on EPYC 7351P) *does* have "Mitigation: Full AMD retpoline, IBPB: conditional, STIBP: disabled, RSB filling"09:17
tomreynso i was assuming ubuntu would default to this as well09:17
tomreynnewer kernel there, though, different cpu (though roughly the same generation)09:18
apwtomreyn, you can tell if it is availble by selecting spectre_v2=retpoline,lfence by my reading.09:18
apwtomreyn, the CVE you quote there is the original spectre issue, and that is mean to be mitigated by just lfence, right?  obviously time has moved on and the new issues exposed by CVE-2022-0001 change the equation for some people.09:22
ubottuNon-transparent sharing of branch predictor selectors between contexts in some Intel(R) Processors may allow an authorized user to potentially enable information disclosure via local access. <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-0001>09:22
SvenKiesketomreyn: sorry was hung up in some other kernel sec bugs.. I got: "cat /sys/devices/system/cpu/vulnerabilities/spectre_v2" reports "Mitigation: Full AMD retpoline, IBPB: conditional, IBRS_FW, STIBP: always-on, RSB filling" on a "AMD EPYC 7713P 64-Core Processor" with kernel: 5.4.0-97-generic09:24
tomreynSvenKieske: which gcc was this built with, which ubuntu version is it?09:27
apwtomreyn, i should say just lfence, assuming you have appropriate cpu-firmware loaded.09:27
tomreynapw: yes, the info CVE page is basically irrelevant by now for current HWE on 18.0409:28
SvenKieskeapw|tomreyn: the performance impact is one thing; I'm a bit more worried about retpoline also not being as effective as IBRS? that's what I read from the kernel docs, but they are also not very clear: "For a full mitigation against BHB attacks, it’s recommended to use retpolines (or eIBRS combined with retpolines)."09:28
tomreynin case it's of any use, here's spectre-meldown-checker output: https://termbin.com/22op , with --verbose: https://termbin.com/n1e2 , with --explain: https://termbin.com/buef609:30
tomreyni'll try booting with the kernel cmdline options apw mentioned09:30
SvenKiesketomreyn: we don't built kernels ourselves anymore (I hope I don't have to go back to those times..) that is linux-hwe-5.4 on ubuntu 18.04 from official ubuntu repositories afaik.09:30
apwSvenKieske, the CVE update at -104 carried some relaxing of option combinations and allowing manual override for those options.09:30
tomreynSvenKieske: thanks.09:31
apwSvenKieske, specifically allowing selection of eibrs and retpoline for instance.09:31
SvenKieskeapw: a longstanding issue I got with ubuntu btw is, that uname -r does not report ubuntu patchlevels.. always need to parse uname -a, very annoying.. this is running 5.4.0-97-generic #110~18.0409:31
SvenKieskewe also go with stock kernel cmd line atm (except for our ceph clusters), well not really true, we have hugepages and stuff enabled, but no custom mitigation flags currently09:32
apwSvenKieske, that is an interaction with kmod which uses uname -r to find the modules.  that said now that we have to alway bump abi (for secureboot and signed modules) we could change the form of uname -r more readily.09:33
SvenKieskefor completeness sake, here are the custom kernel options, but they shouldn't interfere here:  no_timer_check nofb nomodeset gfxpayload=text numa_balancing=disable transparent_hugepage=never default_hugepagesz=1GB hugepagesz=1GB09:33
SvenKieskeapw: makes sense, many scripts use the short kernel versions provided via uname -r09:34
SvenKiesketomreyn: is that spectre checker part of stock ubuntu repos by chance? :)09:34
apwSvenKieske, as i understand the security position (and i am only on the periphery) it is believed that unless someone finds new gadgets that disabling uBPF avoids the need to enable more (expensive) mitigations in the general case; but this depends on your threat model.09:34
SvenKieskeapw: wasn't there a recent paper that showed that not only unprivileged ebpf was affected? let me dig up a link (I'm also not an expert in C-Programming or Security, just an interested bystander for over 10 years ;) )...09:36
apwSvenKieske, i believe there are theortically others, i have not see a real one; yet.  but that i think is where the stance of not enabling but making-possible the additional mitigations.09:37
SvenKieskeapw: there you go, a real one ;) https://www.vusec.net/projects/bhi-spectre-bhb/09:37
apwfor this machine right here, none makes any sense.09:37
apwSvenKieske, that is the eBPF exploit09:38
SvenKiesketo be fair: I didn't read the whole paper, just the abstract and the webpage for mere mortals like me ( I aborted my comp sci studies..)09:39
tomreynSvenKieske: no, from their github09:39
apwSvenKieske, and which is why the security update ensures the default for use BPF is off.09:39
SvenKieskeapw: from the website: "So, is disabling unprivileged eBPF sufficient?" "As hinted in the answer above, we believe this is not the case. However, we believe unprivileged eBPF does  tremendously facilitate speculative execution (and other) attacks."09:39
tomreynapw: $ cat /proc/version /proc/cmdline /sys/devices/system/cpu/vulnerabilities/spectre_v2 | nc termbin.com 999909:39
tomreynhttps://termbin.com/gbhc09:39
apwSvenKieske, right, but that contention is "we believe" and that is reasonable, as their attack relies on having a cirtain shaped code gadget in kernel mode, to attack the branch buffers.09:40
SvenKieskeapw: ok, granted; I'm afk for a bit..09:41
apwSvenKieske, and they are saying, they are not convinced there isn't other ways to make one, and they are likely right, but, none is currently known.  so one makes a trade off between actual and possible risk.09:41
apwSvenKieske, which is why it really comes down to your threat model. on my laptop none of these mitigations make any sense at all; and the 10% or whatever performance cost is not warrentd.  if you run potentially hostile payloads (such as occurs in a cloud) of course the cost is necessary.09:43
tomreynapw: you mentioned "assuming you have appropriate cpu-firmware loaded" - i believe this to be the case based on spectre-meltdown-checker v0.44-18-g16f2160 (git head) output:   * CPU microcode is the latest known available version:  YES  (latest version is 0x8001138 dated 2019/02/04 according to builtin firmwares DB v220+i20220208)09:45
apwtomreyn, right, but for example in your debian test, it might have different loaded.09:45
tomreynit loaded with debian defaults there, which could differ from ubuntu defaults09:46
tomreynapw: FWIW, jjohansen in -security pointed out that: "Until this last week lfence/jump was amd's recommended mitigation. You could force generic retpoline using the kernel boot parameter spectre_v2=retpoline,generic - see https://www.amd.com/en/corporate/product-security/bulletin/amd-sb-103609:53
tomreyn"09:53
tomreynhowever, this adivory does not list Ryzen 1000 series Desktop CPUs (such as this one). which could mean those are not affected, or are not being handled.09:54
tomreynmaybe those are just EOL.09:54
apwinteresting they say just retpolines, and not retpoline,lfence which is what was known as retpoline,amd ...09:55
tomreyn"retpolines" (plural 's')?09:55
apwtomreyn, indeed.09:55
SvenKieskeapw: yeah I should've mentioned my threadmodel (I agree it's important): running a basically public cloud, so untrusted kvm guests in openstack09:57
SvenKieskealways mixing up threads and threats :D09:57
tomreynapw: not for me, unless you don't mean it verbatim: curl -s https://www.amd.com/en/corporate/product-security/bulletin/amd-sb-1036 | grep -i retpolines09:57
apwtomreyn, they say retpoline,generic which is retpolines only, not their own ,amd variant.  this seems odd, given it exists for a reason.10:00
tomreynok, got you now.10:01
SvenKieskeI can run the spectre checker on the above amd epyc, if it helps?10:01
tomreynSvenKieske: we've already seen that yours has retpoline enabled, so i don't think it helps us10:02
tomreyn"Full AMD retpoline" specifically10:02
SvenKieskeokay10:03
SvenKieskethe bottomline for me is: I want to make sure I can run untrusted guests, to the best current knowledge, safely. the cherry on top would be if it would be more performant, does anybody has seen performance comparisons between retpoline and IBRS?10:04
tomreyni think phoronix had some for amd10:05
SvenKieskeone thing I don't get is, why I have "IBRS_FW" but not "IBRS"; I mean, okay, I know why I don't got IBRS, but how can IBRS_FW work without IBRS? 10:05
SvenKiesketomreyn: right, I read it at the time, if anyone wants to reread: https://www.phoronix.com/scan.php?page=article&item=3-years-specmelt&num=110:07
SvenKieskethere is also a new performance comparison, but only intel so far for the new mitigations against the above mentioned vusec paper: https://www.phoronix.com/scan.php?page=article&item=spectre-bhi-retpoline&num=210:08
tomreynapw: so i rebooted again, this time with spectre_v2=retpoline,generic , and got "Mitigation: Retpolines, IBPB: conditional, STIBP: disabled, RSB filling"10:15
tomreynwhich i guess is better than LFENCE, worse than "Full AMD retpoline", if i'm getting this right10:16
apwtomreyn, at least you know it has retpolines in it; which is what we expected.11:54
tomreynnow, with the non default cmdline, it does, yes. :)12:02
tomreynthanks for your help in figuring it out, apw.12:03
apwtomreyn, np.12:04
SvenKiesketo update you guys: we in fact are already using the ubuntu cloud archive to get updated packages, but the package list was frozen due to internal organzational challenges, so the IBRS problem will be resolved once we can update our docker images, thanks!13:49
=== fling_ is now known as fling
=== chrisccoulson_ is now known as chrisccoulson

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!