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]
Message-ID: <20150521080038.GA2212@nanopsycho.orion>
Date:	Thu, 21 May 2015 10:00:38 +0200
From:	Jiri Pirko <jiri@...nulli.us>
To:	sfeldma@...il.com
Cc:	netdev@...r.kernel.org, simon.horman@...ronome.com,
	makita.toshiaki@....ntt.co.jp
Subject: Re: [PATCH net-next] rocker: move netevent neigh update to processes
 context

Thu, May 21, 2015 at 07:05:07AM CEST, sfeldma@...il.com wrote:
>From: Scott Feldman <sfeldma@...il.com>
>
>In review of Simon's patchset "rocker: transaction fixes". it was noted
>that rocker->neigh_tbl_next_index was unprotected in the call path below
>and could race with other contexts calling rocker_port_ipv4_neigh():
>
>	arp_process()
>	neigh_update()
>	rocker_neigh_update()
>	rocker_port_ipv4_neigh()
>
>To fix, move the neigh_update() event processing to process contexts and
>hold rtnl_lock to call rocker_port_ipv4_neigh().  This will protect
>rocker->neigh_tbl_next_index accesses and is more consistent with the rest
>of the driver code where non-I/O processing is done under process context
>with rtnl_lock held.
>
>Signed-off-by: Scott Feldman <sfeldma@...il.com>
>---
> drivers/net/ethernet/rocker/rocker.c |   52 +++++++++++++++++++++++++++++-----
> 1 file changed, 45 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
>index 0f5e962..4cff2f6 100644
>--- a/drivers/net/ethernet/rocker/rocker.c
>+++ b/drivers/net/ethernet/rocker/rocker.c
>@@ -5240,14 +5240,52 @@ static struct notifier_block rocker_netdevice_nb __read_mostly = {
>  * Net event notifier event handler
>  ************************************/
> 
>-static int rocker_neigh_update(struct net_device *dev, struct neighbour *n)
>+struct rocker_neigh_update_work {
>+	struct work_struct work;
>+	struct rocker_port *rocker_port;
>+	int flags;
>+	__be32 ip_addr;
>+	unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))];
>+};
>+
>+static void rocker_event_neigh_update_work(struct work_struct *work)
> {
>-	struct rocker_port *rocker_port = netdev_priv(dev);
>-	int flags = (n->nud_state & NUD_VALID) ? 0 : ROCKER_OP_FLAG_REMOVE;
>-	__be32 ip_addr = *(__be32 *)n->primary_key;
>+	struct rocker_neigh_update_work *nw =
>+		container_of(work, struct rocker_neigh_update_work, work);
>+	int err;
>+
>+	rtnl_lock();
>+	err = rocker_port_ipv4_neigh(nw->rocker_port, SWITCHDEV_TRANS_NONE,
>+				     nw->flags, nw->ip_addr, nw->ha);
>+	rtnl_unlock();
>+
>+	if (err)
>+		netdev_warn(nw->rocker_port->dev,
>+			    "failed to handle neigh %pI4 update (err %d)\n",
>+			    &nw->ip_addr, err);
> 
>-	return rocker_port_ipv4_neigh(rocker_port, SWITCHDEV_TRANS_NONE,
>-				      flags, ip_addr, n->ha);
>+	kfree(work);

It should be kfree(nw)
I know it is the same, but looks more correct.

Other than this, this looks good to me

Acked-by: Jiri Pirko <jiri@...nulli.us>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ