From: Oleg Nesterov <oleg@redhat.com>
To: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Samuel Dionne-Riel <samuel@dionne-riel.com>,
Richard Weinberger <richard.weinberger@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Graham Christensen <graham@grahamc.com>,
Michal Hocko <mhocko@suse.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] exec: load_script: Allow interpreter argument truncation
Date: Thu, 14 Feb 2019 17:08:21 +0100 [thread overview]
Message-ID: <20190214160821.GB19102@redhat.com> (raw)
In-Reply-To: <20190214012754.GA17326@beast>
On 02/13, Kees Cook wrote:
>
> While we want to make sure the kernel doesn't attempt to execute a
> truncated interpreter path, we must allow the interpreter arguments to
> be truncated. Perl, for example, will re-read the script itself to parse
> arguments correctly.
Heh. I still think that 8099b047ecc4 does the right thing.
But I can't argue with the fact that it caused the regression, so it should
be reverted.
> This documents the parsing steps, and will fail to exec if the string was
> truncated with neither an end-of-line nor any trailing whitespace.
You know, I have already spent 3 hours trying to write something simple and
clear, but failed. Still trying...
Nor I can really understand your fix ;) Will try to read it again, just one
question for now,
> for (cp = bprm->buf+2;; cp++) {
> - if (cp >= bprm->buf + BINPRM_BUF_SIZE)
> - return -ENOEXEC;
> - if (!*cp || (*cp == '\n'))
> + if (cp == bprm->buf + BINPRM_BUF_SIZE - 1) {
> + truncated = true;
Off-by-one, no? "bprm->buf + BINPRM_BUF_SIZE - 1" is the very last char, it can
be '\n' or '\0', this should set end_of_interp.
> break;
> + }
> + if (!*cp || (*cp == '\n')) {
> + end_of_interp = true;
> + break;
> + }
so unless I am totally confused you should move this block up before the
"bprm->buf + BINPRM_BUF_SIZE - 1" check or that check should use
"bprm->buf + BINPRM_BUF_SIZE".
No?
Oleg.
next prev parent reply other threads:[~2019-02-14 16:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-14 1:27 [PATCH] exec: load_script: Allow interpreter argument truncation Kees Cook
2019-02-14 16:08 ` Oleg Nesterov [this message]
2019-02-14 16:38 ` Kees Cook
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=20190214160821.GB19102@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=graham@grahamc.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=richard.weinberger@gmail.com \
--cc=samuel@dionne-riel.com \
--cc=torvalds@linux-foundation.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