mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rik van Riel <riel@surriel.com>
To: Brian Witte <brianwitte@mailfence.com>, Kees Cook <kees@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner	 <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Lorenzo Stoakes <ljs@kernel.org>,  Jann Horn <jannh@google.com>,
	Helge Deller <deller@gmx.de>,
	Justin Stitt <justinstitt@google.com>,
	 Daniel Micay <danielmicay@gmail.com>,
	Shuah Khan <shuah@kernel.org>,
	linux-fsdevel@vger.kernel.org, 	linux-mm@kvack.org,
	linux-hardening@vger.kernel.org,
		linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] exec: randomize the argument block's offset within its page
Date: Tue, 01 Dec 2026 20:42:13 -0500	[thread overview]
Message-ID: <c4d5915a76f96a9f68613510e4647e93f10e1b8f.camel@surriel.com> (raw)
In-Reply-To: <20261023015345.1594514-2-brianwitte@mailfence.com>

On Fri, 2026-10-23 at 03:54 +0200, Brian Witte wrote:
> bprm->p starts one word below STACK_TOP_MAX, and setup_arg_pages()
> moves the stack only by whole pages, so the argv, envp and execfn
> strings sit at the same offset within their page on every exec. Three
> execs on x86_64 put argv[0] at 0x7ffeee30af9f, 0x7ffdf3709f9f and
> 0x7ffc871e0f9f.
> 
> Lower bprm->p by a random amount under a page before the strings are
> copied: about 12 bits of entropy with 4K pages and 16 with 64K.
> bprm->argmin is derived from bprm->p, so the argument size limit is
> unchanged, but up to a page of RLIMIT_STACK is used.
> 
> ADDR_NO_RANDOMIZE disables the offset; PF_RANDOMIZE cannot be used,
> since load_elf_binary() sets it after the strings are copied.
> PER_CLEAR_ON_SETID also clears the flag for set-id execs only after
> the
> copy, and moving the strings then would mean copying them all. So
> bprm_fill_uid()'s set-id checks are repeated early, without its
> 
I still had to do a little git archeology to
figure out exactly why that test is that way
in bprm_fill_uid(), but a little digging made
it all clear!

> 
> Suggested-by: Daniel Micay <danielmicay@gmail.com>
> Link: https://github.com/KSPP/linux/issues/283
> Signed-off-by: Brian Witte <brianwitte@mailfence.com>

Reviewed-by: Rik van Riel <riel@surriel.com>

-- 
All Rights Reversed.

  reply	other threads:[~2026-12-02  1:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  1:54 [PATCH 0/2] exec: randomize the argument block's in-page offset Brian Witte
2026-10-23  1:54 ` [PATCH 1/2] exec: randomize the argument block's offset within its page Brian Witte
2026-12-02  1:42   ` Rik van Riel [this message]
2026-10-23  1:54 ` [PATCH 2/2] selftests/exec: test the argument block's in-page offset Brian Witte
2026-12-02  1:48   ` Rik van Riel

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=c4d5915a76f96a9f68613510e4647e93f10e1b8f.camel@surriel.com \
    --to=riel@surriel.com \
    --cc=brauner@kernel.org \
    --cc=brianwitte@mailfence.com \
    --cc=danielmicay@gmail.com \
    --cc=deller@gmx.de \
    --cc=jack@suse.cz \
    --cc=jannh@google.com \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=shuah@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

all inboxes | Powered by JetHome®