public inbox for linux-um@lists.infradead.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Benjamin Berg <benjamin@sipsolutions.net>, linux-um@lists.infradead.org
Cc: Benjamin Berg <benjamin.berg@intel.com>
Subject: Re: [PATCH v6 3/7] um: use execveat to create userspace MMs
Date: Mon, 01 Jul 2024 22:20:41 +0200	[thread overview]
Message-ID: <c900d5ab0131ee3445cc2ed8a08caf671f2f4552.camel@sipsolutions.net> (raw)
In-Reply-To: <20240626135350.493110-4-benjamin@sipsolutions.net>

On Wed, 2024-06-26 at 15:53 +0200, Benjamin Berg wrote:
> 
> +static int __init init_stub_exec_fd(void)
> +{
> +	size_t len = 0;
> +	int res;
> +	char tmpfile[] = "/tmp/uml-userspace-XXXXXX";


That seems awkward, perhaps it should use make_tempfile() from mem.c?

> +		stub_exec_fd = mkostemp(tmpfile, O_CLOEXEC);

mkostemp() also requires _GNU_SOURCE according to the man page? It also
doesn't matter since you reopen the file anyway.

> +		/* Only executable by us */
> +		if (fchmod(stub_exec_fd, 00100) < 0) {
> +			unlink(tmpfile);
> +			panic("Could not make stub binary excutable: %d",
> +			      errno);
> +		}
> +
> +		close(stub_exec_fd);
> +		stub_exec_fd = open(tmpfile, O_CLOEXEC);

Hmm. Technically, I think you _have_ to open for reading, writing, or
both; not none? But then I guess you have to make it readable?

Might also want O_NOFOLLOW here?

> diff --git a/arch/x86/um/stub_elf.c b/arch/x86/um/stub_elf.c
> new file mode 100644
> index 000000000000..2bf1a717065d
> --- /dev/null
> +++ b/arch/x86/um/stub_elf.c

Is stub_elf really the right name? In practice it's going to be an ELF
file, but ... who cares? Not sure why it should be called "elf" vs. just
"stub" or "exec_stub" or something like that.

Also, is it really x86-specific?

> +++ b/arch/x86/um/stub_elf_embed.S

surely that isn't x86-specific?

johannes


  reply	other threads:[~2024-07-01 20:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26 13:53 [PATCH v6 0/7] Increased address space for 64 bit Benjamin Berg
2024-06-26 13:53 ` [PATCH v6 1/7] um: Add generic stub_syscall6 function Benjamin Berg
2024-06-26 13:53 ` [PATCH v6 2/7] um: Add generic stub_syscall1 function Benjamin Berg
2024-06-26 13:53 ` [PATCH v6 3/7] um: use execveat to create userspace MMs Benjamin Berg
2024-07-01 20:20   ` Johannes Berg [this message]
2024-06-26 13:53 ` [PATCH v6 4/7] um: Fix stub_start address calculation Benjamin Berg
2024-06-26 13:53 ` [PATCH v6 5/7] um: Limit TASK_SIZE to the addressable range Benjamin Berg
2024-06-26 13:53 ` [PATCH v6 6/7] um: Discover host_task_size from envp Benjamin Berg
2024-06-26 13:53 ` [PATCH v6 7/7] um: Add 4 level page table support Benjamin Berg
2024-07-03 11:32   ` Johannes Berg

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=c900d5ab0131ee3445cc2ed8a08caf671f2f4552.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=benjamin.berg@intel.com \
    --cc=benjamin@sipsolutions.net \
    --cc=linux-um@lists.infradead.org \
    /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