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]
Date:	Sat, 28 Dec 2013 18:07:17 -0800
From:	Joe Perches <joe@...ches.com>
To:	Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Cc:	akpm@...ux-foundation.org, geert@...ux-m68k.org, jkosina@...e.cz,
	viro@...iv.linux.org.uk, davem@...emloft.net,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lib/vsprintf: add %pT[C012] format specifier

On Sun, 2013-12-29 at 09:32 +0900, Tetsuo Handa wrote:
> Joe Perches wrote:
> > On Sat, 2013-12-28 at 12:08 -0800, Andrew Morton wrote:
> > > On Sat, 28 Dec 2013 11:53:25 -0800 Joe Perches <joe@...ches.com> wrote:
> > > 
> > > > > > #define PRINTK_PID      "\002"
> > > > > > #define PRINTK_TASK_ID  "\003"  /* "comm:pid" */
> > 
> > > > > >
> > > > > >         printk(PRINTK_TASK_ID ": hair on fire\n");
> > > > > >
> > > > > > It's certainly compact.  I doubt if there's any existing code which
> > > > > > deliberately prints control chars?
> 
> What about using bytes from \x7F to \xFF ?
> 
> We are not passing multibyte characters like UTF-8 in the format string (are
> we?) because the non-first byte of multibyte characters by error matching %
> will cause security problem (format string bug) because the format string is
> parsed as char array.
> 
> Then, we could do something like below.
> 
>   pr_info("%s", current->comm);   => pr_info("\x7F\x80");
>   pr_info("%d", current->pid);    => pr_info("\x7F\x81");
>   pr_info("%10d", current->pid);  => pr_info("\x7F10\x81");
> 
> If precision field support is unnecessary, we could use only \x80 to \xFF .
> 
>   pr_info("%s", current->comm);   => pr_info("\x80");
>   pr_info("%d", current->pid);    => pr_info("\x81");

My preference would be to do something like:

$ cat include/asm-generic/current.h
#ifndef __ASM_GENERIC_CURRENT_H
#define __ASM_GENERIC_CURRENT_H

#include <linux/thread_info.h>

#define get_current() (current_thread_info()->task)
#define current get_current()

#define CURRENT_SUB		"\032"
#define CURRENT_SUB_ASCII	'\032'

#define CURRENT_ID		CURRENT_SUB "1"
#define CURRENT_COMM		CURRENT_SUB "2"
#define CURRENT_TASK_STATE	CURRENT_SUB "3"
#define CURRENT_TASK_PID	CURRENT_SUB "4"
#define CURRENT_TASK_GID	CURRENT_SUB "5"
#define CURRENT_TASK_UID	CURRENT_SUB "6"
#define CURRENT_TASK_FSUID	CURRENT_SUB "7"
#define CURRENT_TASK_FSGID	CURRENT_SUB "8"
/* add more as necessary */

#endif /* __ASM_GENERIC_CURRENT_H */


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ