From patchwork Fri Nov 18 00:34:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 21993 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp706231wrr; Thu, 17 Nov 2022 16:47:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf68KypTRbQAzUvLhd8rr0XUhWTIrZwLCBSu7FgObK5M8uyOOpJkYc6gTnlMKL+9cem4AmX4 X-Received: by 2002:a17:906:4bc4:b0:78d:6325:356 with SMTP id x4-20020a1709064bc400b0078d63250356mr4130749ejv.6.1668732452964; Thu, 17 Nov 2022 16:47:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668732452; cv=none; d=google.com; s=arc-20160816; b=sjOAzG8eWOv0+UfAeCs5Ts56XzMLVJ5LiecO/4gYPMqnSsQncuaOoHZgKK5Thl/WdV 9Z4vTgCV9MQmv8BI05URNs4nIiLjRHfI5a5QRU0dCA4n6plCNOLGboPjfV3xmTylSViU JZzPSt3y3Q2nY2nVmfcFz2Uj3AqUKC9N1eaAv1OXasW0QxazwpN4sg+vJgz9Q1+7mqap UI3dnLIUTxEXGFxHwgME6G/PaYLPplraOCbkWOWjl0KK3KdjZW6HF6xQidl+VJ1/AspG FgZ2WGEGZHz1yaggl7dc7LeSPe/gtT5FufP7CPG4EN3Ct7xc0V5WMyU4UsdUmhyM7Dms HP0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=zfKoIXcdSbSCG4X8dhvdkumwWP5cdUHpW/BAvV90utQ=; b=XAAxjL7+ZqbECehaorjG86X6w4620Aqpkr2NJJatgySjXZ9uu/YbBb0F4gjTbTg+9l 5LdRPYGdw3O2Qt6OeyQfWX1Av3d6/2QpW8QqqSYklZ3FvHCxD+wSOvweC0qZgscFdEW6 EgQbs6jo4A7re9U+2TtGuzPfLbUWbcYVAiYyfrQTPi9BbXTrZg8OVDXHwlMZwB0fUiCg fXoDiY8WOzoaOV0WnG700BzvR+UP3+9lfIzlmFgPkmNZKD/ikI59HDWP80nfNo3/Ibf4 IKDYse68JensSiPUM+twWRWKgTlsMKpZZy3Mb1BymHfSs5kLkbr0uK4uX1L2l/YWFSZb IqSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hBAITYak; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh18-20020a1709076e9200b007ae5fa9b603si1961501ejc.374.2022.11.17.16.47.03; Thu, 17 Nov 2022 16:47:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hBAITYak; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234695AbiKRAeZ (ORCPT + 99 others); Thu, 17 Nov 2022 19:34:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233780AbiKRAeS (ORCPT ); Thu, 17 Nov 2022 19:34:18 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 559A171F22 for ; Thu, 17 Nov 2022 16:34:17 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id u8-20020a17090a5e4800b002106dcdd4a0so6923930pji.1 for ; Thu, 17 Nov 2022 16:34:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zfKoIXcdSbSCG4X8dhvdkumwWP5cdUHpW/BAvV90utQ=; b=hBAITYaklRvHDDl64erxDCykr4u6NNFZ8OfJfZ1JT3AFy1r2suv3k/1rLcyzRXga0N /Gxby+KLLrwQV7OBkH8LYJSkKhJPZmRywFIeLAjhWp9a/BDOFymG1t+YxoeVqcooLMOC THVmW0Q2Ukz0Y0EPe7mbObmo0p8I/djfdpo1U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zfKoIXcdSbSCG4X8dhvdkumwWP5cdUHpW/BAvV90utQ=; b=F+Oi6eDMtDJqUSqH0CWW3UIfawzmvFTVI4BZ6UIlozlLdPz0qvttTATCa+6yHNokOr lPWDN+F0AWxtl7XOjxxtTDzobCFZMSmqwNso/ZqMryNqjoV8RlLTAisbN3cWPrMKJR71 1umMoBDK96YkiKDhBXcIXeOuxE0SxvEwzq8BZw2X317FGv0/o+1V9Qj7vqF/iS/cndQW 2209cOpEh/a+YrQAEs/e0bSJS77eukUM6NNSpZINB9p3vgc32d9Dt2A8Ji+Sa3/W7x5I TY1ev2D3T7LzwOiqTwyU5qyYEID43ZUmMqLI8m2xC4aVt3zbDdgWbAl3SaKVPZ4vc262 Rg2g== X-Gm-Message-State: ANoB5pkVJUKGcju3Bam9bu4ywQCR9gPc/KPC1ulfNWSxo1B00r0YJXR9 Dqp9d5EuiWyECTHf8NF160OaSL2GSMyFBA== X-Received: by 2002:a17:902:9a01:b0:176:cf64:2f39 with SMTP id v1-20020a1709029a0100b00176cf642f39mr5096556plp.93.1668731656837; Thu, 17 Nov 2022 16:34:16 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id m4-20020a170902db0400b0016c50179b1esm2058299plx.152.2022.11.17.16.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 16:34:16 -0800 (PST) From: Kees Cook To: Eric Biederman Cc: Kees Cook , David Hildenbrand , Linus Torvalds , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] exec: Remove FOLL_FORCE for stack setup Date: Thu, 17 Nov 2022 16:34:14 -0800 Message-Id: <20221118003410.never.653-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1103; h=from:subject:message-id; bh=Q3A301qUeRB8tq7dkiRpjGQmp7qcdEcbj6KnmtW0Kwk=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjdtMFIHEE/2aFsG+0+1k2j6trtVeqZg6//sNcJ9PZ qpTOZmaJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY3bTBQAKCRCJcvTf3G3AJmxND/ 4nU1/hNVNbDf3WDg7BJbbkga3ERM+KhF9FnAQVu8KD6VPUt+W3bNr9NimO5ebcKzxJIpAWnFFquFte arvoVm5AdjVA997ZUKDrwC3EfEOyszPX6WaRYz6/CTXy7OFJiJKAgdqiz0rM0Jb/VpEyNJFTQNVyxV wMroI6NjViv6G3EUD1FiAkTEyQvtGBfX4ps6mqXa+VFwFlzH56Pqq95o3+RDaekupGblAKIBILa3px 8qchKhd+rbNaM/5Q+krz/xGgEM3pADGVa1Gc7LcICT0swoJlyfl1/5QZCPntj70a0cp50YlpWLkL48 45rCEUBDdCNJ4zVQ8RGTTK7xxjzkZU/6LtVntk/6bvsujeJDTaexOWPF3/qYjPI2jUerZlakCMj4rf Tgd33LBDRv/KHbPWibXCHmOHgWJwjfNWmVbwxsDs+Yksj/1JiO7OX0fLNJpZn9GbNjmBjfKyz4MjzP c5GmSJFRqJPwPubdfziNeJUTx6BpruAG2rBrcZWSPMAW+hvDOXwvycOVf6FcXrKbuxWDN0o4vHAS4B PtDF7gVEHcr/1T1ve6JOKyFcoF5KHZnCDfMJa7DhDf/f6beMa0KDPvcVSZKFe40c//VyjBP88R8yis ZoZVUu2RUXJONdTela0ORVr6/2I+UkBiTe7Sdd4SleuMafvG7eTx4ES95sfA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749792800890700085?= X-GMAIL-MSGID: =?utf-8?q?1749792800890700085?= It does not appear that FOLL_FORCE should be needed for setting up the stack pages. They are allocated using the nascent brpm->vma, which was newly created with VM_STACK_FLAGS, which an arch can override, but they all appear to include VM_WRITE | VM_MAYWRITE. Remove FOLL_FORCE. Cc: Eric Biederman Cc: David Hildenbrand Cc: Linus Torvalds Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Link: https://lore.kernel.org/lkml/202211171439.CDE720EAD@keescook/ Signed-off-by: Kees Cook Reviewed-by: David Hildenbrand --- fs/exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/exec.c b/fs/exec.c index 9585bc1bc970..870a707b5d3b 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -200,7 +200,7 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos, { struct page *page; int ret; - unsigned int gup_flags = FOLL_FORCE; + unsigned int gup_flags = 0; #ifdef CONFIG_STACK_GROWSUP if (write) {