From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] misc: enable retpolines across all xfsprogs utilities
Date: Wed, 21 Feb 2018 18:16:25 -0800 [thread overview]
Message-ID: <20180222021625.GA9827@magnolia> (raw)
From: Darrick J. Wong <darrick.wong@oracle.com>
Detect and enable retpolines for all code, to mitigate Spectre v2
(branch target injection) on x86.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
configure.ac | 1 +
include/builddefs.in | 7 +++++++
m4/package_libcdev.m4 | 22 ++++++++++++++++++++++
3 files changed, 30 insertions(+)
diff --git a/configure.ac b/configure.ac
index d068ba0..2104219 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/include/builddefs.in b/include/builddefs.in
index df76b2c..fe05dc3 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -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
diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index 9258c27..5a7baa1 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -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)
+ ])
next reply other threads:[~2018-02-22 2:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-22 2:16 Darrick J. Wong [this message]
2018-02-22 15:09 ` [PATCH] misc: enable retpolines across all xfsprogs utilities Christoph Hellwig
2018-02-22 15:31 ` Eric Sandeen
2018-02-22 17:15 ` Darrick J. Wong
2018-02-22 21:10 ` Matthias Schniedermeyer
2018-02-22 23:57 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180222021625.GA9827@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).