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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 642FDE7716D for ; Wed, 4 Dec 2024 23:50:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9502D6B007B; Wed, 4 Dec 2024 18:50:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 900976B0083; Wed, 4 Dec 2024 18:50:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EECA6B0085; Wed, 4 Dec 2024 18:50:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5FB836B007B for ; Wed, 4 Dec 2024 18:50:13 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CC9731C7DEF for ; Wed, 4 Dec 2024 23:50:12 +0000 (UTC) X-FDA: 82858921992.27.CB3D2B9 Received: from kawka3.in.waw.pl (kawka3.in.waw.pl [68.183.222.220]) by imf18.hostedemail.com (Postfix) with ESMTP id 46FEB1C0008 for ; Wed, 4 Dec 2024 23:50:04 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of zbyszek@in.waw.pl designates 68.183.222.220 as permitted sender) smtp.mailfrom=zbyszek@in.waw.pl ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733356204; a=rsa-sha256; cv=none; b=aoUF9seOvmYAjRo9JbTiyoFXL7+RdqR8bzQcd7TzEUTLbj+/sr3MvAD6RlIa3hopP4r1XZ /1GMQcEmfnqFSIYcsp4U/u46iRglUsxop3fr+6ocIuc68LXoOzuh+au5ytiuTTa67o+Iuj FO43i0yEumNOW1UDbjPglc45fE2600Q= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of zbyszek@in.waw.pl designates 68.183.222.220 as permitted sender) smtp.mailfrom=zbyszek@in.waw.pl ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733356204; 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:in-reply-to:references:references; bh=zKwXrxgqbkVJUcwVEj6nj4vBCGAUChQ/GpLI7ng0OYo=; b=D5ez2zf7K9lRfFbsQeUG5xa+CM38yiPpB0M1dvFZU0LeUPNkRcCjku3iU+sAKJReTke4S8 XsOuEg8iTzWHVEoTBvteJ2KE7HoJ5J+ldLabm+SjSC0K0C3DTZifONKfp8Mg3kA7L1ZllJ j+BhajGile5W9QRQQazvi/9J2Il39Wc= Received: by kawka3.in.waw.pl (Postfix, from userid 1000) id C2F315B99BA; Wed, 4 Dec 2024 23:50:08 +0000 (UTC) Date: Wed, 4 Dec 2024 23:50:08 +0000 From: Zbigniew =?utf-8?Q?J=C4=99drzejewski-Szmek?= To: Kees Cook Cc: Aleksa Sarai , Al Viro , Tycho Andersen , Linus Torvalds , Eric Biederman , Christian Brauner , Jan Kara , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case Message-ID: References: <20241130045437.work.390-kees@kernel.org> <20241130.055433-shy.herds.gross.wars-zGaSWwzAa56n@cyphar.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241130.055433-shy.herds.gross.wars-zGaSWwzAa56n@cyphar.com> X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 46FEB1C0008 X-Stat-Signature: ikopxeytwaqmxyjeya8ajgq69gjyuzph X-HE-Tag: 1733356204-391907 X-HE-Meta: U2FsdGVkX18pNgZpqlqnBsw80h0j30YN/qD6fOPmPke+HrmRJOsXz7h1xrTR9LVDwJzcjf/4YHXTup+b6zhkqHDHCgVvpzphTcOSFQglekmvOi3d2pALeAuuBhEyBy6whovFkuaCv6s0RwFIu9nXSN7AFeaxDiSgmTkjIZmFSu9fHXnFNV9m+o3ucT2CSiplC8N7RYh2Pe9yijzjCGW/K/yXhU8c95GeMI4kRjh9UkRe4E4qzt9VlKM/xwmBM/7HjiNCxb2oHQvZ+lFW9K7yn92iAeG8b286ttrV0MSniTO728h+6vLPqlm6lVUCxqpl4h2RuBe24HQX3xcEwZe5DKjPpQmRYl9+C22WELHTtBiGUx7GClfBzI009mMFmTGruHFmapwybGzSYLir81rgwbV4uTPv9tl4a6hVjVZ0VJM4BdzsuVqNhE980coHMLipiGTACjZbWlJBhgtME7s16I6utWhtXlPsNozwoSvRhH1RSwiC+QVSQjVzaHZayiBFoNjqA6RPgxBsC4hPN9ffXNlQgaKrWrmCysOOxWfby7zvZGMWkwghA8lRcHnVlP2WO/5BzTiPopPLjyqNjjo8AdsMKN3e3fmyHZ5K98LvTO247R1znT0WIgVpyc1wmM0MQmP89dfiMRJTMQjslznfm8h15gfgOsO/VIlPr/l1Nsegpaee7A9WC8pxhFf6YCSEl+VuciMVsyff+1afm6R5HUvuvjJ/nDxgMwhrwSwpmiru0m4gpBEiRbZpNIrATuDCUSKi44bocvJqG91y+ZG9zi4uWXm7p72pXb5JLbHomVXx62Scevd9d4FEHTwCNuuIEXjJCanbL3Z4cQDSQFatcQzn6TF2wVt5almJl55PYeyaVX8ZCDhSFOu6KgGKDvdfcd8jqkmQ7CO02WGstRhMTELxXY5IH4myaMuYONB0XVH+Hozy+b5hYhZUp47eEuG9otoe/8+l5m+kPs8+5eP INKEXETc 3Rv08ib6DxvdaDLGNYHv5MmBqJj7afAHpZXUaxMmTazzXW0yeDnpgcoP3bMSQckbyUOTnUB4bQwH+2gEg9bD0RA+NFikcvoiWE/V3WNYq2eBKJE7kk3UlskvkPyubG7noEi616ZGQ6WjveDno72HLz5dzH8uwjUVn+UR3QDEFOJ46b1HW/LJInHNX/lIplMXiml0Q8kwg6tDWOUsB6SRjKdOr7xwwhZuprOOuPU/gSvH6e1Z74D85LlbZKp9SbSyxnyn/qBdVN760pTE= 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: List-Subscribe: List-Unsubscribe: On Sat, Nov 30, 2024 at 04:55:09PM +1100, Aleksa Sarai wrote: > On 2024-11-29, Kees Cook wrote: > > Zbigniew mentioned at Linux Plumber's that systemd is interested in > > switching to execveat() for service execution, but can't, because the > > contents of /proc/pid/comm are the file descriptor which was used, > > instead of the path to the binary. This makes the output of tools like > > top and ps useless, especially in a world where most fds are opened > > CLOEXEC so the number is truly meaningless. > > > > When the filename passed in is empty (e.g. with AT_EMPTY_PATH), use the > > dentry's filename for "comm" instead of using the useless numeral from > > the synthetic fdpath construction. This way the actual exec machinery > > is unchanged, but cosmetically the comm looks reasonable to admins > > investigating things. > > > > Instead of adding TASK_COMM_LEN more bytes to bprm, use one of the unused > > flag bits to indicate that we need to set "comm" from the dentry. > > Looks reasonable to me, feel free to take my > > Reviewed-by: Aleksa Sarai Thank you for making another version of the patch. I tested this with systemd compiled to use fexecve and everything seems to work as expected (the filename in /proc//comm). Zbyszek