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 B5A00C54E55 for ; Thu, 7 Mar 2024 09:22:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46EAD6B0134; Thu, 7 Mar 2024 04:22:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 41F466B0138; Thu, 7 Mar 2024 04:22:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30E106B0139; Thu, 7 Mar 2024 04:22:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 223656B0134 for ; Thu, 7 Mar 2024 04:22:04 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F0393C0311 for ; Thu, 7 Mar 2024 09:22:03 +0000 (UTC) X-FDA: 81869701326.03.06C70EE Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf10.hostedemail.com (Postfix) with ESMTP id 4329AC001E for ; Thu, 7 Mar 2024 09:22:02 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=g5fCY2Rk; spf=pass (imf10.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709803322; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IX5iM6M24QSta8+xuk0LUf7SeEIWUgitZF8G9QXeS3E=; b=uNtL3kSMfTn0XTv2yNAGinF/YXrBmtGv+dgtuRK0zEkpdw2EjtIw+vlYbDZ1IadmIxJ9rd QH5AWfC2TUk1fBwNPbsLNZOyd4O9Pu6D5Bo32scoYJUlHSXB5LUvj/gxzXx/rdrNhky6pv E6Gm4QmcaKRilUQ1MYL1/olFem56CTs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709803322; a=rsa-sha256; cv=none; b=j8trJut2zRHpr9RxPtr4v7jws0n/AFjXEmRTvGrcyOGa8BoX3qVWxmw+k3GfpoQmADHm4O 3gr6fT8hubQLvExS5Tfmyd5f/Utqu5D+Zj7MibghdoNM/Ys30AgSG06XmiSpLSuHg88md0 GtA5hvrUO5dhoPnsM9DwERM7tCQOqgA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=g5fCY2Rk; spf=pass (imf10.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1709803320; bh=6iqoDRc9RjwEw4cRyfIUcA4bB68ye1om5KId/6dzsa8=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=g5fCY2Rkol6ztpSrz/yatNxAFRhYOzdVjBa7zly9pDCklbhxF04LXgpu2LJdaJtMY n4zZzYJ3LBGhQse1dCkcl0YwDMfe3c+tesu/pnBV+bJ7/VMIDlD/qw+Mq+iOldFtIb d1UCQwY9G9rkBwrw/TXk+YUXqag/WBPvfh9ExjNDUgobn+uBFXMdpNsBaIF+gTa+bf IbWIlJU0AuWocasWpLcOMIuLlj7Qo07ev7CTeyN5tu1Bdl06c1XheWBoDI9skT8r70 Z0WX6B/AQoIY33ayCS8XxxJp4klj4GOiHoNCcoRLKPQXEdzo2NJwAHEcV3wAnWIXTy TvgINlSx5m5Cw== Received: from [10.193.1.1] (broslavsky.collaboradmins.com [68.183.210.73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 85F8D3780624; Thu, 7 Mar 2024 09:21:58 +0000 (UTC) Message-ID: Date: Thu, 7 Mar 2024 14:22:27 +0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , Eric Biederman , Shuah Khan , Mark Brown , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "kernel@collabora.com" Subject: Re: [Test Failure Report] exec: Test failures in execveat To: Kees Cook References: <02c8bf8e-1934-44ab-a886-e065b37366a7@collabora.com> <202403051256.7A50FE28E7@keescook> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <202403051256.7A50FE28E7@keescook> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: ef6t6fr7hwoku1gu4nbzskdh94qjhbju X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 4329AC001E X-Rspam-User: X-HE-Tag: 1709803321-781497 X-HE-Meta: U2FsdGVkX1+9P4Y2mb4/Vhv4jGhhrY6afZpxLvPMtIC65COB73Zp8ml5ieWU31QausZ5PtVPkx8rWd9OgggtcM1k1RpgNz1uaYp9Mb069u7oF1/iLcvCQkBN3PZe6nnKASsGlqCxyw59kPEVH63Re9iQ5yGsQlDJF6mBF2+44dQP9aJPbw6ajtmtxzAqyarSsjKnLh5KIdHqjO10JKRa/Rx0Se8cr1m7nXT4rwRmWAt8Dr71XcdQ6oyIx4iU7OXCgIfl7YX0O3aRnJCRKVXA2nH8zgaMsG+NuNsMrTafaSNwgHh0wkEgWdEGk68pLGDuxAFSEsXCXCUKlOUtnRRxaJQsjqt2mowqG8ABemXHacxG4iSzIvW1hkmbdCWOrcsj8vgIkrSi9URsZdQs9CysFsI5oZiq2henlCavbkGyctH1UvoTto2Myieq9TXwpemAmAro9y6JrCyFGs4Q4bTVz3rbVFiUKfqhNw6pD8y6Gvsd55F/WwOH5zKN2XrdPiSGqwteV3wuqZEOOhX0IZNcuxzpOUrgpTa5e9UBJFrgN0Ai2zQIJk9N9EAWLb64bZ5ELPk+oVEUrW5VtbuaogTmL4HwzhbBCUOCSYs7GZ5Qx8vKKuEkkglOLw3N994qFkRezbmBvfhpD3unHHk6OvAxOCMeO+jFKXcZl9vAu3VPH0lWKkeey+Yy01Au8nCA87dxbgLKQHGkXyr3GzNx7MBYvfXsrTwfKT60zmvdYAGtbnlKaQRq/tfmuDO73BnrKUYodOE3KzPbfov/OtiBr2EGl94heKPr0GPUV0CxeE+8KJe8xpuWRnx1VcSYw1OX/KN3rHXNQvqoDD4fS+zinw5Xs9WieVyPScOC8ruC42OpChGLb4xLFjmRS7TRw0gHEIzGrIsk1P7dih0VbtVp0x3ii6lEPpyQeNv1n6i9jxlacsYgKiYKrxLq+YUKUIW916Y8sRCpzVpfrGZ64eB8Rwc lpmN3ccD 7Q/+C X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, 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 3/6/24 2:00 AM, Kees Cook wrote: > On Tue, Mar 05, 2024 at 07:20:27PM +0500, Muhammad Usama Anjum wrote: >> Hello, >> >> I've been running execveat (execveat.c) locally on v6.1 and next-20240228. >> It has flaky test case. There are some test cases which fail consistently. >> The comment (not very clear) on top of failing cases is as following: >> >> /* >> * Execute as a long pathname relative to "/". If this is a script, >> * the interpreter will launch but fail to open the script because its >> * name ("/dev/fd/5/xxx....") is bigger than PATH_MAX. >> * >> * The failure code is usually 127 (POSIX: "If a command is not found, >> * the exit status shall be 127."), but some systems give 126 (POSIX: >> * "If the command name is found, but it is not an executable utility, >> * the exit status shall be 126."), so allow either. >> */ >> The file name is just less than PATH_MAX (4096) and we are expecting the >> execveat() to fail with particular 99 or 127/128 error code. But kernel is >> returning 1 error code. Snippet from full output: >> >> # child 3493092 exited with 1 not 99 nor 99 >> # child 3493094 exited with 1 not 127 nor 126 >> >> I'm not sure if test is wrong or the kernel has changed the return error codes. > > The error code is actually coming from the script interpreter (in this > case, "/bin/sh"). On my system, /bin/sh is /bin/dash, and I see the > failure. If I manually change "script" to use "#!/bin/bash", the test > passes for me. > > Since lots of other selftests appears to depend on /bin/bash, I think > the right fix is simply: > > > diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c > index bf79d664c8e6..0546ca24f2b2 100644 > --- a/tools/testing/selftests/exec/execveat.c > +++ b/tools/testing/selftests/exec/execveat.c > @@ -393,7 +393,7 @@ static int run_tests(void) > static void prerequisites(void) > { > int fd; > - const char *script = "#!/bin/sh\nexit $*\n"; > + const char *script = "#!/bin/bash\nexit $*\n"; > > /* Create ephemeral copies of files */ > exe_cp("execveat", "execveat.ephemeral"); > > > Can you test this and let me know if this fixes it for you? I've tested this patch. Still getting same failures. > > Thanks for the report! > > -Kees > -- BR, Muhammad Usama Anjum