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] [day] [month] [year] [list]
Message-ID: <877fs9yjqr.fsf@x220.int.ebiederm.org>
Date:	Fri, 15 May 2015 09:54:04 -0500
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	Nicolas Iooss <nicolas.iooss_linux@....org>
Cc:	Alexander Viro <viro@...iv.linux.org.uk>,
	linux-fsdevel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org,
	Linux Containers <containers@...ts.linux-foundation.org>
Subject: Re: [PATCH v2 2/2] coredump: add __printf attribute to cn_*printf functions

Nicolas Iooss <nicolas.iooss_linux@....org> writes:

> This allows detecting improper format string at build time, like:
>
>   fs/coredump.c:225:5: warning: format '%ld' expects argument of type
>   'long int', but argument 3 has type 'int' [-Wformat=]
>        err = cn_printf(cn, "%ld", cprm->siginfo->si_signo);
>        ^
>
> As si_signo is always an int, the format should be %d here.

Acked-by: "Eric W. Biederman" <ebiederm@...ssion.com>
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@....org>
> ---
>  fs/coredump.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/fs/coredump.c b/fs/coredump.c
> index 833a57bc856c..e52e0064feac 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -70,7 +70,8 @@ static int expand_corename(struct core_name *cn, int size)
>  	return 0;
>  }
>  
> -static int cn_vprintf(struct core_name *cn, const char *fmt, va_list arg)
> +static __printf(2, 0) int cn_vprintf(struct core_name *cn, const char *fmt,
> +				     va_list arg)
>  {
>  	int free, need;
>  	va_list arg_copy;
> @@ -93,7 +94,7 @@ again:
>  	return -ENOMEM;
>  }
>  
> -static int cn_printf(struct core_name *cn, const char *fmt, ...)
> +static __printf(2, 3) int cn_printf(struct core_name *cn, const char *fmt, ...)
>  {
>  	va_list arg;
>  	int ret;
> @@ -105,7 +106,8 @@ static int cn_printf(struct core_name *cn, const char *fmt, ...)
>  	return ret;
>  }
>  
> -static int cn_esc_printf(struct core_name *cn, const char *fmt, ...)
> +static __printf(2, 3)
> +int cn_esc_printf(struct core_name *cn, const char *fmt, ...)
>  {
>  	int cur = cn->used;
>  	va_list arg;
> @@ -225,7 +227,8 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
>  				break;
>  			/* signal that caused the coredump */
>  			case 's':
> -				err = cn_printf(cn, "%ld", cprm->siginfo->si_signo);
> +				err = cn_printf(cn, "%d",
> +						cprm->siginfo->si_signo);
>  				break;
>  			/* UNIX time of coredump */
>  			case 't': {
--
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