From patchwork Tue Jun 9 12:32:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noam Camus X-Patchwork-Id: 6572461 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E412F9F399 for ; Tue, 9 Jun 2015 12:47:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 09CCA204FF for ; Tue, 9 Jun 2015 12:47:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 234AD204D9 for ; Tue, 9 Jun 2015 12:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753962AbbFIMrc (ORCPT ); Tue, 9 Jun 2015 08:47:32 -0400 Received: from mail-db3on0098.outbound.protection.outlook.com ([157.55.234.98]:12384 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753921AbbFIMrb (ORCPT ); Tue, 9 Jun 2015 08:47:31 -0400 X-Greylist: delayed 882 seconds by postgrey-1.27 at vger.kernel.org; Tue, 09 Jun 2015 08:47:31 EDT Received: from DB3PR02CA0042.eurprd02.prod.outlook.com (10.242.134.52) by AMSPR02MB184.eurprd02.prod.outlook.com (10.242.94.26) with Microsoft SMTP Server (TLS) id 15.1.184.17; Tue, 9 Jun 2015 12:32:47 +0000 Received: from AM1FFO11FD046.protection.gbl (2a01:111:f400:7e00::178) by DB3PR02CA0042.outlook.office365.com (2a01:111:e400:9814::52) with Microsoft SMTP Server (TLS) id 15.1.184.17 via Frontend Transport; Tue, 9 Jun 2015 12:32:46 +0000 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; Received-SPF: Fail (protection.outlook.com: domain of ezchip.com does not designate 212.179.42.66 as permitted sender) receiver=protection.outlook.com; client-ip=212.179.42.66; helo=ezex10.ezchip.com; Received: from ezex10.ezchip.com (212.179.42.66) by AM1FFO11FD046.mail.protection.outlook.com (10.174.65.209) with Microsoft SMTP Server (TLS) id 15.1.190.9 via Frontend Transport; Tue, 9 Jun 2015 12:32:45 +0000 Received: from localhost.localdomain (10.1.3.132) by ezex10.ezchip.com (10.1.1.4) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 9 Jun 2015 15:32:22 +0300 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 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)