All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Christoph Jaeger <christophjaeger@linux.com>
Cc: linux-kernel@vger.kernel.org,
	Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>,
	Jon Mason <jon.mason@intel.com>,
	tech.support@emulex.com, "David Woodhouse" <dwmw2@infradead.org>,
	Michal Nazarewicz <mina86@mina86.com>
Subject: Re: [PATCH 1/1] module: fix sprintf format specifier in param_get_byte()
Date: Wed, 07 Aug 2013 16:13:57 +0930	[thread overview]
Message-ID: <87y58eov9u.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1375823532-24153-1-git-send-email-christophjaeger@linux.com>

Christoph Jaeger <christophjaeger@linux.com> writes:
> In param_get_byte(), to which the macro STANDARD_PARAM_DEF(byte, ...) expands,
> "%c" is used to print an unsigned char. So it gets printed as a character what
> is not intended here. Use "%hhu" instead.
>
> Signed-off-by: Christoph Jaeger <christophjaeger@linux.com>

Nice patch.  Unfortunately, there are several users of this already:

drivers/net/wireless/cw1200/main.c:50:module_param_array_named(macaddr, cw1200_mac_template, byte, NULL, S_IRUGO);
drivers/ntb/ntb_transport.c:68:module_param(max_num_clients, byte, 0644);
drivers/scsi/lpfc/lpfc_attr.c:4207:module_param(lpfc_prot_guard, byte, S_IRUGO);
drivers/usb/atm/speedtch.c:117:module_param(ModemMode, byte, S_IRUGO | S_IWUSR);
drivers/usb/atm/speedtch.c:121:module_param_array(ModemOption, byte, &num_ModemOption, S_IRUGO);
drivers/usb/gadget/g_ffs.c:95:module_param_named(bDeviceClass,    gfs_dev_desc.bDeviceClass,    byte,   0644);
drivers/usb/gadget/g_ffs.c:97:module_param_named(bDeviceSubClass, gfs_dev_desc.bDeviceSubClass, byte,   0644);
drivers/usb/gadget/g_ffs.c:99:module_param_named(bDeviceProtocol, gfs_dev_desc.bDeviceProtocol, byte,   0644);

I have CC'd all the authors, to see if changing the results of reading
/sys/module/<modname>/parameters/<xxx> from a literal char to a number
will harm them.

Thanks,
Rusty.

> ---
>  kernel/params.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/params.c b/kernel/params.c
> index 440e65d..59f7ac7 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -252,7 +252,7 @@ int parse_args(const char *doing,
>  	EXPORT_SYMBOL(param_ops_##name)
>  
>  
> -STANDARD_PARAM_DEF(byte, unsigned char, "%c", unsigned long, strict_strtoul);
> +STANDARD_PARAM_DEF(byte, unsigned char, "%hhu", unsigned long, strict_strtoul);
>  STANDARD_PARAM_DEF(short, short, "%hi", long, strict_strtol);
>  STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, strict_strtoul);
>  STANDARD_PARAM_DEF(int, int, "%i", long, strict_strtol);
> -- 
> 1.8.3.1

  parent reply	other threads:[~2013-08-07  6:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 21:12 [PATCH 1/1] module: fix sprintf format specifier in param_get_byte() Christoph Jaeger
2013-08-06 23:39 ` Joe Perches
2013-08-07  6:43 ` Rusty Russell [this message]
2013-08-07 11:31   ` Michal Nazarewicz
2013-08-07 16:45   ` Jon Mason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y58eov9u.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=christophjaeger@linux.com \
    --cc=dmitry.tarnyagin@lockless.no \
    --cc=dwmw2@infradead.org \
    --cc=jon.mason@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mina86@mina86.com \
    --cc=tech.support@emulex.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.