Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp911265ybb; Fri, 10 Apr 2020 12:39:58 -0700 (PDT) X-Google-Smtp-Source: APiQypLdp2tA88aeOt4Ot2EpAWzdFTklsOMLvBgLnZiGEDbo3X/2LRyCuJ5SvSxe2KpXb7uzkoEC X-Received: by 2002:ae9:f30f:: with SMTP id p15mr5536679qkg.178.1586547598789; Fri, 10 Apr 2020 12:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586547598; cv=none; d=google.com; s=arc-20160816; b=nB/MgkE8QsCbFb0dxI9zpO24CsZHrvlSQ3MWTuhEBq9nuGSgBDCF/6o24poYdjT02N B2Pp5+2bEYKP5t3aNKO52Jvm7vw55wrkl1jwq4S9ZLNPKoX7nBxxT5dgrDyddAUYunj2 4/HCIN2p2VCWUMg1IAXW3f6X8pzAPjL5V6sI9h1YChi2zlPgEZkB7JixMsex6sFsXSTN ss6CfrxGIgqTrz9M1SEi+piMk7zMgXnrnyG8ON9AKz64cVQOBh7aMEVgF1mNUAembumV OQvR1tmOHkbcqS76mm8pG6d6IjQ813/czhouUgBE6BuCBGx0S+cV31LGFU+J4Y7ru5em jL0A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vhCIXXrwM2OK0/KGZOPqHoin3JZ7djJk9w7hMn0lA1I=; b=PJzF7c3IAxQX+KsVk0H3BPpW7yQGEZo+Zzqnn6eGwpx9dlurH88ptPo11oMd55naQH IkrosLOtSnY7jSYxUS9e55H7LzLDt7y608eIQZYfHSxxLvbDbgKKL/B1QX9CyBIRPV2h qjmVscrdQ+SjiehmlUDajami1v+rblEB5wjVw6TvRb2jaPiy2W56m2WCtxQoy/gKx+SF zZYkCgYdC8CMt8mDrYWi1osFnuykR2s13076DEHlm2gFzN3F7PdNWm9HGV+DIBN8mrwE f+Lrms9dn8qg8TIeVuEgvNotDOjZ27AsIR9kAGCy9QZ6X6AyApAR+NXk3sum5Iatw+UG hErQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 19si1956441qks.314.2020.04.10.12.39.44; Fri, 10 Apr 2020 12:39:58 -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; 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=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbgDJTiN (ORCPT + 99 others); Fri, 10 Apr 2020 15:38:13 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:36229 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbgDJTiM (ORCPT ); Fri, 10 Apr 2020 15:38:12 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Fri, 10 Apr 2020 12:38:08 -0700 Received: from sc9-mailhost3.vmware.com (unknown [10.166.69.226]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 0D04240BC0; Fri, 10 Apr 2020 12:38:12 -0700 (PDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Julien Thierry , Ingo Molnar , Steven Rostedt , Miroslav Benes , Matt Helsley Subject: [RFC][PATCH 21/36] objtool: mcount: Restrict using ehdr in append_func() Date: Fri, 10 Apr 2020 12:35:44 -0700 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII Received-SPF: None (EX13-EDG-OU-002.vmware.com: mhelsley@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To use as a pointer to an ehdr to modify. Extract the read-only bits from objtool's GElf_Ehdr. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index 3c7afb9a2eac..3c98c379f472 100644 --- a/tools/objtool/recordmcount.h +++ b/tools/objtool/recordmcount.h @@ -99,8 +99,8 @@ static int append_func(Elf_Ehdr *const ehdr, char const *mc_name = (sizeof(Elf_Rela) == rel_entsize) ? ".rela__mcount_loc" : ".rel__mcount_loc"; - unsigned const old_shnum = w2(ehdr->e_shnum); - uint_t const old_shoff = _w(ehdr->e_shoff); + unsigned const old_shnum = lf->ehdr.e_shnum; + uint_t const old_shoff = lf->ehdr.e_shoff; uint_t const old_shstr_sh_size = _w(shstr->sh_size); uint_t const old_shstr_sh_offset = _w(shstr->sh_offset); uint_t t = 1 + strlen(mc_name) + _w(shstr->sh_size); @@ -167,7 +167,7 @@ static int append_func(Elf_Ehdr *const ehdr, return -1; ehdr->e_shoff = _w(new_e_shoff); - ehdr->e_shnum = w2(2 + w2(ehdr->e_shnum)); /* {.rel,}__mcount_loc */ + ehdr->e_shnum = w2(2 + lf->ehdr.e_shnum); /* {.rel,}__mcount_loc */ if (ulseek(0, SEEK_SET) < 0) return -1; if (uwrite(ehdr, sizeof(*ehdr)) < 0) -- 2.20.1