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:	Tue, 20 Aug 2013 15:35:22 +0930
From:	Rusty Russell <rusty@...tcorp.com.au>
To:	Chen Gang <gang.chen@...anux.com>, jg1.han@...sung.com,
	khali@...ux-fr.org, David.Woodhouse@...el.com
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kernel/params.c: use scnprintf() instead of sprintf()

Chen Gang <gang.chen@...anux.com> writes:

> For some strings (e.g. version string), they are permitted to be larger
> than PAGE_SIZE (although meaningless), so recommend to use scnprintf()
> instead of sprintf().

Applied.

Thanks,
Rusty.

>
> Signed-off-by: Chen Gang <gang.chen@...anux.com>
> ---
>  kernel/params.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/params.c b/kernel/params.c
> index 1f228a3..4da300f 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -241,7 +241,8 @@ int parse_args(const char *doing,
>  	}								\
>  	int param_get_##name(char *buffer, const struct kernel_param *kp) \
>  	{								\
> -		return sprintf(buffer, format, *((type *)kp->arg));	\
> +		return scnprintf(buffer, PAGE_SIZE, format,		\
> +				*((type *)kp->arg));			\
>  	}								\
>  	struct kernel_param_ops param_ops_##name = {			\
>  		.set = param_set_##name,				\
> @@ -285,7 +286,7 @@ EXPORT_SYMBOL(param_set_charp);
>  
>  int param_get_charp(char *buffer, const struct kernel_param *kp)
>  {
> -	return sprintf(buffer, "%s", *((char **)kp->arg));
> +	return scnprintf(buffer, PAGE_SIZE, "%s", *((char **)kp->arg));
>  }
>  EXPORT_SYMBOL(param_get_charp);
>  
> @@ -827,7 +828,7 @@ ssize_t __modver_version_show(struct module_attribute *mattr,
>  	struct module_version_attribute *vattr =
>  		container_of(mattr, struct module_version_attribute, mattr);
>  
> -	return sprintf(buf, "%s\n", vattr->version);
> +	return scnprintf(buf, PAGE_SIZE, "%s\n", vattr->version);
>  }
>  
>  extern const struct module_version_attribute *__start___modver[];
> -- 
> 1.7.7.6
--
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