All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Henning Rogge <hrogge@gmail.com>, linux-wireless@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Henning Rogge <henning.rogge@fkie.fraunhofer.de>
Subject: Re: [PATCH 2/2] mac80211: let unused MPP table entries timeout
Date: Tue, 26 Jan 2016 12:44:41 +0100	[thread overview]
Message-ID: <1453808681.2759.35.camel@sipsolutions.net> (raw)
In-Reply-To: <1453190672-9748-3-git-send-email-henning.rogge@fkie.fraunhofer.de> (sfid-20160119_090459_536071_3CC17F87)

On Tue, 2016-01-19 at 09:04 +0100, Henning Rogge wrote:

> +++ b/net/mac80211/mesh_pathtbl.c
> @@ -929,12 +929,55 @@ int mesh_path_del(struct ieee80211_sub_if_data
> *sdata, const u8 *addr)
>  		if (mpath->sdata == sdata &&
>  		    ether_addr_equal(addr, mpath->dst)) {
>  			__mesh_path_del(tbl, node);
> -			goto enddel;
> +			goto enddelpath;

C labels are scoped, why rename it?

>  		}
>  	}
>  
>  	err = -ENXIO;
> -enddel:
> +enddelpath:
> +	mesh_paths_generation++;
> +	spin_unlock(&tbl->hashwlock[hash_idx]);
> +	read_unlock_bh(&pathtbl_resize_lock);
> +	return err;
> +}
> +
> +/**
> + * mpp_path_del - delete a mesh proxy path from the table
> + *
> + * @addr: addr address (ETH_ALEN length)
> + * @sdata: local subif
> + *
> + * Returns: 0 if successful
> + */
> +static int mpp_path_del(struct ieee80211_sub_if_data *sdata, const
> u8 *addr)
> +{
> +	struct mesh_table *tbl;
> +	struct mesh_path *mpath;
> +	struct mpath_node *node;
> +	struct hlist_head *bucket;
> +	int hash_idx;
> +	int err = 0;
> +
> +	/* flush relevant mpp entries first */
> +	mpp_flush_by_proxy(sdata, addr);
> +
> +	read_lock_bh(&pathtbl_resize_lock);
> +	tbl = resize_dereference_mpp_paths();
> +	hash_idx = mesh_table_hash(addr, sdata, tbl);
> +	bucket = &tbl->hash_buckets[hash_idx];
> +
> +	spin_lock(&tbl->hashwlock[hash_idx]);
> +	hlist_for_each_entry(node, bucket, list) {
> +		mpath = node->mpath;
> +		if (mpath->sdata == sdata &&
> +		    ether_addr_equal(addr, mpath->dst)) {
> +			__mesh_path_del(tbl, node);
> +			goto enddelmpp;

This has the same use-after-free, I'd say?
And another instance later in this file.


> +					spin_lock_bh(&mppath-
> >state_lock);
> +					mppath->exp_time = jiffies;

That locking seems fairly pointless? You only write to this value here,
and it's an unsigned long, so in itself it's atomic and there's no
synchronisation against anything else needed.

johannes

  parent reply	other threads:[~2016-01-26 11:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19  8:04 [PATCH 0/2] mac80211: add cleanup path for MPP table entries Henning Rogge
2016-01-19  8:04 ` [PATCH 1/2] mac80211: Remove connected MPP table entries with MPath Henning Rogge
2016-01-26 11:41   ` Johannes Berg
2016-01-26 18:36     ` Bob Copeland
2016-01-26 19:04       ` Henning Rogge
2016-01-26 20:53       ` Johannes Berg
2016-01-26 21:22         ` Bob Copeland
2016-01-26 21:31           ` Johannes Berg
2016-01-26 21:32             ` Johannes Berg
2016-01-26 21:44               ` Bob Copeland
2016-01-19  8:04 ` [PATCH 2/2] mac80211: let unused MPP table entries timeout Henning Rogge
2016-01-22 20:30   ` Bob Copeland
2016-01-23  9:39     ` Henning Rogge
2016-01-23 15:15       ` Bob Copeland
2016-01-24 17:53         ` Henning Rogge
2016-01-26 11:44   ` Johannes Berg [this message]
2016-01-26 19:54     ` Henning Rogge
2016-01-26 23:17   ` Bob Copeland
2016-01-28 13:44 ` [PATCH 0/2] mac80211: add cleanup path for MPP table entries Bob Copeland
2016-01-28 15:07   ` Henning Rogge
2016-01-28 15:12     ` Bob Copeland

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=1453808681.2759.35.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=davem@davemloft.net \
    --cc=henning.rogge@fkie.fraunhofer.de \
    --cc=hrogge@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    /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.