From patchwork Mon Jul 3 19:58:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 13300456 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48B2BC001B0 for ; Mon, 3 Jul 2023 19:59:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95926280032; Mon, 3 Jul 2023 15:59:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90937280030; Mon, 3 Jul 2023 15:59:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D087280032; Mon, 3 Jul 2023 15:59:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6CE78280030 for ; Mon, 3 Jul 2023 15:59:03 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 32683A0289 for ; Mon, 3 Jul 2023 19:59:03 +0000 (UTC) X-FDA: 80971364166.24.E4056A6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id B7651A0014 for ; Mon, 3 Jul 2023 19:59:00 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QwXrd7Rv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688414341; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=LoUauweNDt2UPReHWwhjgp3VsV7Mm+fSGj9PBNXZlgE=; b=72sbYEgpOyAq4yookc2YsLd457+1ZPJh/MZEPHKcPVKl3hP3uCDRQbQ+Cpfnx25WfK4RYT ZzK6fu8HGuF/ixchyzOcFQMMGJzpE/4UTAI8YvLtW9Hp0udg7ogTd0Af3rEmgzJWmiAFFp pH2B7XsWhApm8nesMQV4LzdMsaOTMvo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QwXrd7Rv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688414341; a=rsa-sha256; cv=none; b=Pe5psU8GW9ZpvPm3hzbDJwbfMcll0iwXoa413fzdLJF+5fETpsBCrAKSaj0dOnmZGEZVJz fPr+1iFjxO8KgeUKaEIyjzup7SZQFi1HKuxY3Dpjs5tg08HthO/zNXve4I8bWrd2Iaa8Lv ui0ovzhC+GBvG2Lae5GFw/Hxa2mw/yg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688414340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=LoUauweNDt2UPReHWwhjgp3VsV7Mm+fSGj9PBNXZlgE=; b=QwXrd7RvGABOL7HxQlNy2FYC2ales6q7K7i9qZS5zXdnmE0D5iCQK8FRHzkA2aC4NnuuDG PHx0UhJaf2T+GuEXgq4dmaA3Pa+vEiGrn2de5j0RRv0ZqzpGx3P9KhO2EvHk6i2wKjUNv9 fUN0DBJLmDyJ+5LSPCrggkZWU+zM6mY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-SiAgHKluOzClhvo0o0Tz-w-1; Mon, 03 Jul 2023 15:58:57 -0400 X-MC-Unique: SiAgHKluOzClhvo0o0Tz-w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68CEB803FDC; Mon, 3 Jul 2023 19:58:56 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9DE4340C2063; Mon, 3 Jul 2023 19:58:55 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id E807E3096A40; Mon, 3 Jul 2023 19:58:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id E32D83F7CF; Mon, 3 Jul 2023 21:58:41 +0200 (CEST) Date: Mon, 3 Jul 2023 21:58:41 +0200 (CEST) From: Mikulas Patocka To: Linus Torvalds cc: Vegard Nossum , John Paul Adrian Glaubitz , Frank Scheiner , "James E.J. Bottomley" , Helge Deller , John David Anglin , Andrew Morton , linux-parisc@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] parisc: fix inability to allocate stack pages on exec Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B7651A0014 X-Stat-Signature: 7bshncd4mqdco7j8ju9uex57q71bhtyo X-HE-Tag: 1688414340-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wsyKV/s+3gHLHCVzzSiwyAUPGb0XI9ih/wrZUF0aUrU88/lRLg9udnxG94hkRBa7Si7nvLO06Vr05zSvd1QTUXM7qHwXT53R/7Pb9B33W8OSi9tT3HkQnRxvsAetrS0TffvCJZ4jmpz1YgvkXTXri5qSNcLKooFVnZzCKBP/dIC7fJ4z9K5ih2eSj5mZICYY= 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: Hi The patch 8d7071af8907 ("mm: always expand the stack with the mmap write lock held") breaks PA-RISC. The breakage happens if we attempt to pass more arguments to execve than what fits into the initial stack page - we get -E2BIG in such a case. The reason for the breakage is that the commit 8d7071af8907 adds the test "if (!(vma->vm_flags & VM_GROWSDOWN)) return -EFAULT;" to the function expand_downwards. expand_downwards is called from get_arg_page to allocate initial stack pages. With the added test for VM_GROWSDOWN, it is not able to allocate any pages on PA-RISC at all, and execve fails as soon as it tries to allocate a stack page. The bug can be fixed by dropping the test for VM_GROWSDOWN from expand_downwards. Fixes: 8d7071af8907 ("mm: always expand the stack with the mmap write lock held") Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org # v6.4 --- mm/mmap.c | 3 --- 1 file changed, 3 deletions(-) Index: linux-6.4.1/mm/mmap.c =================================================================== --- linux-6.4.1.orig/mm/mmap.c 2023-07-03 18:17:35.000000000 +0200 +++ linux-6.4.1/mm/mmap.c 2023-07-03 21:22:44.000000000 +0200 @@ -2036,9 +2036,6 @@ int expand_downwards(struct vm_area_stru struct vm_area_struct *prev; int error = 0; - if (!(vma->vm_flags & VM_GROWSDOWN)) - return -EFAULT; - address &= PAGE_MASK; if (address < mmap_min_addr || address < FIRST_USER_ADDRESS) return -EPERM;