Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp538207ybh; Sun, 12 Jul 2020 14:52:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHFwQl1wqYpod2jti7ltxG10/hYQLdQRM87QgdPv949jjzlUaA9GOhKPpiK4JD1cs5Iqa8 X-Received: by 2002:a50:a451:: with SMTP id v17mr68346182edb.256.1594590737196; Sun, 12 Jul 2020 14:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594590737; cv=none; d=google.com; s=arc-20160816; b=lCkUPyF3KFy5k1g/IXaSjt94ZR6RgI4zt1ssvicTMHF4IKeWt5AeQWlo0+9DReICE2 QsHwXeLGGhX8BONCGZpQ5CqGoRF1jVSps9S69MYk/+S/P1Q1hznj2mUWNiIrkWm/tpnA tedg3gRsT2ZgujaOSO/rvqYts8TkKhtWL8p8v07g4u/0sA+QDxY7k0pOKRTv9rJZijMf Bb185a9XGChus8T6UOqby+pE9PG3yjfRsmcA4YphaX1nKFbm7y9/kUtCB8EB8oWlNJjs KRzA2MwkU+KOErpGgXoUq3YkrPA1lWMihAZLE5W5IblAqg/hUBv/40+m+d8HbfgR2WJF wRsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=y0Y9Cg878pa612/SC58tikFh/oV/WVfZP31F8tnLOG0=; b=BX8jqEB+TtuEs7g0dsr8L+0o+HyhlBuGsrookXuKAm8wSjADVBTQoofWAzxnDz5nar xt3XYaqbOqxJmhvYvkakHKjrs1H03Q4dy57+rEFaWjP5j5l0qmVtE3xIwqeGdpcPEMv0 d1FCwHwZ9PZWWwoZKFDAwDjZ/33Pr2E536PiQnh9YlFqtekB5a5B0TsuNH6gJrEN45pO uyXY1aGapGZ3x2Bf2Ldyis6AgzwcXJVgjMsHOXBm3QhmABisoDP1vjHBNtiMUNJzBR2x gtVZOasou0djd+5QSTbf5dnuVEsA8CiPvUbJwZW/1ia4zsnwCd0AQ70MRq3IfFwLBDq6 nccw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=OOmgHlYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga5si8776369ejb.567.2020.07.12.14.51.39; Sun, 12 Jul 2020 14:52:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=OOmgHlYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729509AbgGLVun (ORCPT + 99 others); Sun, 12 Jul 2020 17:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729398AbgGLVun (ORCPT ); Sun, 12 Jul 2020 17:50:43 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 232D0C061794 for ; Sun, 12 Jul 2020 14:50:43 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id a32so8619576qtb.5 for ; Sun, 12 Jul 2020 14:50:43 -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=SPLdsD04TXWspgfz/DCD7SbLEXn8807m1uxzjYW6SZyQ00LzsCLsEU7TdlbbzaGnID zFiK+Emqupnb6tpSCSELRsM9eitqz5rFvYNEd2oQYSzlhoyOFczcQ2GeD8IqdWDhQRE/ pz8+3siUfPl1QlDTwzIOTjBIS+I2z1wwdJZQxueouA5LhW7R/WLo/NtwOutGmDZdQwsR euiGd4qc/ljjdIiYmnhY6i6+odjyEuyn1uQbJAM3yEvgdBZ/8E8Wgmeyr5kuSEAq5BbT SN75yn6/E1yaG5L31n6DqElGp6v7EF0nlTGNhacMBauPS4eEWbtUu3v0JLAUbNJkBgYd t3Lw== X-Gm-Message-State: AOAM531zqe1gYQUVuvJIE6Z7YYazUKGVy9K5Q0YvYc++0aDwvxtXlgBX xeY+uoqNEApdl4OHObNbvmqPtWv0JUI= 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: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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