* [PATCH net-next] bonding: don't cast const buf in sysfs store
@ 2018-07-22 8:37 Nikolay Aleksandrov
2018-07-22 17:09 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Aleksandrov @ 2018-07-22 8:37 UTC (permalink / raw)
To: netdev; +Cc: j.vosburgh, vfalico, andy, roopa, davem, Nikolay Aleksandrov
As was recently discussed [1], let's avoid casting the const buf in
bonding_sysfs_store_option and use kstrndup/kfree instead.
[1] http://lists.openwall.net/netdev/2018/07/22/25
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
drivers/net/bonding/bond_sysfs.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 6096440e96ea..35847250da5a 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -160,14 +160,19 @@ static ssize_t bonding_sysfs_store_option(struct device *d,
{
struct bonding *bond = to_bond(d);
const struct bond_option *opt;
+ char *buffer_clone;
int ret;
opt = bond_opt_get_by_name(attr->attr.name);
if (WARN_ON(!opt))
return -ENOENT;
- ret = bond_opt_tryset_rtnl(bond, opt->id, (char *)buffer);
+ buffer_clone = kstrndup(buffer, count, GFP_KERNEL);
+ if (!buffer_clone)
+ return -ENOMEM;
+ ret = bond_opt_tryset_rtnl(bond, opt->id, buffer_clone);
if (!ret)
ret = count;
+ kfree(buffer_clone);
return ret;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] bonding: don't cast const buf in sysfs store
2018-07-22 8:37 [PATCH net-next] bonding: don't cast const buf in sysfs store Nikolay Aleksandrov
@ 2018-07-22 17:09 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-22 17:09 UTC (permalink / raw)
To: nikolay; +Cc: netdev, j.vosburgh, vfalico, andy, roopa
From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Date: Sun, 22 Jul 2018 11:37:31 +0300
> As was recently discussed [1], let's avoid casting the const buf in
> bonding_sysfs_store_option and use kstrndup/kfree instead.
>
> [1] http://lists.openwall.net/netdev/2018/07/22/25
>
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Applied, thanks Nikolay.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-22 18:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-22 8:37 [PATCH net-next] bonding: don't cast const buf in sysfs store Nikolay Aleksandrov
2018-07-22 17:09 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).