[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190214160821.GB19102@redhat.com>
Date: Thu, 14 Feb 2019 17:08:21 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Kees Cook <keescook@...omium.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Samuel Dionne-Riel <samuel@...nne-riel.com>,
Richard Weinberger <richard.weinberger@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
Graham Christensen <graham@...hamc.com>,
Michal Hocko <mhocko@...e.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] exec: load_script: Allow interpreter argument truncation
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.
Powered by blists - more mailing lists