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 A9EADC54EE9 for ; Tue, 20 Sep 2022 22:21:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B88C8940008; Tue, 20 Sep 2022 18:21:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B38A8940007; Tue, 20 Sep 2022 18:21:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D913940008; Tue, 20 Sep 2022 18:21:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 90749940007 for ; Tue, 20 Sep 2022 18:21:15 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 59F5A4100B for ; Tue, 20 Sep 2022 22:21:15 +0000 (UTC) X-FDA: 79933885710.09.F20A219 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf16.hostedemail.com (Postfix) with ESMTP id DAD6118000B for ; Tue, 20 Sep 2022 22:21:14 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id y11so4542215pjv.4 for ; Tue, 20 Sep 2022 15:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=upw72VMgBHjGqZ0U19GWpMgzVWGJTdhRQ+B6JpzBzhI=; b=XaT90E8n2dHZfoQg35IwewP1F01hNnFj3HR28CQPhteLbf8K8/qzEfH4PnmvQwUc1l Vu5c/N1czJLmPcijnABkGU3shW911nCwc2oVYG2knnKsFI1BDQSZF90+wU/meXdN5gS7 I8viMtcF9E/E7sWpN7MRpPJZUesU/n2ObnUtE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=upw72VMgBHjGqZ0U19GWpMgzVWGJTdhRQ+B6JpzBzhI=; b=2IRFm/oMfA1UyselmCdDkXQugfRqOryCGMEAkVSeVrLQiBFQi6spDE/yBxT4mMrWw+ RSZHAM+L6bQxFiNuTmH1cGIX4MrZTWfTSMuneeO+107L8IJgn0he4DVKVZdGQxuBFxHk z7EwEpEbhvUuwAORsPAdF1kDuA9u9xcJ6y3AMNkgWrS7pog/TbQFWIHYLUEQDLmofGSM EjsbZK88Ad4yBHHe1mM80xhGJ/IIrzOnXedjQWO5Mkruv+7CwHw3D+BWQ/aH8jtECZMV b/ENNFggPSvcnsMwqE7BgFD+xOI08WW3m5bkFKsfdxf9B0zLWzHR3u83ySj5LAyF2Md3 hWkQ== X-Gm-Message-State: ACrzQf3kc0tU907jG1YdmEinduSS1umtT2CQiaYl0OYpBWGbxUMjwE21 QpEzsdpX6pUy9nM9c+7DokiNIw== X-Google-Smtp-Source: AMsMyM6nY7sNxH3PAXOplIR0CNRRrYOg/61kDeU+ppTPOusz6Hzev6Euv38+l4THkA3nyZ4g+ysgFw== X-Received: by 2002:a17:902:ec82:b0:178:6b70:7eca with SMTP id x2-20020a170902ec8200b001786b707ecamr1729657plg.164.1663712473795; Tue, 20 Sep 2022 15:21:13 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x4-20020a1709027c0400b001637529493esm426472pll.66.2022.09.20.15.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 15:21:13 -0700 (PDT) Date: Tue, 20 Sep 2022 15:21:11 -0700 From: Kees Cook To: "Eric W. Biederman" Cc: Ren Zhijie , viro@zeniv.linux.org.uk, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, tanghui20@huawei.com Subject: Re: [PATCH] exec: Force binary name when argv is empty Message-ID: <202209201516.966D6EF@keescook> References: <20220920120812.231417-1-renzhijie2@huawei.com> <87sfkmyumv.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87sfkmyumv.fsf@email.froward.int.ebiederm.org> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663712475; a=rsa-sha256; cv=none; b=AMx1mSQxlhn5uCVd7458VCKUKRZ0dYjF2C3vGQ7KH3b3B6SZG4jN8UYVmxW33BgWzn1qL5 Cs5t2d6hVj/SNG5UAuh5X7/Sqp/re/+czc15RLSeLR9HMv7H4JZE4eDeEJfATvRw2ynXZC A1HkU7REPmp9CQ9Rgl5MdPl3NjfVgT4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=XaT90E8n; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf16.hostedemail.com: domain of keescook@chromium.org designates 209.85.216.41 as permitted sender) smtp.mailfrom=keescook@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663712475; 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:dkim-signature; bh=upw72VMgBHjGqZ0U19GWpMgzVWGJTdhRQ+B6JpzBzhI=; b=xofnCADthVfq3WVC4rEmJusEzJ07Jo4J2bWH/15is6Xv5F26PEbwfp7BkFF2hpfKTLGpYw zZhBy7X9Bj9kFhlAz4jA9jFoNnFaxWt5MGf7Nt9/3GpFc+uwuXdSBc0Vkugno41Hg0J1zw eBXjTaILkZA4whWkkiux+n6LyktFH9s= X-Rspamd-Queue-Id: DAD6118000B Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=XaT90E8n; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf16.hostedemail.com: domain of keescook@chromium.org designates 209.85.216.41 as permitted sender) smtp.mailfrom=keescook@chromium.org X-Rspamd-Server: rspam08 X-Rspam-User: X-Stat-Signature: c7qbjrsj4t1cokgqf68mcfkdg4e9mw7z X-HE-Tag: 1663712474-3749 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: On Tue, Sep 20, 2022 at 09:42:48AM -0500, Eric W. Biederman wrote: > Ren Zhijie writes: > > From: Hui Tang > > > > First run './execv-main execv-child', there is empty in 'COMMAND' column > > when run 'ps -u'. > > > > USER PID %CPU %MEM VSZ RSS TTY [...] TIME COMMAND > > root 368 0.3 0.0 4388 764 ttyS0 0:00 ./execv-main > > root 369 0.6 0.0 4520 812 ttyS0 0:00 > > > > The program 'execv-main' as follows: > > > > int main(int argc, char **argv) > > { > > char *execv_argv[] = {NULL}; > > pid_t pid = fork(); > > > > if (pid == 0) { > > execv(argv[1], execv_argv); > > } else if (pid > 0) { > > wait(NULL); > > } > > return 0; > > } The correct fix is to userspace here: int main(int argc, char **argv) { - char *execv_argv[] = {NULL}; + char *execv_argv[] = { argv[1], NULL }; pid_t pid = fork(); if (pid == 0) { > [...] > For a rare case that should essentially never happen why make it > friendlier to use? Why not fix userspace to add the friendly name > instead of the kernel? > > Unless there is a good reason for it, it would be my hope that in > a couple of years all of the userspace programs that trigger > the warning when they start up could be fixed, and we could have > execve start failing in those cases. Agreed -- the goal is to help userspace fix how execve(2) is called. Speaking to the proposed patch, this idea was considered during the development of the ""-adding patch, with the basic outcome being that creating a _new_ behavior was not a good idea, and might cause more confusion. You can see the thread here: https://lore.kernel.org/all/202202021229.9681AD39B0@keescook/ -Kees -- Kees Cook