Received: by 10.192.165.156 with SMTP id m28csp1081206imm; Wed, 18 Apr 2018 03:52:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Z3GiPrPdIv9lAcj5pLtg1hDyPDrQvXs4wgNYFJ1gUIea6cwwPwoBB69J4e3vW5aHxFsK2 X-Received: by 2002:a17:902:6689:: with SMTP id e9-v6mr1659189plk.176.1524048760010; Wed, 18 Apr 2018 03:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524048759; cv=none; d=google.com; s=arc-20160816; b=RVrJAkOj5dsObtf6H9Kr9qlkZW+GQ9oCIsuRbrZ2Yq1gyGIy/+3KI1PJFlWa6ajoM5 9WlTvoAfbbwtU6RdVSOrFgpGLhKE1WXYuiVCM+qPVFFKc6jwL6UEJPnnJjQC9BgmYYS9 xPRyZGmwGVxWhaSMhzwvk5vCaGWoeSnaEp/PEa34H+O3y+hEJOi9ZG57ZyGLAT7olRno IeM7m7DKtcf2FdAloB/AdAniKD/umVFoAwcqSkIyvlSDAsOxFrEHSOHhLz62j6v/ZNqR SG3aP9bRUTVC2YgrQQJbSt8meLf9xsz1rXCATlOJAeK54XCBFbJxOd3NPLeVJAfln356 fvDw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=4mkhbEraZX0mJ0ulcbl31OEsRFklViRpLaePpLJDSDU=; b=rleFdZq/9zHj5O7UKP/5ebYi11aChtThYNhdCeVtGvrGJQ95nlUURwXd0ssdzM1Sqp w9JsLd+C1jWdNg2RNusX+7SuSQMwFdX27LW4iv1Er7om+8wUNG9wC18WDaocrLxDlJGz ZVncYoc7HcDB5xypFo+aKN9eyPFqKLTt9rx5wYxE6w/3/HcWTUme0eB3z42cP4dDVnKO FXNt8uqWgwamdR0Y5b73EylfY5SeUekKVQUvZM26Di/yLOZvJH4Gw1ZG4DYvk0n4O7b1 ieN5WLqzmFv5TX0TYlGdx6VMzryFgNdsBtIdxg0sofdaPwVj3Z1cacs4WNFDmjxzTbdw Thhg== 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 v16si881318pfn.294.2018.04.18.03.52.25; Wed, 18 Apr 2018 03:52:39 -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 S1752788AbeDRKvW (ORCPT + 99 others); Wed, 18 Apr 2018 06:51:22 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:47455 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751870AbeDRKvV (ORCPT ); Wed, 18 Apr 2018 06:51:21 -0400 Received: from fsav301.sakura.ne.jp (fsav301.sakura.ne.jp [153.120.85.132]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w3IApApW045297; Wed, 18 Apr 2018 19:51:10 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav301.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav301.sakura.ne.jp); Wed, 18 Apr 2018 19:51:10 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav301.sakura.ne.jp) Received: from [192.168.1.8] (softbank126099184120.bbtec.net [126.99.184.120]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w3IAp6D0045283 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 18 Apr 2018 19:51:10 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Subject: Re: [PATCH 2/2] fs, elf: drop MAP_FIXED usage from elf_map To: Andrew Morton , Michal Hocko Cc: linux-mm@kvack.org, LKML References: <20171213092550.2774-1-mhocko@kernel.org> <20171213092550.2774-3-mhocko@kernel.org> From: Tetsuo Handa Message-ID: <0b5c541a-91ee-220b-3196-f64264f9f0bc@I-love.SAKURA.ne.jp> Date: Wed, 18 Apr 2018 19:51:05 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20171213092550.2774-3-mhocko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From 0ba20dcbbc40b703413c9a6907a77968b087811b Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Wed, 18 Apr 2018 15:31:48 +0900 Subject: [PATCH] fs, elf: don't complain MAP_FIXED_NOREPLACE if mapping failed. 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 Don't complain if IS_ERR_VALUE(), and use %px for printing the address. Signed-off-by: Tetsuo Handa Cc: 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..559d35b 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) && BAD_ADDR(map_addr) && + !IS_ERR_VALUE(map_addr)) + 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