Received: by 10.192.165.156 with SMTP id m28csp1274275imm; Wed, 18 Apr 2018 07:08:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+NrCkcstt6Wy0EQmNypuvrIHoxah8KMXI91Ch2jt6iDmRg73L49eqnwl0CBBEPz9OlGWbJ X-Received: by 10.99.146.87 with SMTP id s23mr1880534pgn.64.1524060525266; Wed, 18 Apr 2018 07:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524060525; cv=none; d=google.com; s=arc-20160816; b=m70xB4Nb6DmHas6Gg8yLcHOLV84q08y7OslTd35i+f+dgNFvyb0k6q7ispaujmKBhv aQPgyPXH9UefGEWPVA3yHe52wc9jplJNZBYn5SBsPRO1bQortgL+F7HBPbxNhM8ekGXx 9wHTPepdlWr047j31NndZ9m0ycytnMDmhrv3r8nzctEIDuEKjDZYQTJPcRQwfDnraRQ6 0TKpQ8R/EOe19/yyqJ0DvPAjpnIeG0ImnojtzqiC5UqpgtNwPimaQCTVlRzhlfj890Or J/R2LJxWdqzV/4f383JiGQ8Qd/3NYrAGpjBbh/54f02pmjn9xvvHMCP385mksPLHbfbb fG0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:date:message-id:in-reply-to :references:from:subject:cc:to:arc-authentication-results; bh=LACBWp35MVc+t75v3R8j9f97TvXsBw/Nrpj1DK8TJao=; b=EVQRTA1xrBrgMzZrEqJXRlE9n1KDN5aQW9jMp3Ug8Ko2LZSnWOc7FtbgkjtPWAGEOp OeRpkq6Mj6McpY/a3cqsLa2vUsLt7aUantcr9gcDOV5/wYYi/MG4B42p0IDRzy95q9RW DvM9Xndg3i9ByeGO/XBPp87pCXTP6WsWxwq003lEEPTvF9kUJXTmw3jo61bvGtt9AKpU 5pocre7qSrhZgl3S2k3ALWq3x08j2O2wz1P/5M15F1NteVbYM5nPvpEZ0uU8qDb1Vooz d90iOWzC/y0dblnfhPlKTIIjMPxHvsbfyZFnfomzxAsbEM5XEgxzkmY9KgaycAIe7b3a C2rA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3-v6si1362965pld.309.2018.04.18.07.08.30; Wed, 18 Apr 2018 07:08:45 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753919AbeDROHR (ORCPT + 99 others); Wed, 18 Apr 2018 10:07:17 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:52827 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753729AbeDROHQ (ORCPT ); Wed, 18 Apr 2018 10:07:16 -0400 Received: from fsav401.sakura.ne.jp (fsav401.sakura.ne.jp [133.242.250.100]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w3IE7Ep6028412; Wed, 18 Apr 2018 23:07:14 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav401.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav401.sakura.ne.jp); Wed, 18 Apr 2018 23:07:14 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav401.sakura.ne.jp) Received: from AQUA (softbank126099184120.bbtec.net [126.99.184.120]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w3IE7Dqu028399; Wed, 18 Apr 2018 23:07:13 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) To: akpm@linux-foundation.org Cc: mhocko@kernel.org, avagin@openvz.org, khalid.aziz@oracle.com, mpe@ellerman.id.au, keescook@chromium.org, abdhalee@linux.vnet.ibm.com, joel@jms.id.au, khandual@linux.vnet.ibm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] fs, elf: don't complain MAP_FIXED_NOREPLACE unless -EEXIST error. From: Tetsuo Handa References: <20171213092550.2774-3-mhocko@kernel.org> <0b5c541a-91ee-220b-3196-f64264f9f0bc@I-love.SAKURA.ne.jp> <20180418113301.GY17484@dhcp22.suse.cz> <201804182043.JFH90161.LStOOMFFOJQHVF@I-love.SAKURA.ne.jp> <20180418115546.GZ17484@dhcp22.suse.cz> In-Reply-To: <20180418115546.GZ17484@dhcp22.suse.cz> Message-Id: <201804182307.FAC17665.SFMOFJVFtHOLOQ@I-love.SAKURA.ne.jp> X-Mailer: Winbiff [Version 2.51 PL2] X-Accept-Language: ja,en,zh Date: Wed, 18 Apr 2018 23:07:12 +0900 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >From 3f396857d23d4bf1fac4d4332316b5ba0af6d2f9 Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Wed, 18 Apr 2018 23:00:53 +0900 Subject: [PATCH v2] fs, elf: don't complain MAP_FIXED_NOREPLACE unless -EEXIST error. Commit 4ed28639519c7bad ("fs, elf: drop MAP_FIXED usage from elf_map") is printing spurious messages under memory pressure due to map_addr == -ENOMEM. 9794 (a.out): Uhuuh, elf segment at 00007f2e34738000(fffffffffffffff4) requested but the memory is mapped already 14104 (a.out): Uhuuh, elf segment at 00007f34fd76c000(fffffffffffffff4) requested but the memory is mapped already 16843 (a.out): Uhuuh, elf segment at 00007f930ecc7000(fffffffffffffff4) requested but the memory is mapped already Complain only if -EEXIST, and use %px for printing the address. Signed-off-by: Tetsuo Handa Acked-by: Michal Hocko Cc: Andrei Vagin Cc: Khalid Aziz Cc: Michael Ellerman Cc: Kees Cook Cc: Abdul Haleem Cc: Joel Stanley Cc: Anshuman Khandual --- fs/binfmt_elf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 41e0418..4ad6f66 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -377,10 +377,10 @@ static unsigned long elf_map(struct file *filep, unsigned long addr, } else map_addr = vm_mmap(filep, addr, size, prot, type, off); - if ((type & MAP_FIXED_NOREPLACE) && BAD_ADDR(map_addr)) - pr_info("%d (%s): Uhuuh, elf segment at %p requested but the memory is mapped already\n", - task_pid_nr(current), current->comm, - (void *)addr); + if ((type & MAP_FIXED_NOREPLACE) && + PTR_ERR((void *)map_addr) == -EEXIST) + pr_info("%d (%s): Uhuuh, elf segment at %px requested but the memory is mapped already\n", + task_pid_nr(current), current->comm, (void *)addr); return(map_addr); } -- 1.8.3.1