From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bn3nam01on0131.outbound.protection.outlook.com ([104.47.33.131]:56088 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032296AbeCAPcL (ORCPT ); Thu, 1 Mar 2018 10:32:11 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Jim Westfall , "David S . Miller" , Sasha Levin Subject: [added to the 4.1 stable tree] net: Allow neigh contructor functions ability to modify the primary_key Date: Thu, 1 Mar 2018 15:25:06 +0000 Message-ID: <20180301152116.1486-247-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jim Westfall This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 096b9854c04df86f03b38a97d40b6506e5730919 ] Use n->primary_key instead of pkey to account for the possibility that a ne= igh constructor function may have modified the primary_key value. Signed-off-by: Jim Westfall Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/neighbour.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index cb9a7ab5444c..5fd6c6e699aa 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -492,7 +492,7 @@ struct neighbour *__neigh_create(struct neigh_table *tb= l, const void *pkey, if (atomic_read(&tbl->entries) > (1 << nht->hash_shift)) nht =3D neigh_hash_grow(tbl, nht->hash_shift + 1); =20 - hash_val =3D tbl->hash(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift= ); + hash_val =3D tbl->hash(n->primary_key, dev, nht->hash_rnd) >> (32 - nht->= hash_shift); =20 if (n->parms->dead) { rc =3D ERR_PTR(-EINVAL); @@ -504,7 +504,7 @@ struct neighbour *__neigh_create(struct neigh_table *tb= l, const void *pkey, n1 !=3D NULL; n1 =3D rcu_dereference_protected(n1->next, lockdep_is_held(&tbl->lock))) { - if (dev =3D=3D n1->dev && !memcmp(n1->primary_key, pkey, key_len)) { + if (dev =3D=3D n1->dev && !memcmp(n1->primary_key, n->primary_key, key_l= en)) { if (want_ref) neigh_hold(n1); rc =3D n1; --=20 2.14.1