From patchwork Fri Jul 12 12:19:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 168939 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp814381ilk; Fri, 12 Jul 2019 05:24:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGSxTgxEWo+Ura5yVFulP0Mg6i75uXz73fdSswujJVFoG5oBkwPhUcD9RAbnis1Qv2jMyC X-Received: by 2002:a63:ef4b:: with SMTP id c11mr8982700pgk.129.1562934242334; Fri, 12 Jul 2019 05:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934242; cv=none; d=google.com; s=arc-20160816; b=FXYJGtmWOOQn/UyHfX66TXGYAwcaGixiEdS2IIBLzu8e+etLhbFR1Av1gcrANfPOM6 1uAzd3ve11FMDd/RtKstntB1RSHh7JjUmn2E4YvmiStevN/z/7rvmAOLTXUi4usP+7U4 ZxAYOldhVzDuU6+/7tFcvNp+fSGa92ZyKYjHb43Ijd7Uy8ldTCtZ/ztnsWe5NSl4x8J8 Tv6VME5BPsdDE7fP4sx/k4eFA6Kfdj/S8YGt1vmf3X+/+A815zE3+KIoOpuI3T3fRKtE 2wCfdSfUwDtGvpUkuscKst/6yRN+2xGQeErlR/5lZl3Ljy/eSG/P7voupL0MHdxKruhB LP9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h3f/xjPGtnYFGGGewDg2Kqyo5DqBIRin36K/7r4s9FQ=; b=OB9oXywiaCCVdGjCdnGYvKuP6OzKir2NDvDc+4Ya2QOfVFRpV6iDrZsKyYOojjdQnw Ky0nIZGTNOnUGLv/De+SX6rFKuahxkTC5KoZWfIr8+c0tbCGPLI1rESo5Qi6nE3fjeGz PIQWJklYYtF1bwdD654QxnP6lf2RHI/KzfGreYJxeipVE0WB9A5Snv/OVNcSO3fhRCvf kmsHC32AX7Z2oc5XK+YEJD5HWDuakaNpNzpd+0JKs0zDla1kKrgOJaXJltELl6peBtKk 3tKouDqAVnVSLQDodA7vFoJXgTSrYTgKG5lRSx83cnSzCVcxM0gqWlTiRKru+2Uu3pqZ bArQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EHAhzlqw; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a186si7923162pge.365.2019.07.12.05.24.02; Fri, 12 Jul 2019 05:24:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EHAhzlqw; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728011AbfGLMYB (ORCPT + 13 others); Fri, 12 Jul 2019 08:24:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:60278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728017AbfGLMYB (ORCPT ); Fri, 12 Jul 2019 08:24:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C8B392166E; Fri, 12 Jul 2019 12:23:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934240; bh=iq7WBELuSJXsDQXHqcYVhtzeWRxVPYpR2skCXKG3gus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EHAhzlqwLPhlgFaNabuOE2QkdXhoV+JfI/HxA5BmV35QJXHfqx4AaSAyoMwuby/lT 8+ATQ3bzu4iddJ6DZPr1nuhaVQxUIkw3i6DsBZUAaeTOq2SAvigNLAZ94zOJ0c/aM+ L4crZmFmMxcLZnll25zb5+5B2dJRryVM6drqmQTE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Alan Modra , Jordan Rupprect , Kees Cook , Nick Desaulniers Subject: [PATCH 4.19 81/91] lkdtm: support llvm-objcopy Date: Fri, 12 Jul 2019 14:19:24 +0200 Message-Id: <20190712121626.129401231@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121621.422224300@linuxfoundation.org> References: <20190712121621.422224300@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nick Desaulniers commit e9e08a07385e08f1a7f85c5d1e345c21c9564963 upstream. With CONFIG_LKDTM=y and make OBJCOPY=llvm-objcopy, llvm-objcopy errors: llvm-objcopy: error: --set-section-flags=.text conflicts with --rename-section=.text=.rodata Rather than support setting flags then renaming sections vs renaming then setting flags, it's simpler to just change both at the same time via --rename-section. Adding the load flag is required for GNU objcopy to mark .rodata Type as PROGBITS after the rename. This can be verified with: $ readelf -S drivers/misc/lkdtm/rodata_objcopy.o ... Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align ... [ 1] .rodata PROGBITS 0000000000000000 00000040 0000000000000004 0000000000000000 A 0 0 4 ... Which shows that .text is now renamed .rodata, the alloc flag A is set, the type is PROGBITS, and the section is not flagged as writeable W. Cc: stable@vger.kernel.org Link: https://sourceware.org/bugzilla/show_bug.cgi?id=24554 Link: https://github.com/ClangBuiltLinux/linux/issues/448 Reported-by: Nathan Chancellor Suggested-by: Alan Modra Suggested-by: Jordan Rupprect Suggested-by: Kees Cook Acked-by: Kees Cook Reviewed-by: Nathan Chancellor Signed-off-by: Nick Desaulniers Signed-off-by: Greg Kroah-Hartman --- drivers/misc/lkdtm/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/misc/lkdtm/Makefile +++ b/drivers/misc/lkdtm/Makefile @@ -13,8 +13,7 @@ KCOV_INSTRUMENT_rodata.o := n OBJCOPYFLAGS := OBJCOPYFLAGS_rodata_objcopy.o := \ - --set-section-flags .text=alloc,readonly \ - --rename-section .text=.rodata + --rename-section .text=.rodata,alloc,readonly,load targets += rodata.o rodata_objcopy.o $(obj)/rodata_objcopy.o: $(obj)/rodata.o FORCE $(call if_changed,objcopy)