From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E27EC433E0 for ; Sun, 12 Jul 2020 21:50:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 458A12065F for ; Sun, 12 Jul 2020 21:50:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="OOmgHlYg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 458A12065F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 657376B0002; Sun, 12 Jul 2020 17:50:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E0096B0003; Sun, 12 Jul 2020 17:50:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A9998D0002; Sun, 12 Jul 2020 17:50:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 2FA9A6B0002 for ; Sun, 12 Jul 2020 17:50:44 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8EC97181AEF0B for ; Sun, 12 Jul 2020 21:50:43 +0000 (UTC) X-FDA: 77030768766.24.cord78_310fc5d26ee3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 632A01A4A5 for ; Sun, 12 Jul 2020 21:50:43 +0000 (UTC) X-HE-Tag: cord78_310fc5d26ee3 X-Filterd-Recvd-Size: 6498 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Sun, 12 Jul 2020 21:50:42 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id 6so8623739qtt.0 for ; Sun, 12 Jul 2020 14:50:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=y0Y9Cg878pa612/SC58tikFh/oV/WVfZP31F8tnLOG0=; b=OOmgHlYgE7YnD046QRQELznkE+KLcSALex6ufH1VGqNd4C7sItpmSYOap5tQttlypc jdt6eIo0wKb5ZqE6muON5tsGF2EWAVW1crXJRyDGH0sJUS7gfqhgJ+Ajt8mBTt68XMJr JjrKt2czjqgs70T0mhnF8yH3naCPysmtTAk0c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=y0Y9Cg878pa612/SC58tikFh/oV/WVfZP31F8tnLOG0=; b=mz0aJbu9wHRoVsqDDekT9bmodvvrWIprRKrDwRvdn33UVe97NMVRMQJM1LGMC9iI+n Gti/eeFaQEahzEUBUicQIzxJKbTP15y7/3/arD68VbUUNmn9+bv9JnpNwXONaf5i1yEh ACwQ5BTbx0sbd2m5xmTGeyB6wHArMPNfrknj+qwj5XT/2EeRZ9OB5ySfrMndfe1M1vGw 6AQQmO0T0ogDhkJyytFu9XrAsnPWgxNes0NG7rtkpQ9+O+n9S24RcwsDzjoTUiYnRhKb NfTB+C7aAB0f1wk55LoZC4J/voR16EDtXI1o9QJX08suuVpQB4ybVcTeAnd7JxKkGs/b MxvQ== X-Gm-Message-State: AOAM531PoXWf3aypgdoovIjPcBO58/o6wQwGmE+4aRfZh7PwxJaetMlr WozAD7VAGkQLkhovD8s1m/uOHg== X-Google-Smtp-Source: ABdhPJwlXOHXDmN+gWJ3YpyLEA5rsIV6twy1fVkifMEu75+iS99ioKgeA467G+sdg4i7myUitvTUXw== X-Received: by 2002:ac8:c4e:: with SMTP id l14mr67127104qti.106.1594590642283; Sun, 12 Jul 2020 14:50:42 -0700 (PDT) Received: from localhost ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id p7sm16209284qki.61.2020.07.12.14.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 14:50:41 -0700 (PDT) Date: Sun, 12 Jul 2020 17:50:41 -0400 From: Joel Fernandes To: Linus Torvalds Cc: Naresh Kamboju , linux- stable , open list , linux-mm , Arnd Bergmann , Andrew Morton , Roman Gushchin , Michal Hocko , lkft-triage@lists.linaro.org, Chris Down , Michel Lespinasse , Fan Yang , Brian Geffon , Anshuman Khandual , Will Deacon , Catalin Marinas , pugaowei@gmail.com, Jerome Glisse , Greg Kroah-Hartman , Mel Gorman , Hugh Dickins , Al Viro , Tejun Heo , Sasha Levin Subject: Re: WARNING: at mm/mremap.c:211 move_page_tables in i386 Message-ID: <20200712215041.GA3644504@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 632A01A4A5 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jul 09, 2020 at 10:22:21PM -0700, Linus Torvalds wrote: > On Thu, Jul 9, 2020 at 9:29 PM Naresh Kamboju wrote: > > > > Your patch applied and re-tested. > > warning triggered 10 times. > > > > old: bfe00000-c0000000 new: bfa00000 (val: 7d530067) > > Hmm.. It's not even the overlapping case, it's literally just "move > exactly 2MB of page tables exactly one pmd down". Which should be the > nice efficient case where we can do it without modifying the lower > page tables at all, we just move the PMD entry. Hi Linus, I reproduced Naresh's issue on a 32-bit x86 machine and the below patch fixes it. The issue is solely within execve() itself and the way it allocates/copies the temporary stack. It is actually indeed an overlapping case because the length of the stack is big enough to cause overlap. The VMA grows quite a bit because of all the page faults that happen due to the copy of the args/env. Then during the move of overlapped region, it finds that a PMD is already allocated. The below patch fixes it and is not warning anymore in 30 minutes of testing so far. Naresh, could you also test the below patch on your setup? thanks, - Joel ---8<----------------------- From: Joel Fernandes Subject: [PATCH] fs/exec: Fix stack overlap issue during stack moving in i386 When running LTP's thp01 test, it is observed that a warning fires in move_page_tables() because a PMD is already allocated. This happens because there is an address space overlap between the temporary stack created and the range it is being moved to when the move_page_tables() is requested. During the move_page_tables() loop, it picks the same valid PMD that was already allocated for the temporary stack. This loop requires the PMD to be new or it warns. Making sure the new location of the stack is non-overlapping with the old location makes the warning go away. Fixes: b6a2fea39318e ("mm: variable length argument support"). Reported-by: Naresh Kamboju Signed-off-by: Joel Fernandes (Google) --- fs/exec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/exec.c b/fs/exec.c index e6e8a9a703278..a270205228a1a 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -755,6 +755,10 @@ int setup_arg_pages(struct linux_binprm *bprm, stack_shift = vma->vm_end - stack_top; + /* Ensure the temporary stack is shifted by atleast its size */ + if (stack_shift < (vma->vm_end - vma->vm_start)) + stack_shift = (vma->vm_end - vma->vm_start); + bprm->p -= stack_shift; mm->arg_start = bprm->p; #endif -- 2.27.0.383.g050319c2ae-goog