From: Kees Cook <keescook@chromium.org>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: ariadne@dereferenced.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, ebiederm@xmission.com,
viro@zeniv.linux.org.uk
Subject: Re: [PATCH] fs/exec: require argv[0] presence in do_execveat_common()
Date: Wed, 26 Jan 2022 16:00:01 -0800 [thread overview]
Message-ID: <202201261558.DAA974162@keescook> (raw)
In-Reply-To: <YfFigbwhImLQqQsQ@localhost.localdomain>
On Wed, Jan 26, 2022 at 06:02:25PM +0300, Alexey Dobriyan wrote:
> > execve("...", NULL, NULL);
>
> I personally wrote a program which relies on execve(NULL) to succeed.
> It wasn't an exploit, it was test program against IMA-like kernel
> "only whitelisted executables can run" feature.
>
> Test copies and "corrupts" itself by appending \0 to the end, then tries
> to reexec itself with execve("/proc/self/exe", NULL, NULL);
> main() if run with argc==0 exits with specific error code.
>
> Appending \0 breaks checksum so working kernel protection scheme must
> not allow it, therefore if execve(NULL) succeeded, than the parent
> process doing test hard fails.
>
> Also appending \0 doesn't break ELF structure. In other words,
> if executable A is working (and it is working because it is running)
> then A||\0 is valid executable as well and will run too.
>
> This is independent from filesystem layout, libc, kernel, dynamic
> libraries, compile options and what not.
>
> Now QNX doesn't allow execve(NULL) and I don't remember if I changed it
> to the next simplest variant and I don't work anymore at that company,
> so I can't check :^)
>
> execve("/proc/self/exe", (char*[]){"Alexey", NULL}, NULL);
One of the various suggestions was to inject { path, NULL } when argc=0.
Given that execve(path, NULL, ...) is being used at least a little,
hopefully there is nothing that depends on argc==0... :P
--
Kees Cook
next prev parent reply other threads:[~2022-01-27 0:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 15:02 [PATCH] fs/exec: require argv[0] presence in do_execveat_common() Alexey Dobriyan
2022-01-27 0:00 ` Kees Cook [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-01-26 4:39 Ariadne Conill
2022-01-26 6:42 ` Kees Cook
2022-01-26 7:28 ` Kees Cook
2022-01-26 11:18 ` Ariadne Conill
2022-01-26 12:33 ` Heikki Kallasjoki
2022-01-26 23:57 ` Kees Cook
2022-01-27 0:20 ` Eric W. Biederman
2022-01-26 16:59 ` David Laight
2022-01-26 13:27 ` Rich Felker
2022-01-26 14:46 ` Christian Brauner
2022-01-26 17:37 ` Ariadne Conill
2022-02-01 20:54 ` hypervis0r
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202201261558.DAA974162@keescook \
--to=keescook@chromium.org \
--cc=adobriyan@gmail.com \
--cc=ariadne@dereferenced.org \
--cc=ebiederm@xmission.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).