All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Daniele Buono <dbuono@linux.vnet.ibm.com>
Subject: [PATCH 5/5] net: slirp: allow CFI with libslirp >= 4.7
Date: Wed,  4 May 2022 23:00:01 +0200	[thread overview]
Message-ID: <20220504210001.678419-6-pbonzini@redhat.com> (raw)
In-Reply-To: <20220504210001.678419-1-pbonzini@redhat.com>

slirp 4.7 introduces a new CFI-friendly timer callback that does
not pass function pointers within libslirp as callbacks for timers.
Check the version number and, if it is new enough, allow using CFI
even with a system libslirp.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/meson.build b/meson.build
index c26aa442d4..defe604065 100644
--- a/meson.build
+++ b/meson.build
@@ -2509,10 +2509,25 @@ if have_system
   slirp_opt = get_option('slirp')
   if slirp_opt in ['enabled', 'auto', 'system']
     have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
+    slirp_dep_required = (slirp_opt == 'system' or
+                          slirp_opt == 'enabled' and not have_internal)
     slirp = dependency('slirp', kwargs: static_kwargs,
                        method: 'pkg-config',
-                       required: slirp_opt == 'system' or
-                                 slirp_opt == 'enabled' and not have_internal)
+                       required: slirp_dep_required)
+    # slirp <4.7 is incompatible with CFI support in QEMU.  This is because
+    # it passes function pointers within libslirp as callbacks for timers.
+    # When using a system-wide shared libslirp, the type information for the
+    # callback is missing and the timer call produces a false positive with CFI.
+    # Do not use the "version" keyword argument to produce a better error.
+    # with control-flow integrity.
+    if get_option('cfi') and slirp.found() and slirp.version().version_compare('<4.7')
+      if slirp_dep_required
+        error('Control-Flow Integrity requires libslirp 4.7.')
+      else
+        warning('Control-Flow Integrity requires libslirp 4.7, not using system-wide libslirp.')
+        slirp = not_found
+      endif
+    endif
     if slirp.found()
       slirp_opt = 'system'
     elif have_internal
@@ -2585,18 +2600,6 @@ if have_system
   endif
 endif
 
-# For CFI, we need to compile slirp as a static library together with qemu.
-# This is because we register slirp functions as callbacks for QEMU Timers.
-# When using a system-wide shared libslirp, the type information for the
-# callback is missing and the timer call produces a false positive with CFI.
-#
-# Now that slirp_opt has been defined, check if the selected slirp is compatible
-# with control-flow integrity.
-if get_option('cfi') and slirp_opt == 'system'
-  error('Control-Flow Integrity is not compatible with system-wide slirp.' \
-         + ' Please configure with --enable-slirp=git')
-endif
-
 fdt = not_found
 if have_system
   fdt_opt = get_option('fdt')
-- 
2.35.1



  parent reply	other threads:[~2022-05-04 21:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04 20:59 [PATCH 0/5] net: support for CFI with libslirp >= 4.7 Paolo Bonzini
2022-05-04 20:59 ` [PATCH 1/5] slirp: bump submodule to 4.7 release Paolo Bonzini
2022-05-05  8:21   ` Marc-André Lureau
2022-05-05  8:34     ` Paolo Bonzini
2022-05-05  8:37       ` Marc-André Lureau
2022-05-05  8:42         ` Paolo Bonzini
2022-05-04 20:59 ` [PATCH 2/5] net: slirp: introduce a wrapper struct for QemuTimer Paolo Bonzini
2022-05-05  8:22   ` Marc-André Lureau
2022-05-04 20:59 ` [PATCH 3/5] net: slirp: switch to slirp_new Paolo Bonzini
2022-05-05  8:20   ` Marc-André Lureau
2022-05-05  8:29     ` Paolo Bonzini
2022-05-05 10:07       ` Daniel P. Berrangé
2022-05-05 12:02         ` Paolo Bonzini
2022-05-04 21:00 ` [PATCH 4/5] net: slirp: add support for CFI-friendly timer API Paolo Bonzini
2022-05-05  8:24   ` Marc-André Lureau
2022-05-04 21:00 ` Paolo Bonzini [this message]
2022-05-05  8:21   ` [PATCH 5/5] net: slirp: allow CFI with libslirp >= 4.7 Marc-André Lureau

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=20220504210001.678419-6-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dbuono@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.