Received: by 10.192.165.156 with SMTP id m28csp319542imm; Wed, 18 Apr 2018 22:59:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+nqqI4nLGbJ/glQuGBKD0aAQRy7Pb8IAX1ygRSPjbbqdBZhRompsEQt8JWYXoy144Rgwjn X-Received: by 2002:a17:902:788b:: with SMTP id q11-v6mr4836624pll.76.1524117596640; Wed, 18 Apr 2018 22:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524117596; cv=none; d=google.com; s=arc-20160816; b=OC7HEdl+VsmTuIy5gRY1lB3DHjvd929wi9RYxelIJT9I0/VO1ZbWMj3PMXxJp1wKSe PLmSZt6nAOHQfkFUsfKNewYTdp70t7Q5h59dV3MFOeWriU/I3VFdZ0jI8a5Iu9Umk84L 011RPJujpD8P6PYr96fbga11E0K2ysrhYLu0P2eoPefxdgRocsDIqX74AIis3aSAX8+w OEynqJfyxfPvgYbbJ8WWEx0NHLjBLPHYvnK4AhJJQGaR+3Ztpy++AGgpbIGCdoKkAKNy Rpwy6KnlRlbh6axk0PwwgN49iVWjii7F0LegYpmL3YRLuBYG7Z/HyrMQp+z9vQnP7Qev qtHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=HdG6+xjGybOU+VWLEPKTiD+cug0VxcvlCG3gyYfLzOU=; b=iOLWacFt2JJzF8Gdj2UpXasfHGyn+7G1dCBLJ9ohQLHcKVWauu7PNjNqdD6ptrKsFD +9yx7k5MkFFi7W5V8LJQyVxkQwhYeEsPrxr4GzCx+uoxJxRvIhySA4t5gJXoyTfbeOhp sCnZLxe/0uiNwAwGCM1ybhFdrn2uxOjjs+zzpwOsy0G0ownMx9F9VCrLsaNxBpqebx+y uippNDn7ULmLN/ibwxngZ9uZR+snL7Vs96I7Mu+rqYwVYl91IgKLEDd6raKFED7T+QD5 Wi+jhTUFbCoFU9Vx0p/vnZMCHtQUaOmHsuK5Ku6TYXOjnlT5Ev6FvPEub+c95v5pwC6w kGeQ== 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 h1-v6si2782825plh.375.2018.04.18.22.59.42; Wed, 18 Apr 2018 22:59:56 -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 S1753336AbeDSF6Z (ORCPT + 99 others); Thu, 19 Apr 2018 01:58:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:37120 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752649AbeDSF6Y (ORCPT ); Thu, 19 Apr 2018 01:58:24 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 954C7AFC0; Thu, 19 Apr 2018 05:58:22 +0000 (UTC) Date: Thu, 19 Apr 2018 07:57:54 +0200 From: Michal Hocko To: Tetsuo Handa Cc: akpm@linux-foundation.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: Re: [PATCH v2] fs, elf: don't complain MAP_FIXED_NOREPLACE unless -EEXIST error. Message-ID: <20180419055754.GH17484@dhcp22.suse.cz> 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> <201804182307.FAC17665.SFMOFJVFtHOLOQ@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201804182307.FAC17665.SFMOFJVFtHOLOQ@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 18-04-18 23:07:12, Tetsuo Handa wrote: > >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 Thanks! > --- > 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 -- Michal Hocko SUSE Labs