Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933335AbbFIMdo (ORCPT ); Tue, 9 Jun 2015 08:33:44 -0400 Received: from mail-db3on0075.outbound.protection.outlook.com ([157.55.234.75]:26896 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933209AbbFIMcu (ORCPT ); Tue, 9 Jun 2015 08:32:50 -0400 Authentication-Results: spf=fail (sender IP is 212.179.42.66) smtp.mailfrom=ezchip.com; synopsys.com; dkim=none (message not signed) header.d=none; From: Noam Camus To: , CC: , , , "Noam Camus" Subject: [PATCH] fs: heap/bss calculation ignore special section. Date: Tue, 9 Jun 2015 15:32:19 +0300 Message-ID: <1433853139-28554-1-git-send-email-noamc@ezchip.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-11.0.0.1191-7.500.1018-21534.006 X-TM-AS-Result: No--7.276000-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;AM1FFO11FD046;1:t3Qe0fEiKmovEtauA9c/ARahwAnNBeE9GPHwkSd4yZEaVPn4gVQTsG7CAkuqH1IuaN1wRrh8Wntd3DoFDTnZEhspTvlSuYMNNqxn8J2jBL6nMMYHzWhgqVOsMrGaaKv5Pq8k4sHzEVe7KC/SY1BVNgT005AW3LlfB7wqDCcgYpDFNGadYb5fJiq0sp3MX1ABmvyOPUu7ilb56N6zED34R0RYgq87Fv+IPGfDkst9Yt43X82FtzxZoRI/GZ1rhK8qHwaGNCIADexoMr6o9PzaiEL85CoEniVIyDov+2zIE7YU6/NA0TI85xsDEoxMA2Mq X-Forefront-Antispam-Report: CIP:212.179.42.66;CTRY:IL;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(189002)(199003)(85426001)(48376002)(50466002)(92566002)(5001770100001)(62966003)(5001970100001)(107886002)(50226001)(87936001)(46102003)(77096005)(105606002)(47776003)(104016003)(33646002)(19580395003)(189998001)(6806004)(36756003)(50986999)(229853001)(106466001)(19580405001)(86362001)(77156002)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:AMSPR02MB184;H:ezex10.ezchip.com;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AMSPR02MB184; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520003)(3002001);SRVR:AMSPR02MB184;BCL:0;PCL:0;RULEID:;SRVR:AMSPR02MB184; X-Forefront-PRVS: 06022AA85F X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2015 12:32:45.9223 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3;Ip=[212.179.42.66];Helo=[ezex10.ezchip.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR02MB184 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1272 Lines: 41 From: Noam Camus Today bss/heap is placed above last loaded sections. However if STACK_TOP is not equal to TASK_SIZE we wish to ignore such sections mapped to this gap between STACK_TOP and TASK_SIZE. set_brk will never work for such case. So at the moment this addition is just a sanity check. An alternative (more complex): Linux would make use of LMA field in ELF, then we can set VMA below STACK_TOP and set LMA to be between STACK_TOP and TASK_SIZE to match such special memory mapping. Signed-off-by: Noam Camus --- fs/binfmt_elf.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 241ef68..09f9483 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -962,6 +962,9 @@ static int load_elf_binary(struct linux_binprm *bprm) k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz; + if (k >= STACK_TOP) + continue; + if (k > elf_bss) elf_bss = k; if ((elf_ppnt->p_flags & PF_X) && end_code < k) -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/