All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: David Drysdale <drysdale@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Meredydd Luff <meredydd@senatehouse.org>,
	Shuah Khan <shuahkh@osg.samsung.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Kees Cook <keescook@chromium.org>, Arnd Bergmann <arnd@arndb.de>,
	Rich Felker <dalias@aerifal.cx>,
	Christoph Hellwig <hch@infradead.org>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: + syscallsx86-implement-execveat-system-call.patch added to -mm tree
Date: Fri, 14 Nov 2014 01:11:59 +0100	[thread overview]
Message-ID: <20141114001159.GA31545@redhat.com> (raw)

> @@ -1479,7 +1489,26 @@ static int do_execve_common(struct filen
>
>  	bprm->file = file;
> -	bprm->filename = bprm->interp = filename->name;
> +	if (fd == AT_FDCWD || filename->name[0] == '/') {
> +		bprm->filename = filename->name;
> +	} else {
> +		if (filename->name[0] == '\0')
> +			pathbuf = kasprintf(GFP_TEMPORARY, "/dev/fd/%d", fd);
> +		else
> +			pathbuf = kasprintf(GFP_TEMPORARY, "/dev/fd/%d/%s",
> +					    fd, filename->name);
> +		if (!pathbuf) {
> +			retval = -ENOMEM;
> +			goto out_unmark;
> +		}
> +		/* Record that a name derived from an O_CLOEXEC fd will be
> +		 * inaccessible after exec. Relies on having exclusive access to
> +		 * current->files (due to unshare_files above). */
> +		if (close_on_exec(fd, current->files->fdt))
> +			bprm->interp_flags |= BINPRM_FLAGS_PATH_INACCESSIBLE;
> +		bprm->filename = pathbuf;
+	}
+	bprm->interp = bprm->filename;

Not sure I understand this patch, will try to read later...

Just once question, don't we leak pathbuf if exec() succeeds?

OTOH, if it fails,

>  out_free:
>  	free_bprm(bprm);
> +	kfree(pathbuf);

Is it correct if we fail after bprm_change_interp() was called? It seems
that we can free interp == pathbuf twice?

Oleg.


             reply	other threads:[~2014-11-14  0:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14  0:11 Oleg Nesterov [this message]
2014-11-14 14:55 ` + syscallsx86-implement-execveat-system-call.patch added to -mm tree David Drysdale
  -- strict thread matches above, loose matches on Subject: below --
2014-11-12 22:08 akpm

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=20141114001159.GA31545@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=dalias@aerifal.cx \
    --cc=drysdale@google.com \
    --cc=ebiederm@xmission.com \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=meredydd@senatehouse.org \
    --cc=mingo@redhat.com \
    --cc=mtk.manpages@gmail.com \
    --cc=shuahkh@osg.samsung.com \
    --cc=tglx@linutronix.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.