linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kalle Valo <kvalo@codeaurora.org>,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Joe Perches <joe@perches.com>, Guenter Roeck <linux@roeck-us.net>,
	Jiri Slaby <jslaby@suse.com>, Paul Moore <pmoore@redhat.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Casey Schaufler <casey@schaufler-ca.com>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	linux-security-module <linux-security-module@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/5] string_helpers: add kstrdup_quotable_cmdline
Date: Wed, 6 Apr 2016 16:38:17 -0700	[thread overview]
Message-ID: <CAGXu5jLvQinwyY9ksP+iaT8kN1jOHiFzjq4=sBR2XJT7RNv4HA@mail.gmail.com> (raw)
In-Reply-To: <1459336290.5907.39.camel@linux.intel.com>

On Wed, Mar 30, 2016 at 4:11 AM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, 2016-03-30 at 14:07 +0300, Andy Shevchenko wrote:
>> On Mon, 2016-03-28 at 14:14 -0700, Kees Cook wrote:
>
>
>> > +   res = get_cmdline(task, buffer, PAGE_SIZE - 1);
>> > +   buffer[res] = '\0';
>> > +
>> > +   /* Collapse trailing NULLs. */
>> > +   for (; res > 0; res--)
>> > +           if (buffer[res-1] != '\0')
>> > +                   break;
>> /* buffer[res] is '\0', so, predecrement is safe here */
>> while (buffer[--res] == '\0')
>>  /* nothing */;
>>
>> ?
>>
>
> Oops, no, the following should be better
>
> while (--res >= 0 && buffer[res] == '\0') ;

Sure, I'll change it. Though I'll need to adjust the next loop's use
of res (since it effectively changes from "number of bytes" counter to
"location of last non-null byte" (i <= res).

-Kees

-- 
Kees Cook
Chrome OS & Brillo Security

  reply	other threads:[~2016-04-06 23:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-28 21:14 [PATCH v2 0/5] LSM: LoadPin for kernel file loading restrictions Kees Cook
2016-03-28 21:14 ` [PATCH v2 1/5] string_helpers: add kstrdup_quotable Kees Cook
2016-03-28 23:30   ` Joe Perches
2016-04-06 23:50     ` Kees Cook
2016-03-28 21:14 ` [PATCH v2 2/5] string_helpers: add kstrdup_quotable_cmdline Kees Cook
2016-03-30 11:07   ` Andy Shevchenko
2016-03-30 11:11     ` Andy Shevchenko
2016-04-06 23:38       ` Kees Cook [this message]
2016-03-28 21:14 ` [PATCH v2 3/5] string_helpers: add kstrdup_quotable_file Kees Cook
2016-03-28 21:14 ` [PATCH v2 4/5] Yama: consolidate error reporting Kees Cook
2016-03-28 21:14 ` [PATCH v2 5/5] LSM: LoadPin for kernel file loading restrictions Kees Cook
2016-03-28 21:38   ` Andrew Morton
2016-03-28 21:58     ` Kees Cook
2016-03-30 20:24     ` Mimi Zohar
2016-03-28 23:20   ` Joe Perches
2016-03-31 21:24   ` Mimi Zohar
2016-04-04 19:31     ` Kees Cook
2016-04-04 23:03       ` Mimi Zohar

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='CAGXu5jLvQinwyY9ksP+iaT8kN1jOHiFzjq4=sBR2XJT7RNv4HA@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=agruenba@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=casey@schaufler-ca.com \
    --cc=jmorris@namei.org \
    --cc=joe@perches.com \
    --cc=jslaby@suse.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=linux@roeck-us.net \
    --cc=mchehab@osg.samsung.com \
    --cc=pmoore@redhat.com \
    --cc=sds@tycho.nsa.gov \
    --cc=serge@hallyn.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vkuznets@redhat.com \
    --cc=zohar@linux.vnet.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).