From nobody Thu May 15 04:38:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1509111228734717.3973902131744; Fri, 27 Oct 2017 06:33:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3295B7E382; Fri, 27 Oct 2017 13:33:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 080BF80E16; Fri, 27 Oct 2017 13:33:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C2E661804485; Fri, 27 Oct 2017 13:33:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9RDVvgV000949 for ; Fri, 27 Oct 2017 09:31:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0BD2C60BEB; Fri, 27 Oct 2017 13:31:57 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-204-199.brq.redhat.com [10.40.204.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FB1160C8A; Fri, 27 Oct 2017 13:31:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3295B7E382 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Fri, 27 Oct 2017 14:31:42 +0100 Message-Id: <20171027133143.2553-5-berrange@redhat.com> In-Reply-To: <20171027133143.2553-1-berrange@redhat.com> References: <20171027133143.2553-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH dbus 4/5] Enable full RELRO mode X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 27 Oct 2017 13:33:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By passing the flags -z relro -z now to the linker, we can force it to resolve all library symbols at startup, instead of on-demand. This allows it to then make the global offset table (GOT) read-only, which makes some security attacks harder. Signed-off-by: Daniel P. Berrange --- configure.ac | 1 + m4/virt-linker-relro.m4 | 35 +++++++++++++++++++++++++++++++++++ src/Makefile.am | 4 +++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 m4/virt-linker-relro.m4 diff --git a/configure.ac b/configure.ac index 4c96fbe..b9ccf93 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,7 @@ PKG_CHECK_MODULES(LIBVIRT, libvirt >=3D $LIBVIRT_REQUIRED) PKG_CHECK_MODULES(SYSTEMD, libsystemd >=3D $SYSTEMD_REQUIRED) =20 LIBVIRT_COMPILE_WARNINGS +LIBVIRT_LINKER_RELRO =20 AC_ARG_WITH(dbus-services, [AC_HELP_STRING([--with-dbus-services=3D], diff --git a/m4/virt-linker-relro.m4 b/m4/virt-linker-relro.m4 new file mode 100644 index 0000000..7669b23 --- /dev/null +++ b/m4/virt-linker-relro.m4 @@ -0,0 +1,35 @@ +dnl +dnl Check for -z now and -z relro linker flags +dnl +dnl Copyright (C) 2013 Red Hat, Inc. +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library. If not, see +dnl . +dnl + +AC_DEFUN([LIBVIRT_LINKER_RELRO],[ + AC_MSG_CHECKING([for how to force completely read-only GOT table]) + + RELRO_LDFLAGS=3D + ld_help=3D`ld --help 2>&1` + case $ld_help in + *"-z relro"*) RELRO_LDFLAGS=3D"-Wl,-z -Wl,relro" ;; + esac + case $ld_help in + *"-z now"*) RELRO_LDFLAGS=3D"$RELRO_LDFLAGS -Wl,-z -Wl,now" ;; + esac + AC_SUBST([RELRO_LDFLAGS]) + + AC_MSG_RESULT([$RELRO_LDFLAGS]) +]) diff --git a/src/Makefile.am b/src/Makefile.am index 17b4fe1..8dd8ecd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,9 @@ libvirt_dbus_CFLAGS =3D \ =20 libvirt_dbus_LDFLAGS =3D \ $(SYSTEMD_LDFLAGS) \ - $(LIBVIRT_LDFLAGS) + $(LIBVIRT_LDFLAGS) \ + $(RELRO_LDFLAGS) \ + $(NULL) =20 libvirt_dbus_LDADD =3D \ $(SYSTEMD_LIBS) \ --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list