From: Johannes Berg <johannes@sipsolutions.net>
To: Javier Lopez <jlopex@gmail.com>
Cc: linux-wireless@vger.kernel.org, linville@tuxdriver.com, j@w1.fi,
javier@cozybit.com
Subject: Re: [PATCH v6] mac80211_hwsim driver support userspace frame tx/rx
Date: Wed, 25 May 2011 20:54:19 -0700 [thread overview]
Message-ID: <1306382059.3407.12.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <1306350193-3003-1-git-send-email-jlopex@gmail.com> (sfid-20110525_210407_046264_235EE93A)
On Wed, 2011-05-25 at 21:03 +0200, Javier Lopez wrote:
> +static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
> + struct sk_buff *skb)
> +{
> + if (wmediumd_pid) {
> + mac80211_hwsim_tx_frame_nl(hw, skb);
> + return true;
> + } else
> + return mac80211_hwsim_tx_frame_no_nl(hw, skb);
> +}
This is racy. That wouldn't be an issue at all, but you also have
> mac80211_hwsim_tx_frame(hw, skb);
> - dev_kfree_skb(skb);
> + if (!wmediumd_pid)
> + dev_kfree_skb(skb);
so that a race could lead to a double-free or a leak (not sure which
one, maybe both depending on which way it races). I suppose _tx_frame()
should just always consume the SKB so you have only one check. And maybe
use ACCESS_ONCE() or something so the compiler doesn't play tricks.
> + if (nla_len(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]) !=
> + sizeof(struct mac_address))
> + goto out;
The policy should catch this. I think I may have pointed you to this
erroneously, possibly because I missed the policy (don't remember seeing
it before) -- should the policy really be in a header file? Normally
static variables shouldn't really be since they'd get duplicated, though
I must admit in this special case it seems very unlikely that two files
would include the header.
> +out:
> + return -1;
This is -EPERM ("Permission denied") going to userspace, almost
certainly not what you want.
> + dev_kfree_skb(skb);
> + return -1;
Ditto, same in a few other places later too.
> +/* Generic Netlink operations array */
> +static struct genl_ops hwsim_ops[] = {
> + {
> + .cmd = HWSIM_CMD_REGISTER,
> + .flags = 0,
> + .policy = hwsim_genl_policy,
> + .doit = hwsim_register_received_nl,
> + .dumpit = NULL,
No need for explicit 0/NULL initialisation, just FYI (I don't really
mind in this case, doesn't seem excessive). However, are you sure we
should allow any user to run this? While it should be safe, do we want
to risk it? More of a philosophical question I guess.
> +failure:
> + printk(KERN_DEBUG "mac80211_hwsim: error occured in %s\n", __func__);
> + return -1;
Same here with the error code, this could be propagated as "permission
denied" while loading the module which would be rather odd.
> +
> +
> +#define VERSION_NR 1
Did I miss a use of the version number somewhere? Seems kinda pointless
since if it's really totally incompatible the only reasonable way would
be to renumber the commands or rename the genl family.
johannes
next prev parent reply other threads:[~2011-05-26 3:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-18 20:45 [PATCH] mac80211_hwsim driver support userspace frame tx/rx Javier Lopez
2011-04-19 2:19 ` Javier Cardona
2011-04-22 19:31 ` [PATCH v2] " Javier Lopez
2011-04-28 18:34 ` John W. Linville
2011-05-01 19:29 ` [PATCH v3] " Javier Lopez
2011-05-01 21:35 ` Johannes Berg
2011-05-11 21:32 ` [PATCH v4] " Javier Lopez
2011-05-18 0:09 ` Javier Cardona
2011-05-18 20:58 ` Johannes Berg
2011-05-19 16:00 ` Johannes Berg
2011-05-25 10:41 ` [PATCH v5] " Javier Lopez
2011-05-25 19:03 ` [PATCH v6] " Javier Lopez
2011-05-26 3:54 ` Johannes Berg [this message]
2011-05-31 21:29 ` [PATCH v7] " Javier Lopez
2011-05-31 22:06 ` Javier Lopez
2011-06-01 4:16 ` Johannes Berg
[not found] ` <BANLkTinE0axwc_X9Gt=qdrjufopvPNADng@mail.gmail.com>
2011-06-01 8:48 ` Johannes Berg
2011-06-01 9:26 ` [PATCH v8] " Javier Lopez
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=1306382059.3407.12.camel@jlt3.sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=j@w1.fi \
--cc=javier@cozybit.com \
--cc=jlopex@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.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 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).