Received: by 10.192.165.156 with SMTP id m28csp1119227imm; Wed, 18 Apr 2018 04:35:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+V7ginU1ZC24HIHNpXQY40RTpsGCOfetThHlg8Qnltt0v5oHQ5LeQzMjTp0j7hexOXwA/u X-Received: by 2002:a17:902:aa43:: with SMTP id c3-v6mr1756988plr.17.1524051303555; Wed, 18 Apr 2018 04:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524051303; cv=none; d=google.com; s=arc-20160816; b=L2vs4YFIV8HTWZSAeFUnhLGU6UBrPC2adHjqMJLXteSkXVFu+hgTDKR+W3LK/km7j/ t+kU0ajoAS1fR5t1GXJ4dohaHKFEEotqFNncY772INmq2OKZF3sIi0+gOKUk4cKcQUs3 bxZoSNakhlxvmX621Dj0wk2avPkRFiTrPBQkEX2MBy9YOrl5sMjSKeP2cP9wvvVLqMJ0 NUKmwKPNt3S+0P1x865B1rtaVgacdfFpjn24+M7e1FQtDpBiMjukla68k5E7/WaPUtD4 zEFg5gaS1xjkefBaPnFaUZveIMI6v7H4XUm4lEmsP4OpigIfYxJJDLEFioWfJazTVBWk itCw== 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=P1O6f00/mEhMuesxQmHyOmzDp4U9Y7t/wTapVx6E77I=; b=X8b8p8IwnXztmVGGh+xq2D1lCIOGbmm1jSFitc1wfCYfP1DVBpQ3FXg0MEwR/rPhiI yBvr49KsUssd38yY5CdFqsBcKtnXf/FW6A49wlT37auPG6LVOy//NtzoxCfobJxIqmx+ x8MWqa7OZWvO5RpwMzHo+x/Opt+h0Qc2RIL+vZmsCH4N3BjU7+Zw/IxfW6OLX578ZG8F xScP3xwiMMoZcoIKUnspVOm74mM9g2iOz4bAVbU/ovENefFDfy8m1k/WjZJPILO160Hi 83pFbPBSKDnNVbWjNYJe4M1fGxlixMPHaA79cQFsXuKMW7T2tOv7I/Dc7cG9RND+QghD orZA== 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 w27si927113pge.638.2018.04.18.04.34.49; Wed, 18 Apr 2018 04:35:03 -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 S1753611AbeDRLdE (ORCPT + 99 others); Wed, 18 Apr 2018 07:33:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:53603 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753520AbeDRLdD (ORCPT ); Wed, 18 Apr 2018 07:33:03 -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 0163CAF26; Wed, 18 Apr 2018 11:33:01 +0000 (UTC) Date: Wed, 18 Apr 2018 13:33:01 +0200 From: Michal Hocko To: Tetsuo Handa Cc: Andrew Morton , linux-mm@kvack.org, LKML Subject: Re: [PATCH 2/2] fs, elf: drop MAP_FIXED usage from elf_map Message-ID: <20180418113301.GY17484@dhcp22.suse.cz> References: <20171213092550.2774-1-mhocko@kernel.org> <20171213092550.2774-3-mhocko@kernel.org> <0b5c541a-91ee-220b-3196-f64264f9f0bc@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0b5c541a-91ee-220b-3196-f64264f9f0bc@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 19:51:05, Tetsuo Handa wrote: > >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 Hmm this is ENOMEM. > Don't complain if IS_ERR_VALUE(), this is simply wrong. We do want to warn on the failure because this is when the actual clash happens. We should just warn on EEXIST. > 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 > > -- Michal Hocko SUSE Labs