[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGXu5j+h7pE4pyysEj7LO=SgQwokzF29t7dN7RduFBvHeSNsQw@mail.gmail.com>
Date: Wed, 6 Apr 2016 16:50:50 -0700
From: Kees Cook <keescook@...omium.org>
To: Joe Perches <joe@...ches.com>
Cc: James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Kalle Valo <kvalo@...eaurora.org>,
Mauro Carvalho Chehab <mchehab@....samsung.com>,
Guenter Roeck <linux@...ck-us.net>,
Jiri Slaby <jslaby@...e.com>, Paul Moore <pmoore@...hat.com>,
Stephen Smalley <sds@...ho.nsa.gov>,
Mimi Zohar <zohar@...ux.vnet.ibm.com>,
Casey Schaufler <casey@...aufler-ca.com>,
Andreas Gruenbacher <agruenba@...hat.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Ulf Hansson <ulf.hansson@...aro.org>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
linux-security-module <linux-security-module@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/5] string_helpers: add kstrdup_quotable
On Mon, Mar 28, 2016 at 4:30 PM, Joe Perches <joe@...ches.com> wrote:
> On Mon, 2016-03-28 at 14:14 -0700, Kees Cook wrote:
>> Handle allocating and escaping a string safe for logging.
> []
>> diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
> []
>> @@ -68,4 +68,6 @@ static inline int string_escape_str_any_np(const char *src, char *dst,
>> return string_escape_str(src, dst, sz, ESCAPE_ANY_NP, only);
>> }
>>
>> +char *kstrdup_quotable(char *src);
>
> char *kstrdup_quotable(const char *src)
>
> but shouldn't this really take a gfp_t like all
> the other kstr<string> functions?
Ah, good idea, yes. I'll add this.
>> diff --git a/lib/string_helpers.c b/lib/string_helpers.c
> []
>> +char *kstrdup_quotable(char *src)
> []
>> + BUG_ON(string_escape_mem(src, slen, dst, dlen, flags, esc) != dlen);
>
> BUG_ON? why?
I was thinking that if the string_escape_mem output length changes
between calls, something has gone terribly wrong internally, and we
should stop. But, since we're limited to dlen, it'll be a truncation
at worst. I will change this to WARN_ON, which is what kasprintf does.
Thanks!
-Kees
--
Kees Cook
Chrome OS & Brillo Security
Powered by blists - more mailing lists