Skip to content

Commit

Permalink
net:rfs: adjust table size checking
Browse files Browse the repository at this point in the history
Make sure root user does not try something stupid.

Also make sure mask field in struct rps_sock_flow_table
does not share a cache line with the potentially often dirtied
flow table.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Fixes: 567e4b7 ("net: rfs: add hash collision detection")
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and davem330 committed Feb 9, 2015
1 parent acde2c2 commit 93c1af6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,8 @@ struct rps_dev_flow_table {
*/
struct rps_sock_flow_table {
u32 mask;
u32 ents[0];

u32 ents[0] ____cacheline_aligned_in_smp;
};
#define RPS_SOCK_FLOW_TABLE_SIZE(_num) (offsetof(struct rps_sock_flow_table, ents[_num]))

Expand Down
2 changes: 1 addition & 1 deletion net/core/sysctl_net_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,

if (write) {
if (size) {
if (size > 1<<30) {
if (size > 1<<29) {
/* Enforce limit to prevent overflow */
mutex_unlock(&sock_flow_mutex);
return -EINVAL;
Expand Down

0 comments on commit 93c1af6

Please sign in to comment.