From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 80F04A2F; Tue, 14 Feb 2017 20:08:01 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 14 Feb 2017 11:08:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,162,1484035200"; d="scan'208";a="44417851" Received: from irsmsx106.ger.corp.intel.com ([163.33.3.31]) by orsmga002.jf.intel.com with ESMTP; 14 Feb 2017 11:07:59 -0800 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.173]) by IRSMSX106.ger.corp.intel.com ([169.254.8.197]) with mapi id 14.03.0248.002; Tue, 14 Feb 2017 19:07:58 +0000 From: "Dumitrescu, Cristian" To: Emmanuel Roullit CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH] rte_table: ensure prev bucket has a valid pointer Thread-Index: AQHSdoHqemFMhsTs/02cY2P/rAH9d6Fo/V5g Date: Tue, 14 Feb 2017 19:07:57 +0000 Message-ID: <3EB4FA525960D640B5BDFFD6A3D891265274D175@IRSMSX108.ger.corp.intel.com> References: <20170124203830.5691-1-emmanuel.roullit@gmail.com> In-Reply-To: <20170124203830.5691-1-emmanuel.roullit@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjQxNGJjYzktMjE2Ni00ZTVhLThiNzAtNDViMzk2OWZlY2E0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjIuMTEuMCIsIlRydXN0ZWRMYWJlbEhhc2giOiJLSEY2NXVzYmxTbk1ZQUh4TFhjSzBmZm9MSXpKenpqZCtPS2RuaDMwRzJRPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [PATCH] rte_table: ensure prev bucket has a valid pointer X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Feb 2017 19:08:02 -0000 Hi Emmanuel, > -----Original Message----- > From: Emmanuel Roullit [mailto:emmanuel.roullit@gmail.com] > Sent: Tuesday, January 24, 2017 8:39 PM > To: Dumitrescu, Cristian > Cc: dev@dpdk.org; stable@dpdk.org > Subject: [PATCH] rte_table: ensure prev bucket has a valid pointer >=20 > Fixes: 43f15e28377f ("table: fix verification on hash bucket header > alignment") >=20 > Signed-off-by: Emmanuel Roullit > --- > lib/librte_table/rte_table_hash_key16.c | 7 +++++-- > lib/librte_table/rte_table_hash_key32.c | 7 +++++-- > 2 files changed, 10 insertions(+), 4 deletions(-) >=20 > diff --git a/lib/librte_table/rte_table_hash_key16.c > b/lib/librte_table/rte_table_hash_key16.c > index 08d4d77eb..9c04e7f5e 100644 > --- a/lib/librte_table/rte_table_hash_key16.c > +++ b/lib/librte_table/rte_table_hash_key16.c > @@ -483,8 +483,11 @@ rte_table_hash_entry_add_key16_ext( >=20 > bucket =3D (struct rte_bucket_4_16 *) &f->memory[(f- > >n_buckets + > bucket_index) * f->bucket_size]; > - bucket_prev->next =3D bucket; > - bucket_prev->next_valid =3D 1; > + > + if (bucket_prev) { > + bucket_prev->next =3D bucket; > + bucket_prev->next_valid =3D 1; > + } >=20 > bucket->signature[0] =3D signature; > memcpy(bucket->key[0], key, f->key_size); > diff --git a/lib/librte_table/rte_table_hash_key32.c > b/lib/librte_table/rte_table_hash_key32.c > index 161f6b7a7..27e221be9 100644 > --- a/lib/librte_table/rte_table_hash_key32.c > +++ b/lib/librte_table/rte_table_hash_key32.c > @@ -471,8 +471,11 @@ rte_table_hash_entry_add_key32_ext( > bucket =3D (struct rte_bucket_4_32 *) > &f->memory[(f->n_buckets + bucket_index) * > f->bucket_size]; > - bucket_prev->next =3D bucket; > - bucket_prev->next_valid =3D 1; > + > + if (bucket_prev) { > + bucket_prev->next =3D bucket; > + bucket_prev->next_valid =3D 1; > + } >=20 > bucket->signature[0] =3D signature; > memcpy(bucket->key[0], key, f->key_size); > -- > 2.11.0 Each table bucket is initialized with a group of 4 entries which can be fur= ther extended with one (or several) groups of 4 entries (we also call a gro= up of 4 entries as a bucket). Therefore, there is no way bucket_prev could be NULL. Were you able to hit = a case with bucket_prev =3D=3D NULL at run-time, or was this produced by a = code analysis tool (in which case this is likely a false positive)? Regards, Cristian