From patchwork Sat Nov 2 12:01:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nir Lichtman X-Patchwork-Id: 13860099 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 7A0CFE677F5 for ; Sat, 2 Nov 2024 12:01:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A5B66B0082; Sat, 2 Nov 2024 08:01:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 854F06B0083; Sat, 2 Nov 2024 08:01:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 744336B0085; Sat, 2 Nov 2024 08:01:40 -0400 (EDT) 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 553806B0082 for ; Sat, 2 Nov 2024 08:01:40 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F2B9C121520 for ; Sat, 2 Nov 2024 12:01:39 +0000 (UTC) X-FDA: 82741014216.19.C832A66 Received: from lichtman.org (lichtman.org [149.28.33.109]) by imf20.hostedemail.com (Postfix) with ESMTP id E68B61C0026 for ; Sat, 2 Nov 2024 12:01:01 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=lichtman.org header.s=mail header.b=ocJMli1t; dmarc=pass (policy=none) header.from=lichtman.org; spf=pass (imf20.hostedemail.com: domain of nir@lichtman.org designates 149.28.33.109 as permitted sender) smtp.mailfrom=nir@lichtman.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730548778; a=rsa-sha256; cv=none; b=IzqV849PdG+o/r2QsP8nSsF8lm3XRMyq5DzPlH+WfYpscW2YeamfJ9D3sDJ/YPUElnweof wdSFG5pC+gUZhvAhnZQAuz4jJUZUlj91kQZj0rBavjxNP+lO6YAKTv5i+yjYLJ0I3tGqSZ n0Pa9qrZkzOKPoIdJv0RH7ZwoX/TnoY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=lichtman.org header.s=mail header.b=ocJMli1t; dmarc=pass (policy=none) header.from=lichtman.org; spf=pass (imf20.hostedemail.com: domain of nir@lichtman.org designates 149.28.33.109 as permitted sender) smtp.mailfrom=nir@lichtman.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730548778; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=IRN117BGvNysk52YGBh1LLXc8BRp6gpJLIoNRy4wKCQ=; b=31jUXNhkoHWOOeToWInyhdUbcv9YyHIGFsa6AkZL6Syx6jc7yFk1NfHL7vztG8RQ9S1NHg 6UMnIgFZQmxrjefSJQnYv/HvL5a60MAE34EKNugmGAdZUhNm4lsz0tA0Jh6FU+5bPa0NhL 6tRUI5SEEMn+fx7aaXwVgucBtuL862I= Received: from nirs-laptop. (unknown [85.130.135.138]) by lichtman.org (Postfix) with ESMTPSA id 60B851770C6; Sat, 2 Nov 2024 12:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=lichtman.org; s=mail; t=1730548897; bh=SejvjcKDxw3BthMfHi6eAtNdZaOvse5g9PgP+P44VkM=; h=Date:From:To:Subject:From; b=ocJMli1teNm9L03WHiBKgGRViUZAzwIoHtSl47gK3ti12ZphgpwIthUhcZFmQHkV2 N815jvatvwAUhUN6MK9xIAI74LlVpCOnwp0xKuOgHTEcsqny1jVC93U8FyFYVyRrGH RrnVfj4KMxqUHaLrYjJrfZwHo9+WkIRp5/54LS4LMirxA/s+xXugkS3/4kwLwsfIQx Bc2DRF+FU7qmAR+ZWBhXqRuXfP1I/b+2uYuXoDAfLkUCAhkxnMqBRlqwmqcEFKyaN8 fNFFkBXtDWzeg362XHvhzGWSkhbuqr2xCzZlmh4PMqGuVAwLyesxe8+oPoIYRiL0PK JtlFyCXZtcXow== Date: Sat, 2 Nov 2024 14:01:22 +0200 From: nir@lichtman.org To: ebiederm@xmission.com, kees@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] exec: move warning of null argv to be next to the relevant code Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Rspamd-Queue-Id: E68B61C0026 X-Stat-Signature: omtowxtui9iw94jd1iefqd7qas158fs1 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1730548861-203366 X-HE-Meta: U2FsdGVkX18MXmPpJRglmaJPq2kaPmJEWgte7q22jpbXHVtcIso5MZPO5abxHgf/R4K2m5pd6L2PAc50cpkNmd9PNfutG6kP3ZFDFSDRfvKQwyHpRtUq6GyL9zaeWRThDSmyUxsCqnWRiMvxaT7PTmb/D1hQIRSs0JkyxcNt3TbDE7w2YfcKMQYBPS79EhZlHl72cX24KZElA6l8W6J0qA5D2XAK1MaYFzf+53Hq/59mUu6DpwndIjlygsLBjIRG6sVlFytkiwnwEnZ0ttmQdNKyaTQmr0vMQn7hIP9g1sM3TXQ8+h9hKf9O9Zor+LMWCR7cp+o47UOnoD1WrahMGviNsNTXIMezmqFb+j8AhHP0ce+2BqTMYFR7pnQFATKY90NlHYo6yIo2ErZzxmdUui/29uSXC62NRahRQ2f+pe5uX21PY0ei3uHeHtUTCHPXvKuGiMF+nWZTtHnzNIyGLr0xAhz3y47zNU5q72dF8sdN5C7tKkDkgGZU1n/HnYLYjtw9J/4z+xrrQem5QfNewX8b9Ayh2aob1Rb466Sop2ry87Eb3VAbaQTl7VBqbR/mZs3772trwa+yoDttSm6RA1R9G/KJus/X8lf/mdpngqKgv8ShBAQgbf1qWperzgh/B9HFiuvZv+lDwXCdd5ZGyl2j5Ff42DdGZ6EaLcKPFMcB68Zp6IcVKpxjBhmTnS7BIWkeHxQwDIJ7k6rmU5AvesraoHYjzmh/fP8UPzNq35I34nldFVwiBjSLmDy4OIT8r2ZHYKM+46xjljYkjcWlJZKFmE5wh46PMsJ111DJAeu+K6gjWxckrEd7EKvYFacPABG1+qXTDmupFGeokjSKpSOkknpsjZMwric4eDoCQviINot/t/Fein+B1RiU+HrdvYVvCjj179UtIbaKtUjYiU1ztMX4PBY8LnDTBrxGliJVPTcpYzcrV9i9wdy19jNbKr2NhCXwwFU7HpT2T66 42duRwuV cm8IuTMUNMvI07XeMumpw6DPbBYG+WaPz0afUya9SnmL+8Vi8+sv3SfJ0pNcaiBSKm5P5UOTfPVhMQa2T1Csnbf1p/OYR1UNJ6+x1FXBTdfbdXklnsxKQANeQzbvmTK/fDuGJtNFH/fUy6nCCb+TsjNSMldctYC7d58NDEm6C8pOSksK0414bW4/0gwy4PMrowJmCE0Z3lRQPYp4SJPNDog/5z8zZzZ4oJ7b3IwZvHJJ54bH7RgSrRsSaVrguy91uqAgIcFo0jZ6CEpDXQOVujYWpg8W972x9OKgQW4MT5s16gScU4dXwagMviA== 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: Problem: The warning is currently printed where it is detected that the arg count is zero but the action is only taken place later in the flow even though the warning is written as if the action is taken place in the time of print This could be problematic since there could be a failure between the print and the code that takes action which would deem this warning misleading Solution: Move the warning print after the action of adding an empty string as the first argument is successful Signed-off-by: Nir Lichtman --- Side note: I have noticed that currently the warn once variant is used for reporting this problem, which I guess is to reduce clutter that could go to dmesg, but wouldn't it be better to have this call the regular warn instead to better aid catching this type of bug? fs/exec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 6c53920795c2..4057b8c3e233 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1907,9 +1907,6 @@ static int do_execveat_common(int fd, struct filename *filename, } retval = count(argv, MAX_ARG_STRINGS); - if (retval == 0) - pr_warn_once("process '%s' launched '%s' with NULL argv: empty string added\n", - current->comm, bprm->filename); if (retval < 0) goto out_free; bprm->argc = retval; @@ -1947,6 +1944,9 @@ static int do_execveat_common(int fd, struct filename *filename, if (retval < 0) goto out_free; bprm->argc = 1; + + pr_warn_once("process '%s' launched '%s' with NULL argv: empty string added\n", + current->comm, bprm->filename); } retval = bprm_execve(bprm);