From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753002AbeDRKvW (ORCPT ); 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 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 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot0-f199.google.com (mail-ot0-f199.google.com [74.125.82.199]) by kanga.kvack.org (Postfix) with ESMTP id 6B2F66B0005 for ; Wed, 18 Apr 2018 06:51:16 -0400 (EDT) Received: by mail-ot0-f199.google.com with SMTP id b6-v6so811881otk.5 for ; Wed, 18 Apr 2018 03:51:16 -0700 (PDT) Received: from www262.sakura.ne.jp (www262.sakura.ne.jp. [202.181.97.72]) by mx.google.com with ESMTPS id g33-v6si327950otc.320.2018.04.18.03.51.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 03:51:15 -0700 (PDT) Subject: Re: [PATCH 2/2] fs, elf: drop MAP_FIXED usage from elf_map 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 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: owner-linux-mm@kvack.org List-ID: To: Andrew Morton , Michal Hocko Cc: linux-mm@kvack.org, LKML