misc: enable retpolines across all xfsprogs utilities
PATCH 1/1 misc: enable retpolines across all xfsprogs utilities
From: Darrick J. Wong <[email protected]>
Detect and enable retpolines for all code, to mitigate Spectre v2 (branch target injection) on x86.
--- configure.ac | 1 + include/builddefs.in | 7 +++++++ m4/package_libcdev.m4 | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+)
configure.ac +1 -0
@@ -206,6 +206,7 @@ if test "$have_threadsan" = "yes" && test "$have_addrsan" = "yes"; then AC_MSG_WARN([ADDRSAN and THREADSAN are not known to work together.]) fi +AC_PACKAGE_CHECK_RETPOLINE AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([char *]) AC_TYPE_UMODE_T
include/builddefs.in +7 -0
@@ -176,6 +176,13 @@ endif SANITIZER_CFLAGS += @addrsan_cflags@ @threadsan_cflags@ @ubsan_cflags@ SANITIZER_LDFLAGS += @addrsan_ldflags@ @threadsan_ldflags@ @ubsan_ldflags@ +# Enable retpolines if available +HAVE_RETPOLINE = @have_retpoline@ +ifeq ($(HAVE_RETPOLINE),yes) +OPTIMIZER += @retpoline_cflags@ +LOADERFLAGS += @retpoline_ldflags@ +endif + GCFLAGS = $(DEBUG) \ -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \ -DPACKAGE=\"$(PKG_NAME)\" -I$(TOPDIR)/include -I$(TOPDIR)/libxfs
m4/package_libcdev.m4 +22 -0
@@ -420,3 +420,25 @@ AC_DEFUN([AC_HAVE_HDIO_GETGEO], AC_MSG_RESULT(no)) AC_SUBST(have_hdio_getgeo) ]) + +AC_DEFUN([AC_PACKAGE_CHECK_RETPOLINE], + [ AC_MSG_CHECKING([if C compiler supports retpoline]) + OLD_CFLAGS="$CFLAGS" + OLD_LDFLAGS="$LDFLAGS" + RETPOLINE_FLAGS="-mindirect-branch=thunk" + CFLAGS="$CFLAGS $RETPOLINE_FLAGS" + LDFLAGS="$LDFLAGS $RETPOLINE_FLAGS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [retpoline_cflags=$RETPOLINE_FLAGS] + [retpoline_ldflags=$RETPOLINE_FLAGS], + [AC_MSG_RESULT([no])]) + if test -n "$retpoline_cflags"; then + have_retpoline=yes + fi + CFLAGS="${OLD_CFLAGS}" + LDFLAGS="${OLD_LDFLAGS}" + AC_SUBST(have_retpoline) + AC_SUBST(retpoline_cflags) + AC_SUBST(retpoline_ldflags) + ])
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Detect and enable retpolines for all code, to mitigate Spectre v2 (branch target injection) on x86.
The mechanics look ok, but why do we really care for xfsprogs? fs utilities seem like a lesser target and should just be covered by hopefully sane compiler defaults, shouldn't they?
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Detect and enable retpolines for all code, to mitigate Spectre v2 (branch target injection) on x86.
The mechanics look ok, but why do we really care for xfsprogs? fs utilities seem like a lesser target and should just be covered by hopefully sane compiler defaults, shouldn't they?
That's my feeling as well - does manually fixing one utility out of hundreds on the system help anything? Shouldn't this be done via toolchain or distro-package-build defaults?
-Eric
Quoted 9 lines · Eric Sandeen
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Detect and enable retpolines for all code, to mitigate Spectre v2 (branch target injection) on x86.
The mechanics look ok, but why do we really care for xfsprogs? fs utilities seem like a lesser target and should just be covered
They're a smaller target than the kernel, for sure, but the scary part about spectre is that unprivileged programs running on the same core as a privileged xfs_repair can then use branch predictor poisoning to cause problems with the xfs_repair.
Quoted 1 line
Quoted 1 line
by hopefully sane compiler defaults, shouldn't they?
I would have thought so, but look at the gcc manpage:
-mindirect-branch=choice
Convert indirect call and jump with choice. The default is keep, which keeps indirect call and jump unmodified. thunk
Unmodified, as in don't provide spectre mitigations...
converts indirect call and jump to call and return thunk. thunk-inline converts indirect call and jump to inlined call and return thunk. thunk-extern converts indirect call and jump to external call and return thunk provided in a separate object file. You can control this behavior for a specific function by using the function attribute "indirect_branch".
Note that -mcmodel=large is incompatible with -mindirect-branch=thunk nor -mindirect-branch=thunk-extern since the thunk function may not be reachable in large code model.
So, gcc defaults to unprotected.
Quoted 3 lines
That's my feeling as well - does manually fixing one utility out of hundreds on the system help anything? Shouldn't this be done via toolchain or distro-package-build defaults?
Maybe they will someday, but right now:
$ dpkg-buildflags --get CFLAGS -g -O2 -fdebug-prefix-map=/home/djwong=. -fstack-protector-strong -Wformat -Werror=format-security
It's not clear to me if Debian plans to adopt the per-platform spectre mitigations distro-wide or just for specific packages, or what? So far it looks like Ubuntu is only doing it for their browser packages. libc hasn't been rebuilt, which limits the effectiveness of turning it on for xfsprogs, but otoh we could still protect the bits we control.
--D
Quoted 5 lines
-Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Darrick J. Wong
Quoted 7 lines · Eric Sandeen
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Detect and enable retpolines for all code, to mitigate Spectre v2 (branch target injection) on x86.
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
The mechanics look ok, but why do we really care for xfsprogs? fs utilities seem like a lesser target and should just be covered
They're a smaller target than the kernel, for sure, but the scary part about spectre is that unprivileged programs running on the same core as a privileged
xfs_repaircan then use branch predictor poisoning to cause problems with thexfs_repair.
Spectre & Meltdown are information disclosure vulnerabilities IOW "Read Only".
The other process CAN NOT interfere with xfs_repair.
I would speculate that the most it can get, is information about parts of the filesystem that are inaccsessible to an unprivileged process by spying on xfs_repair.
I don't know how xfs_repair works, especially how xfs_repair handles storing data in memory. But for xfs_repair to be a good target, it would have to store relevant data in a deterministic fashion and for some length of time. At least enough to justify writing an extraction program for it.
I would say the 'good old' xfs_repair case isn't really a good target, but the online-scrubbing-case sure sounds to be a different beast.
In the past you couldn't, for a given point in time, really expect a xfs_repair process to be running, but with online-scrubbing that game changes.
Signature · 1 line
Matthias
Quoted 9 lines · Matthias Schniedermeyer
Quoted 4 lines · Darrick J. Wong
They're a smaller target than the kernel, for sure, but the scary part about spectre is that unprivileged programs running on the same core as a privileged
xfs_repaircan then use branch predictor poisoning to cause problems with thexfs_repair.Spectre & Meltdown are information disclosure vulnerabilities IOW "Read Only".
The other process CAN NOT interfere withxfs_repair.
Yup, that's enough to leak private information. e.g. encryption keys stored in extended attributes...
Quoted 8 lines
I would speculate that the most it can get, is information about parts of the filesystem that are inaccsessible to an unprivileged process by spying on
xfs_repair.
I don't know howxfs_repairworks, especially howxfs_repairhandles storing data in memory. But forxfs_repairto be a good target, it would have to store relevant data in a deterministic fashion and for some length of time. At least enough to justify writing an extraction program for it.
Oh, yeah, we've got this whopping great big buffer cache that can cache all the metadata it reads from disk in memory while repair does it's validation work. It's a pretty big target from that perspective. That's made even worse if you consider a large filesystem that takes days for xfs_repair to completely check....
Quoted 2 lines
I would say the 'good old'
xfs_repaircase isn't really a good target, but the online-scrubbing-case sure sounds to be a different beast.
Scrubbing is done in the kernel, with metadata cached in kernel memory, so it's already protected by whatever kernel mitigations are in place.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]