From patchwork Mon Apr 24 22:39:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 9697325 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C463603F4 for ; Mon, 24 Apr 2017 22:39:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E08B25D9E for ; Mon, 24 Apr 2017 22:39:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22D7228404; Mon, 24 Apr 2017 22:39:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9EF68283FB for ; Mon, 24 Apr 2017 22:39:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EC847E9C2; Mon, 24 Apr 2017 22:39:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3EC847E9C2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3EC847E9C2 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 E44F7189C8; Mon, 24 Apr 2017 22:39:42 +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 E4A931808852; Mon, 24 Apr 2017 22:39:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3OMdebi006424 for ; Mon, 24 Apr 2017 18:39:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D79E18A23; Mon, 24 Apr 2017 22:39:40 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with SMTP id EC3F4189C8; Mon, 24 Apr 2017 22:39:37 +0000 (UTC) Received: by redhat.com (sSMTP sendmail emulation); Mon, 24 Apr 2017 17:39:37 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Mon, 24 Apr 2017 17:39:27 -0500 Message-Id: <1493073570-17167-3-git-send-email-bmarzins@redhat.com> In-Reply-To: <1493073570-17167-1-git-send-email-bmarzins@redhat.com> References: <1493073570-17167-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 2/5] multipath: fix up position independent code X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 24 Apr 2017 22:39:44 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP The multipath binaries were not being compiled as position independent executables (PIE). This code fixes that, and makes other minor code hardening tweaks to make hardening-check happier. Signed-off-by: Benjamin Marzinski --- Makefile.inc | 6 +++++- kpartx/Makefile | 3 ++- libdmmp/Makefile | 2 +- libmpathcmd/Makefile | 2 ++ libmpathpersist/Makefile | 2 +- libmultipath/Makefile | 2 +- libmultipath/checkers/Makefile | 2 +- libmultipath/prioritizers/Makefile | 2 +- mpathpersist/Makefile | 3 ++- multipath/Makefile | 4 ++-- multipathd/Makefile | 6 +++--- 11 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Makefile.inc b/Makefile.inc index 8361e6c..9f2f963 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -75,8 +75,12 @@ OPTFLAGS = -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \ -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong \ --param=ssp-buffer-size=4 -CFLAGS = $(OPTFLAGS) -fPIC -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" +CFLAGS = $(OPTFLAGS) -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" +BIN_CFLAGS = -fPIE -DPIE +LIB_CFLAGS = -fPIC SHARED_FLAGS = -shared +LDFLAGS = -Wl,-z,relro -Wl,-z,now +BIN_LDFLAGS = -pie # Check whether a function with name $1 has been declared in header file $2. check_func = \ diff --git a/kpartx/Makefile b/kpartx/Makefile index 9441a2b..7b75032 100644 --- a/kpartx/Makefile +++ b/kpartx/Makefile @@ -3,7 +3,8 @@ # include ../Makefile.inc -CFLAGS += -I. -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +CFLAGS += $(BIN_CFLAGS) -I. -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -ldevmapper diff --git a/libdmmp/Makefile b/libdmmp/Makefile index 1c5329a..a260871 100644 --- a/libdmmp/Makefile +++ b/libdmmp/Makefile @@ -15,7 +15,7 @@ HEADERS = libdmmp/libdmmp.h OBJS = libdmmp.o libdmmp_mp.o libdmmp_pg.o libdmmp_path.o libdmmp_misc.o -CFLAGS += -fvisibility=hidden -I$(libdmmpdir) -I$(mpathcmddir) \ +CFLAGS += $(LIB_CFLAGS) -fvisibility=hidden -I$(libdmmpdir) -I$(mpathcmddir) \ $(shell pkg-config --cflags json-c) LIBDEPS += $(shell pkg-config --libs json-c) -L$(mpathcmddir) -lmpathcmd -lpthread diff --git a/libmpathcmd/Makefile b/libmpathcmd/Makefile index 9cda94c..4f32101 100644 --- a/libmpathcmd/Makefile +++ b/libmpathcmd/Makefile @@ -4,6 +4,8 @@ SONAME = 0 DEVLIB = libmpathcmd.so LIBS = $(DEVLIB).$(SONAME) +CFLAGS += $(LIB_CFLAGS) + OBJS = mpath_cmd.o all: $(LIBS) diff --git a/libmpathpersist/Makefile b/libmpathpersist/Makefile index 857c8d8..1b4ec16 100644 --- a/libmpathpersist/Makefile +++ b/libmpathpersist/Makefile @@ -4,7 +4,7 @@ SONAME = 0 DEVLIB = libmpathpersist.so LIBS = $(DEVLIB).$(SONAME) -CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) +CFLAGS += $(LIB_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath \ -L$(mpathcmddir) -lmpathcmd diff --git a/libmultipath/Makefile b/libmultipath/Makefile index 1f5ec25..b3244fc 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -7,7 +7,7 @@ SONAME = 0 DEVLIB = libmultipath.so LIBS = $(DEVLIB).$(SONAME) -CFLAGS += -I$(mpathcmddir) +CFLAGS += $(LIB_CFLAGS) -I$(mpathcmddir) LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd -lurcu diff --git a/libmultipath/checkers/Makefile b/libmultipath/checkers/Makefile index 4970fc0..732ca9d 100644 --- a/libmultipath/checkers/Makefile +++ b/libmultipath/checkers/Makefile @@ -3,7 +3,7 @@ # include ../../Makefile.inc -CFLAGS += -I.. +CFLAGS += $(LIB_CFLAGS) -I.. # If you add or remove a checker also update multipath/multipath.conf.5 LIBS= \ diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile index 36b42e4..cf6811c 100644 --- a/libmultipath/prioritizers/Makefile +++ b/libmultipath/prioritizers/Makefile @@ -3,7 +3,7 @@ # include ../../Makefile.inc -CFLAGS += -I.. +CFLAGS += $(LIB_CFLAGS) -I.. # If you add or remove a prioritizer also update multipath/multipath.conf.5 LIBS = \ diff --git a/mpathpersist/Makefile b/mpathpersist/Makefile index 47043bb..bd1c0df 100644 --- a/mpathpersist/Makefile +++ b/mpathpersist/Makefile @@ -1,6 +1,7 @@ include ../Makefile.inc -CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) +CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) +LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -lpthread -ldevmapper -L$(mpathpersistdir) -lmpathpersist \ -L$(multipathdir) -L$(mpathcmddir) -lmpathcmd -lmultipath -ludev diff --git a/multipath/Makefile b/multipath/Makefile index cad34bf..c85314e 100644 --- a/multipath/Makefile +++ b/multipath/Makefile @@ -3,8 +3,8 @@ # include ../Makefile.inc -CFLAGS += -I$(multipathdir) -I$(mpathcmddir) - +CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) +LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath -ludev \ -L$(mpathcmddir) -lmpathcmd diff --git a/multipathd/Makefile b/multipathd/Makefile index d57f6d5..d5782a1 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -6,9 +6,9 @@ include ../Makefile.inc #CFLAGS += -DLCKDBG #CFLAGS += -D_DEBUG_ #CFLAGS += -DLOGDBG -CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) \ - -I$(thirdpartydir) - +CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) \ + -I$(mpathcmddir) -I$(thirdpartydir) +LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -ludev -ldl -L$(multipathdir) -lmultipath -L$(mpathpersistdir) \ -lmpathpersist -L$(mpathcmddir) -lmpathcmd -lurcu -lpthread \ -ldevmapper -lreadline