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
| ||
|
Date: Thu, 30 May 2013 09:51:13 +0300 From: Eliezer Tamir <eliezer.tamir@...ux.intel.com> To: Ben Hutchings <bhutchings@...arflare.com> CC: David Miller <davem@...emloft.net>, linux-kernel@...r.kernel.org, netdev@...r.kernel.org, Jesse Brandeburg <jesse.brandeburg@...el.com>, Don Skidmore <donald.c.skidmore@...el.com>, e1000-devel@...ts.sourceforge.net, Willem de Bruijn <willemb@...gle.com>, Eric Dumazet <erdnetdev@...il.com>, Andi Kleen <andi@...stfloor.org>, HPA <hpa@...or.com>, Eilon Greenstien <eilong@...adcom.com>, Or Gerlitz <or.gerlitz@...il.com>, Alex Rosenbaum <alexr@...lanox.com>, Eliezer Tamir <eliezer@...ir.org.il> Subject: Re: [PATCH v6 net-next 1/5] net: add napi_id and hash On 29/05/2013 23:09, Ben Hutchings wrote: > On Wed, 2013-05-29 at 09:39 +0300, Eliezer Tamir wrote: >> +void napi_hash_add(struct napi_struct *napi) >> +{ >> + if (!test_and_set_bit(NAPI_STATE_HASHED, &napi->state)) { >> + >> + spin_lock(&napi_hash_lock); >> + >> + /* 0 is not a valid id */ >> + napi->napi_id = 0; >> + while (!napi->napi_id) >> + napi->napi_id = ++napi_gen_id; > > Suppose we're loading/unloading one driver repeatedly while another one > remains loaded the whole time. Then once napi_gen_id wraps around, the > same ID can be assigned to multiple contexts. > > So far as I can see, assigning the same ID twice will just make polling > stop working for one of the NAPI contexts; I don't think it causes a > crash. And it is exceedingly unlikely to happen in production. But if > you're going to the trouble of handling wrap-around at all, you'd better > handle this. OK > [...] >> +/* must be called under rcu_read_lock(), as we dont take a reference */ >> +struct napi_struct *napi_by_id(int napi_id) >> +{ >> + unsigned int hash = napi_id % HASH_SIZE(napi_hash); > [...] > > napi_id should be declared unsigned int here, as elsewhere. The > division can't actually yield a negative result because HASH_SIZE() has > type size_t and napi_id is promoted to match, but I had to go and look > at hashtable.h to check that. Good catch, Thanks, Eliezer -- 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