lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1460548402.6620.128.camel@linux.intel.com>
Date:	Wed, 13 Apr 2016 14:53:22 +0300
From:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:	"Serge E. Hallyn" <serge@...lyn.com>,
	Kees Cook <keescook@...omium.org>
Cc:	James Morris <jmorris@...ei.org>, Joe Perches <joe@...ches.com>,
	Mimi Zohar <zohar@...ux.vnet.ibm.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Jonathan Corbet <corbet@....net>,
	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>,
	Casey Schaufler <casey@...aufler-ca.com>,
	Andreas Gruenbacher <agruenba@...hat.com>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Ulf Hansson <ulf.hansson@...aro.org>,
	Vitaly Kuznetsov <vkuznets@...hat.com>,
	linux-security-module@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org
Subject: Re: [PATCH v4 2/6] string_helpers: add kstrdup_quotable_cmdline

On Tue, 2016-04-12 at 16:19 -0500, Serge E. Hallyn wrote:
> Quoting Kees Cook (keescook@...omium.org):
> > 
> > Provide an escaped (but readable: no inter-argument NULLs)
> > commandline
> > safe for logging.
> > 

Sorry, have no access to the original mail right now.

>> +char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp)
> > +{
> > +	char *buffer, *quoted;
> > +	int i, res;
> > +
> > +	buffer = kmalloc(PAGE_SIZE, GFP_TEMPORARY);
> > +	if (!buffer)
> > +		return NULL;
> > +
> > +	res = get_cmdline(task, buffer, PAGE_SIZE - 1);
> > +	buffer[res] = '\0';
> > +
> > +	/* Collapse trailing NULLs, leave res pointing to last non-
> > NULL. */
> > +	while (--res >= 0 && buffer[res] == '\0')
> > +		;

Nitpick: perhaps leave comment that make more visible
/* nothing */ ;

(up to you)?

> > +
> > +	/* Replace inter-argument NULLs. */
> > +	for (i = 0; i <= res; i++)

But why do you need to check = res? It's already checked by previous
condition and undoubtfully it's non-'\0'.

Forgot to mention this earlier.

> > +		if (buffer[i] == '\0')
> > +			buffer[i] = ' ';

-- 
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Intel Finland Oy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ