Commit 93c1af6ca94c1e763efba76a127b5c135e3d23a6

Authored by Eric Dumazet
Committed by David S. Miller
1 parent acde2c2d28

net:rfs: adjust table size checking

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: 567e4b79731c ("net: rfs: add hash collision detection")
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 3 additions and 2 deletions Side-by-side Diff

include/linux/netdevice.h
... ... @@ -653,7 +653,8 @@
653 653 */
654 654 struct rps_sock_flow_table {
655 655 u32 mask;
656   - u32 ents[0];
  656 +
  657 + u32 ents[0] ____cacheline_aligned_in_smp;
657 658 };
658 659 #define RPS_SOCK_FLOW_TABLE_SIZE(_num) (offsetof(struct rps_sock_flow_table, ents[_num]))
659 660  
net/core/sysctl_net_core.c
... ... @@ -52,7 +52,7 @@
52 52  
53 53 if (write) {
54 54 if (size) {
55   - if (size > 1<<30) {
  55 + if (size > 1<<29) {
56 56 /* Enforce limit to prevent overflow */
57 57 mutex_unlock(&sock_flow_mutex);
58 58 return -EINVAL;