From patchwork Mon May 13 22:21:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 164069 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1886737ili; Mon, 13 May 2019 15:21:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqycTncRYbJPKMz8zmIfPDPdsIGEvS/SgVYPxk/Z3lc9BDyfzYlc2ar6hIe3SdA7c9yaoAsv X-Received: by 2002:a65:5682:: with SMTP id v2mr34622973pgs.100.1557786096198; Mon, 13 May 2019 15:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557786096; cv=none; d=google.com; s=arc-20160816; b=QlHv7cKB8+KOUG6I9aeaTxj6xrQXOEPQCU/P9FMLL3W/zT4QfWYSq82+/l+9bm28j1 pOcWGCOpZRsYNa5+yzwJKBFN7Se+YlnXZSYMjR7olqI6Fe3Dwmy+LfzNl+s266VF0f0o uVqH6HgH3UdXHm8Acp6E8CDYYAb43XMylytWISARF1RyDBi3eSvx8U/pFm5EnkHePLeL Qjp2zHhnMuI5fc00LvViaaATg8kSQCb/ZARBvAuIfA6FhC9iTXOMHU60VBveFFxI5nml 3HECWujSQPy+DtHw+XkarskhCDemuRaOOUxRwUJb+Bzplr6XpkrgDjRfIUnAzNYZd2Ls OkoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=AuVjfNBr2+kooUNC4DV3ysuf+Fv6Qzi5cBLNqdsxq6Q=; b=upku+NJIhjg/QKFlnCaVO1hQPwCRUGtigQzK3dsWxMwGqOgeUgKZnK2YBxBbjS3B21 Fz4o974di1yCCAM1TmSL0+XAvhe2lH6pTWMAQsDI5s7RSXkp55lIjBZgnA7wZ1GpowV2 eufKWB5P3dv9R+y4QHp2PbC15lCYbXql8arJqEh5mvePhUiswSdkfua/aRF0OLjWPF8p ws2KGWYz6U3iJ/KtidJgcgexMrINjXhhQssksmDF/XeadNxqJDKzKHSHuigjx07EDi5t kkzNne8I6HtL/3BZFKVGzvJCY/oY3n/oQOcBGVYPkOx9mrM6dPOV1sQeo5X56abOelqH od6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bfaNmFL2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay11si18137035plb.423.2019.05.13.15.21.35; Mon, 13 May 2019 15:21:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@google.com header.s=20161025 header.b=bfaNmFL2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726486AbfEMWVe (ORCPT + 30 others); Mon, 13 May 2019 18:21:34 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:50650 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbfEMWVe (ORCPT ); Mon, 13 May 2019 18:21:34 -0400 Received: by mail-pl1-f202.google.com with SMTP id o12so2628660pll.17 for ; Mon, 13 May 2019 15:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=AuVjfNBr2+kooUNC4DV3ysuf+Fv6Qzi5cBLNqdsxq6Q=; b=bfaNmFL2Ng8OQj0f4CqDD0zd8RaArpJFv4J+IvkwUv+1gNtB0NXngyn4Fh1R14Qic+ 0VGL3bypDi8JEBGYm2jdydCa8HXXrwi5DO1YfGS8+YV5vwpAhVEKagIWTo0K0eD+oy0z QwUvD6PVGn1lwnpkHosMPqP20//eLc4I8e3vAR9kkppKk93sIfd7czXmQ1edFmZJh3Om b856unadmKUCwxCPG0s0XrEP2gSHIyRoQnkjDvzY85tmJ9uRs3MNjpJg4q+SSo92GYwB s+pX3khqV78K8zAOpkcCJPhXFiJuzAN8y3hEoYbVJZyX9R/bLGjTHA5vwjg9bTi5cZUF 5rPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=AuVjfNBr2+kooUNC4DV3ysuf+Fv6Qzi5cBLNqdsxq6Q=; b=Mnr6ebsjFfxJFkyYJRzWLZVxXp3wEQoIYbCvBPQo5H6sYjtSSTsk2hny6N6qc8+KFV 0GVqYg4Yvc7+4FaxUl15FEPMj3tIAt1gFDOLD7YsobGhbJVvpoNF78wPOPvhy0C3l/70 mtpdXWH+YcPktTs/aHKIkMg3dWXijMxcDcOvRSiT4CxEjJBmG/j9n4Wwt5fSwZlVVdGH 0sruQoZfeQ7PfOJlXGIVdYiRS5zND20LQwwflO1rwHAiCp+t4QtRIH3s6nlFZiQQCR4d 3h7/VyVpdf6U+gerym3wC03iwxtdlWOjDdvUMerlsQcOAUbIF95JoPpN9aDf219ot/KJ YzOQ== X-Gm-Message-State: APjAAAVF0YYljcY7ARx6jR9hC4y8Fd6yNFqkABsrSqBQLQoo9iCA8wlQ c5zEQYJV4cqtawwUcdR93B+aIlh9Y/dticVNKQc= X-Received: by 2002:a63:a55:: with SMTP id z21mr34502680pgk.440.1557786093072; Mon, 13 May 2019 15:21:33 -0700 (PDT) Date: Mon, 13 May 2019 15:21:09 -0700 Message-Id: <20190513222109.110020-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog Subject: [PATCH] lkdtm: support llvm-objcopy From: Nick Desaulniers To: keescook@chromium.org Cc: clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Jordan Rupprect , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 in the Flags field that .text is now renamed .rodata, the append flag A is set, and the section is not flagged as writeable W. Link: https://github.com/ClangBuiltLinux/linux/issues/448 Reported-by: Nathan Chancellor Suggested-by: Jordan Rupprect Signed-off-by: Nick Desaulniers --- drivers/misc/lkdtm/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.21.0.1020.gf2820cf01a-goog Acked-by: Kees Cook Reviewed-by: Nick Desaulniers diff --git a/drivers/misc/lkdtm/Makefile b/drivers/misc/lkdtm/Makefile index 951c984de61a..89dee2a9d88c 100644 --- a/drivers/misc/lkdtm/Makefile +++ b/drivers/misc/lkdtm/Makefile @@ -15,8 +15,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 targets += rodata.o rodata_objcopy.o $(obj)/rodata_objcopy.o: $(obj)/rodata.o FORCE $(call if_changed,objcopy)