From patchwork Fri Jun 21 20:50:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13708057 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 4FCAEC2BB85 for ; Fri, 21 Jun 2024 20:50:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 318EA8D01A4; Fri, 21 Jun 2024 16:50:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A04E6B04A2; Fri, 21 Jun 2024 16:50:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1400D8D01A4; Fri, 21 Jun 2024 16:50:53 -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 E37426B04A1 for ; Fri, 21 Jun 2024 16:50:52 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 90F6614111F for ; Fri, 21 Jun 2024 20:50:52 +0000 (UTC) X-FDA: 82256089944.21.7218BEC Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf07.hostedemail.com (Postfix) with ESMTP id 9225A40007 for ; Fri, 21 Jun 2024 20:50:50 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SAve3cmy; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of kees@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=kees@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719003042; a=rsa-sha256; cv=none; b=qcgMYumDT3JUWyeIeKeXW3bxNVf9KC2VbqMlIBhvcPjO6e2bqGYVbQk4UcjYyT0wQoS7gq xat9EB96xL/XGWNR2cSCxcpCIetjaWc74x6O5WFw3Xn5rkQZ6+2/iFK7QSRetrPB91RbJW AmubT5jY3KBCP9Dk4IbSV9z8946/M5A= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SAve3cmy; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of kees@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=kees@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719003042; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=BgIh+TfVSA3cRH2Y+OkWyyRYibmbtfiYHiJ7Nlt7opE=; b=peYMkgC6dsvSSCKBVZ3h3q1zRzSifDlG6RRQQI+WH6GZpSmPT+AatSWyi6dprPPL1mUW9g 3m9HZG108PMt842igL657Vj8hQcs4dIOUQffG8xY4kCJxKp0IRfID5pXmkWS8e7F1as+ti avsFH3c+2cyGRNTTDmRc0JK+L3XwUlY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 50495CE3CFC; Fri, 21 Jun 2024 20:50:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FC28C32789; Fri, 21 Jun 2024 20:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719003046; bh=zHqrm6LL14pN7J1jPUokZ61GJ0sIujqExqHulesYufY=; h=From:To:Cc:Subject:Date:From; b=SAve3cmy5p6v3u6W23zkp6N5P7Zdim1KxMhtleXv1qc7zUJI6hRPGLiX2F9y/4Vwv hL1YERb7sBSgwHGOIBvKEy0x+x3Ox0gs0WYdOlrfAhKMeZQn/VxH+rsHBpgYpH4QZt LCQC4+YiHsoXNSSB9SMz3fEedx2BfAjbYP/M/BXmD8JxAjxLOw0KIKINUUC0C3KUld eRwGrjcgSEnaANo4EpfU2uhJa+el0gq91npAlfpLF88LC9Y6YGt5exhPDcb7LmrSqV pdFc19/VpqBtqMdXSIVxpK4WAWQ9Erq5NBGDuljncaao8jBZcLS44VDjL7pBoRzSyt X+ukufO/bgjPQ== From: Kees Cook To: Guenter Roeck Cc: Kees Cook , Eric Biederman , Al Viro , Christian Brauner , Jan Kara , Alexey Dobriyan , Laurent Vivier , Lukas Bulwahn , Justin Stitt , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 0/2] exec: Avoid pathological argc, envc, and bprm->p values Date: Fri, 21 Jun 2024 13:50:42 -0700 Message-Id: <20240621204729.it.434-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=747; i=kees@kernel.org; h=from:subject:message-id; bh=zHqrm6LL14pN7J1jPUokZ61GJ0sIujqExqHulesYufY=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmdeekF5ynV+ysPDMpgOdN67QrunEd2yLM61lDt iaaLnVb092JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZnXnpAAKCRCJcvTf3G3A JrRYEACJcwXSeETPWX0azPcrjVE+k6pOKsR5cASZRppf73qGPz3sjtne2MfnPOSPHl3lGdu3pZa cHvqfcCZwciotGUh2dfRbyGs9LHlNGJz9Un31oYqiq+wvX2x6sNCNa8jG8FO+cu4cPn8lqISJHt V9QKDv9AKKj+s3qTSLVdRveg4xcuJHTV+A8R882GHLqMo12QMgA3G/CM/VZIofhKj7WTHs2LsfQ l679COtEFu5FSHOzlchAl0f86zhtYq2E6pTNsCLPNKY0NbhMtWuv1PIjJbS2SvkjSb2NMPBhsDJ KLTstbfZ9Ja+57aQRoZdereYMKSNFylYAZHI/7UDoBaCCsDNKnu6T2mcWsksKFMXfsr7AfaqR6v kuOR5Ibj3cJmS4PFE2ShtlsCzypdV7m+gQNqyTK8FMyQzMFeWseRGkbSbQYrbptfAdJqKrgdzs1 sP502r4NtJCvjIrTjWQjUnoGJ0fLXlaSBezY005UpCudsJfOjFe3Pv7CzocvGhDm5z7XQ3IIyhl Sf7S5D/Yh4E5xIvzlvmxQCjMFmOAEiDXJ46bZTztybyI3afN87kEYNj27D6GMxzrQs+x2n2SDIC B/fYFnoA542S0/X5lJBtOWl8I2GUAu6hNXhTCOExcFmT68jQ8YijBC1r+nymoYSfuMG5/bN11SZ wjC829 Q5mJWK0Z g== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Rspamd-Queue-Id: 9225A40007 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: g6prdncawsn14nfq3e1fh3km4onbo8gy X-HE-Tag: 1719003050-363105 X-HE-Meta: U2FsdGVkX19OrBhJlY8fOkdixeQalf7F8clzOhLdS5uhdVoPC0rZE/e57rSwt5g6t3eT55aGUqT6mnc5nLdk8yoovS/H6iBwLULdjZR9LKPT7/gLqihTLQ5MZ5Vy71XO0UgQl3tssUj7g8OnOHw3hb9g0rV/Pe06iNlGCUlC9gd5vzlCdj0QoO85i+wPBUs/++OdPfrIpT0zSlIoEvzNs1cdP2sMzUoyG9MOM+S9vqBWd4emqZ+5otTCiY8coa4kzMPLfrOvHVdJIg26wvPV4imymngPhB9rl7E1WYhSRGJoIpog9BKt/FEYheM2lafK0akuTie9KoC7x4gVO0tpXHoF4n6YtUv0itaAtvMpzovSxKGTxtOsahZ5D696W3+DMzV4GPgJ39yAU9pvp2b+vKQaYbwvqJoYbqExg1uWHM6KFSkggZJLh8b9m0XM4k1YSbWT0yPCXmCd2XmIpPSeogrvw9JDkqUC2Fl7qNJSv2Tc5LpN2e/0ynHtSMoohcRHA1Gfl6E0MAvpSRLq68rY721ox/4kpyeLt7Ascdo+ekl4XRjeqAyCJzqFyYn79W+NGVE4C0tvYdPnGQeaTzGG/CrVmUxV8ASIy6ZgUqAnjTfeq1/CWv6YvgtRWoCVbjwm42Y1rl85Xe808OCGE7xvXH2LZJFaGZASTOs5xMrsDV0562V8TqVujycbC/HZT9+9qBQPS0l4N5A05OEyjlJHROiUzhtUnl7HTLOY4xgSl0PGgdRxqCkj3Y+caXOs4ZmDCkKiiui2fuCP8qyMKSrZaxvcxLE3LyTB0vHlsNxSqE3bHGsTTIYR3gtWyNnvQfIaf9hhG6uzYxNNRAE5ijhKPl7QCYBetZ0NwVt3c2BKVW9TAe0IKuruvZG8Uyv99OZIzESTwRnSn3HPyXyB5yYpHaHnJLEOmyhOrnt88Udl2cqWRAq+m1s6FKoHROiSUWIqKzfRdPp1d2SydQqtEtr /B4hR7U7 6XiHsnv1cOrrpSWTe+glANoOrzgbMGLs9F7/uw++mdq4yIENZ9kO9lWuO8tGwGvLA6hIuvJAzs23uNGIFZsZ+5EIL6cL5gV2+qEAXQvS60dSw5SxXVH7QWyQ7+IrO/LLNEMnc78wauhZELr7sQ9lEaTOXH1e4Kf6vjw7rWCirM2Dz79redJiKwvhxaXpd50xZA4Mf8stz/qkxyOabZ34eOwMKvQY9v41rbSroCmwXJ8ktUUbFX3OGqVCjvyI9ohUJtppU3G1oZ1B6EtUAu86eu2JDL8MtOfSgoirajPmPR+kNWNhRo9WJ09IBKkduRgBZdp2Vd0GJxrpe0cRIvucBFsXtJrwOllAzsWbV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000033, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, This pair of patches replaces the last patch in this[1] series. Perform bprm argument overflow checking but only do argmin checks for MMU systems. To avoid tripping over this again, argmin is explicitly defined only for CONFIG_MMU. Thank you to Guenter Roeck for finding this issue (again)! -Kees [1] https://lore.kernel.org/all/20240520021337.work.198-kees@kernel.org/ Kees Cook (2): execve: Keep bprm->argmin behind CONFIG_MMU exec: Avoid pathological argc, envc, and bprm->p values fs/exec.c | 36 +++++++++++++++++++++++++++++------- fs/exec_test.c | 30 +++++++++++++++++++++++++++++- include/linux/binfmts.h | 2 +- 3 files changed, 59 insertions(+), 9 deletions(-)