AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/09/23 18:08 flow patch-triage
6m Args:
null

Results:
{
  "EnableConfigs": [
    "NET",
    "SYSCTL",
    "VIRTIO_NET"
  ],
  "FocusSymbols": [
    "proc_do_rss_key",
    "netdev_rss_key_fill",
    "netdev_rss_key_init",
    "netdev_rss_key_aliases",
    "netdev_rss_key_fixup_field"
  ],
  "KMSANReasoning": "The patch series enhances the Toeplitz RSS key generation in netdev_rss_key_fill() to ensure non-singularity and avoid collisions across receive queues, adds associated sysctl synchronization, and introduces KUnit and selftests.\n\nAnalysis of uninitialized memory and information leak risks:\n1. All buffers and arrays introduced or modified are properly initialized:\n   - In `netdev_rss_key_init()`, `get_random_bytes()` initializes the entire key buffer before any fixup operations are performed.\n   - The stack array `d` in `netdev_rss_key_fixup_field()` is completely populated in an initial loop prior to any reads.\n   - In `netdev_rss_key_aliases()`, stack array `windows` is populated sequentially up to `n`, and only elements in range `[0, n)` are subsequently read.\n   - In `proc_do_rss_key()`, the output string buffer `buf` is completely written with hex bytes and a null terminator before being passed to `proc_dostring()`. Furthermore, an explicit `netdev_rss_key_initialized` barrier prevents reading `netdev_rss_key` prior to initialization.\n   - The KUnit tests use zero-initialized memory allocations (`kunit_kzalloc` / `kunit_kcalloc`).\n2. No kernel structures with padding or uninitialized fields are exposed or copied to user space.\n3. No conditional branches or control flow decisions rely on uninitialized values.\n\nAny potential bounds or overflow issues would be covered by standard KASAN/UBSAN builds. A dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false,
  "Reasoning": "The patch introduces new algorithmic key generation and alias-checking logic in net/ethtool/ioctl.c (netdev_rss_key_init(), netdev_rss_key_fixup_field(), netdev_rss_key_aliases()) used by netdev_rss_key_fill() to generate non-singular Toeplitz RSS keys. It also updates the procfs sysctl handler proc_do_rss_key() in net/core/sysctl_net_core.c with memory barriers and initialization state tracking. Because this touches core networking logic reachable via virtual network drivers (e.g. virtio_net in QEMU, gve in GCE) as well as the /proc/sys/net/core/netdev_rss_key sysctl interface, it touches reachable executable code and warrants fuzzing.",
  "WorthFuzzing": true
}

1/1 2026/09/23 18:08 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 8db3b7dacd5116913755365bd01f62cd92bd07bd\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Wed Sep 23 18:08:13 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/Documentation/networking/scaling.rst b/Documentation/networking/scaling.rst\nindex 6c261eb48845a..6c9836000a8d1 100644\n--- a/Documentation/networking/scaling.rst\n+++ b/Documentation/networking/scaling.rst\n@@ -48,6 +48,15 @@ count is not a power of two. NICs should provide an indirection table\n at least 4 times larger than the queue count. 4x table results in ~16%\n imbalance between the queues, which is acceptable for most applications.\n \n+The Toeplitz hash is linear over GF(2), so the quality of the hash key\n+matters as much as its randomness. For a key made of uniformly random\n+bytes, the q lowest order bits of a given header field fail to spread\n+flows over all 2^q queues with probability 1/2, and a burst of connections\n+picking nearly consecutive ephemeral ports then lands on a fraction of the\n+queues while the others stay idle. The netdev_rss_key_fill() helper draws\n+a random key that is free of this defect; drivers should use it rather\n+than seeding a key of their own.\n+\n Some NICs support symmetric RSS hashing where, if the IP (source address,\n destination address) and TCP/UDP (source port, destination port) tuples\n are swapped, the computed hash is the same. This is beneficial in some\ndiff --git a/net/Kconfig b/net/Kconfig\nindex e384773935515..4a8dc0e5b075a 100644\n--- a/net/Kconfig\n+++ b/net/Kconfig\n@@ -540,4 +540,18 @@ config NET_TEST\n \n \t  If unsure, say N.\n \n+config ETHTOOL_RSS_KEY_KUNIT_TEST\n+\ttristate \"KUnit tests for the generated RSS key\" if !KUNIT_ALL_TESTS\n+\tdepends on KUNIT\n+\tdefault KUNIT_ALL_TESTS\n+\thelp\n+\t  KUnit tests checking the RSS key that netdev_rss_key_fill() hands\n+\t  to the drivers: flows differing only in the low order bits of one\n+\t  hashed header field have to spread over all the RX queues, for\n+\t  every field of the Toeplitz hash inputs, for every 16-bit aligned\n+\t  position of the key, and for every queue count up to\n+\t  2 ** NETDEV_RSS_KEY_QMAX.\n+\n+\t  If unsure, say N.\n+\n endif   # if NET\ndiff --git a/net/core/dev.h b/net/core/dev.h\nindex b757faead4d1a..0127b4d03e525 100644\n--- a/net/core/dev.h\n+++ b/net/core/dev.h\n@@ -95,6 +95,7 @@ extern int\t\tnetdev_unregister_timeout_secs;\n extern int\t\tweight_p;\n extern int\t\tdev_weight_rx_bias;\n extern int\t\tdev_weight_tx_bias;\n+extern bool\t\tnetdev_rss_key_initialized;\n \n extern struct rw_semaphore dev_addr_sem;\n \ndiff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c\nindex 23310581f4945..e30219765db39 100644\n--- a/net/core/sysctl_net_core.c\n+++ b/net/core/sysctl_net_core.c\n@@ -338,9 +338,14 @@ static int proc_do_rss_key(const struct ctl_table *table, int write,\n \tchar buf[NETDEV_RSS_KEY_LEN * 3];\n \tstruct ctl_table fake_table;\n \tchar *pos = buf;\n+\tbool initialized;\n+\n+\tinitialized = READ_ONCE(netdev_rss_key_initialized);\n+\t/* Pair with smp_wmb() in netdev_rss_key_fill(). */\n+\tsmp_rmb();\n \n \tfor (int i = 0; i \u003c NETDEV_RSS_KEY_LEN; i++) {\n-\t\tpos = hex_byte_pack(pos, netdev_rss_key[i]);\n+\t\tpos = hex_byte_pack(pos, initialized ? netdev_rss_key[i] : 0);\n \t\t*pos++ = ':';\n \t}\n \t*(--pos) = 0;\ndiff --git a/net/ethtool/Makefile b/net/ethtool/Makefile\nindex 629c10916670e..6588cfe652810 100644\n--- a/net/ethtool/Makefile\n+++ b/net/ethtool/Makefile\n@@ -10,3 +10,5 @@ ethtool_nl-y\t:= netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \\\n \t\t   tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \\\n \t\t   module.o cmis_fw_update.o cmis_cdb.o pse-pd.o plca.o \\\n \t\t   phy.o tsconfig.o mse.o\n+\n+obj-$(CONFIG_ETHTOOL_RSS_KEY_KUNIT_TEST)\t+= rss_key_test.o\ndiff --git a/net/ethtool/common.h b/net/ethtool/common.h\nindex 4e5356e26f400..c1b6191f45693 100644\n--- a/net/ethtool/common.h\n+++ b/net/ethtool/common.h\n@@ -15,6 +15,17 @@\n #define __SOF_TIMESTAMPING_CNT (const_ilog2(SOF_TIMESTAMPING_LAST) + 1)\n #define __HWTSTAMP_FLAG_CNT (const_ilog2(HWTSTAMP_FLAG_LAST) + 1)\n \n+/* netdev_rss_key_fill() guarantees that flows differing only in the low order\n+ * bits of one hashed header field spread over all the RX queues, for any queue\n+ * count up to 2 ** NETDEV_RSS_KEY_QMAX and any 16-bit aligned field of the\n+ * hash input. See netdev_rss_key_init().\n+ */\n+#define NETDEV_RSS_KEY_QMAX\t8\n+\n+#if IS_ENABLED(CONFIG_KUNIT)\n+void netdev_rss_key_init(u8 *key, size_t len);\n+#endif\n+\n struct genl_info;\n struct hwtstamp_provider_desc;\n \ndiff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c\nindex 4b0bc503f9307..e625175ed1cbd 100644\n--- a/net/ethtool/ioctl.c\n+++ b/net/ethtool/ioctl.c\n@@ -25,15 +25,20 @@\n #include \u003clinux/rtnetlink.h\u003e\n #include \u003clinux/sched/signal.h\u003e\n #include \u003clinux/net.h\u003e\n+#include \u003clinux/once.h\u003e\n #include \u003clinux/pm_runtime.h\u003e\n+#include \u003clinux/random.h\u003e\n+#include \u003clinux/unaligned.h\u003e\n #include \u003clinux/utsname.h\u003e\n #include \u003clinux/ethtool_netlink.h\u003e\n+#include \u003ckunit/visibility.h\u003e\n #include \u003cnet/devlink.h\u003e\n #include \u003cnet/ipv6.h\u003e\n #include \u003cnet/flow_offload.h\u003e\n #include \u003cnet/netdev_lock.h\u003e\n #include \u003cnet/netdev_queues.h\u003e\n \n+#include \"../core/dev.h\"\n #include \"common.h\"\n \n /* State held across locks and calls for commands which have devlink fallback */\n@@ -1302,11 +1307,174 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,\n }\n \n u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly;\n+bool netdev_rss_key_initialized __read_mostly;\n+\n+/* Toeplitz is linear over GF(2): the hash is the XOR of the 32-bit key\n+ * windows selected by the set bits of the input, and hardware indexes the\n+ * indirection table with the low order bits of the hash. Only the tail of\n+ * each window therefore matters for queue selection:\n+ *\n+ *\tv(i) = key bits [i + 32 - q .. i + 31]\n+ *\n+ * for input bit @i, with q = log2(number of RX queues). Consecutive input\n+ * bits give windows overlapping in q - 1 positions, so the matrix formed by\n+ * the windows of the q lowest bits of a header field is a Toeplitz matrix\n+ * built from 2 * q - 1 key bits, not from q * q independent ones. A random\n+ * Toeplitz matrix over GF(2) is singular with probability 1/2, whatever its\n+ * size, and when it is singular the flows of a burst differing only in the\n+ * low order bits of that field (consecutive ephemeral ports, typically)\n+ * cannot reach all the RX queues no matter how many of them are configured.\n+ *\n+ * Keep the key random, but constrain the few bits that decide this. The\n+ * fixup is applied at every 16-bit aligned position of the key, rather than\n+ * at the offsets of the one hash input layout the software happens to know\n+ * about: hardware is free to hash whatever it wants, but the fields it picks\n+ * are 16 bits wide at the smallest and are not expected to straddle that\n+ * grid, so an encapsulated or offloaded layout is covered like the usual\n+ * 2-tuple and 4-tuple ones. Each position constrains 2 * q - 1 bits, so\n+ * NETDEV_RSS_KEY_QMAX is both enough for 256 queues and the largest value\n+ * keeping the ranges of two adjacent positions disjoint.\n+ */\n+#define NETDEV_RSS_KEY_SPAN\t(2 * NETDEV_RSS_KEY_QMAX - 1)\n+\n+static bool netdev_rss_key_bit(const u8 *key, unsigned int bit)\n+{\n+\treturn key[bit / BITS_PER_BYTE] \u0026 (0x80 \u003e\u003e (bit % BITS_PER_BYTE));\n+}\n+\n+static void netdev_rss_key_assign_bit(u8 *key, unsigned int bit, bool value)\n+{\n+\tu8 mask = 0x80 \u003e\u003e (bit % BITS_PER_BYTE);\n+\n+\tif (value)\n+\t\tkey[bit / BITS_PER_BYTE] |= mask;\n+\telse\n+\t\tkey[bit / BITS_PER_BYTE] \u0026= ~mask;\n+}\n+\n+/* Writing d[t] for key bit (@lsb + 31 - t), the matrices of all the q values\n+ * up to NETDEV_RSS_KEY_QMAX are non singular if and only if\n+ *\n+ *\td[2 * i] = 1 ^ d[i] ^ d[i + 1] ^ ... ^ d[2 * i - 1]\n+ *\n+ * The odd positions stay free, so this is a one pass fixup rather than a\n+ * search. It is also a bijection onto the set of the values having the\n+ * property, so the key stays uniformly distributed over that set. It costs\n+ * NETDEV_RSS_KEY_QMAX bits of entropy per position.\n+ */\n+static void netdev_rss_key_fixup_field(u8 *key, unsigned int lsb)\n+{\n+\tbool d[NETDEV_RSS_KEY_SPAN];\n+\tunsigned int i, t;\n+\n+\tfor (t = 0; t \u003c NETDEV_RSS_KEY_SPAN; t++)\n+\t\td[t] = netdev_rss_key_bit(key, lsb + 31 - t);\n+\n+\tfor (i = 0; 2 * i \u003c NETDEV_RSS_KEY_SPAN; i++) {\n+\t\tbool value = true;\n+\n+\t\tfor (t = i; t \u003c 2 * i; t++)\n+\t\t\tvalue ^= d[t];\n+\n+\t\td[2 * i] = value;\n+\t}\n+\n+\tfor (t = 0; t \u003c NETDEV_RSS_KEY_SPAN; t++)\n+\t\tnetdev_rss_key_assign_bit(key, lsb + 31 - t, d[t]);\n+}\n+\n+/* The 32 key bits starting at @bit, which is what input bit @bit contributes\n+ * to the hash. @bit + 32 must fit in the key.\n+ */\n+static u32 netdev_rss_key_window(const u8 *key, unsigned int bit)\n+{\n+\tunsigned int byte = bit / BITS_PER_BYTE;\n+\tunsigned int shift = bit % BITS_PER_BYTE;\n+\tu32 window = get_unaligned_be32(key + byte);\n+\n+\tif (shift)\n+\t\twindow = (window \u003c\u003c shift) |\n+\t\t\t (key[byte + 4] \u003e\u003e (BITS_PER_BYTE - shift));\n+\n+\treturn window;\n+}\n+\n+/* Two input bits contributing the same window are indistinguishable to the\n+ * hash, since flipping both of them leaves it unchanged. For a uniformly\n+ * random key that is a 2 ** -32 event per pair of positions, but the fixup\n+ * makes it likelier: it derives 8 of every 16 bits from the 8 others, so a\n+ * 16-bit aligned word only takes 2 ** 8 values and two windows a whole\n+ * number of words apart collide with probability 2 ** -16 instead. Half a\n+ * word apart is less affected but still well clear of the random odds, so\n+ * cover every distance that is a multiple of 8. What is left after that is\n+ * below what a plain random key gives.\n+ *\n+ * Two windows at a distance that is a multiple of 8 are two windows at the\n+ * same offset modulo 8. Caching a whole class would put 253 u32 on the\n+ * stack, so cache one class modulo 16 and stream the class 8 bits above it\n+ * against it.\n+ */\n+static bool netdev_rss_key_aliases(const u8 *key, unsigned int bits)\n+{\n+\tu32 windows[NETDEV_RSS_KEY_LEN * BITS_PER_BYTE / 16];\n+\tunsigned int i, j, n, r;\n+\n+\tfor (r = 0; r \u003c 16; r++) {\n+\t\tn = 0;\n+\t\tfor (i = r; i + 32 \u003c= bits; i += 16)\n+\t\t\twindows[n++] = netdev_rss_key_window(key, i);\n+\n+\t\tfor (i = 0; i \u003c n; i++)\n+\t\t\tfor (j = i + 1; j \u003c n; j++)\n+\t\t\t\tif (windows[i] == windows[j])\n+\t\t\t\t\treturn true;\n+\n+\t\tif (r \u003e= 8)\n+\t\t\tcontinue;\n+\n+\t\tfor (i = r + 8; i + 32 \u003c= bits; i += 16) {\n+\t\t\tu32 window = netdev_rss_key_window(key, i);\n+\n+\t\t\tfor (j = 0; j \u003c n; j++)\n+\t\t\t\tif (windows[j] == window)\n+\t\t\t\t\treturn true;\n+\t\t}\n+\t}\n+\n+\treturn false;\n+}\n+\n+VISIBLE_IF_KUNIT void netdev_rss_key_init(u8 *key, size_t len)\n+{\n+\tunsigned int lsb, bits = len * BITS_PER_BYTE;\n+\n+\t/* Four keys out of five come out of the fixup free of aliases, so\n+\t * drawing another one is both simpler and cheaper than repairing.\n+\t */\n+\tdo {\n+\t\tget_random_bytes(key, len);\n+\n+\t\t/* A field ending at bit @lsb uses key bits [.. , @lsb + 31],\n+\t\t * so stop as soon as a 32-bit window no longer fits in the\n+\t\t * key.\n+\t\t */\n+\t\tfor (lsb = 15; lsb + 32 \u003c= bits; lsb += 16)\n+\t\t\tnetdev_rss_key_fixup_field(key, lsb);\n+\t} while (netdev_rss_key_aliases(key, bits));\n+\n+\tif (key != netdev_rss_key)\n+\t\treturn;\n+\n+\t/* Pair with smp_rmb() in proc_do_rss_key(). */\n+\tsmp_wmb();\n+\tWRITE_ONCE(netdev_rss_key_initialized, true);\n+}\n+EXPORT_SYMBOL_IF_KUNIT(netdev_rss_key_init);\n \n void netdev_rss_key_fill(void *buffer, size_t len)\n {\n \tBUG_ON(len \u003e sizeof(netdev_rss_key));\n-\tnet_get_random_once(netdev_rss_key, sizeof(netdev_rss_key));\n+\tDO_ONCE(netdev_rss_key_init, netdev_rss_key, sizeof(netdev_rss_key));\n \tmemcpy(buffer, netdev_rss_key, len);\n }\n EXPORT_SYMBOL(netdev_rss_key_fill);\ndiff --git a/net/ethtool/rss_key_test.c b/net/ethtool/rss_key_test.c\nnew file mode 100644\nindex 0000000000000..1a583f2930c5b\n--- /dev/null\n+++ b/net/ethtool/rss_key_test.c\n@@ -0,0 +1,314 @@\n+// SPDX-License-Identifier: GPL-2.0-only\n+/* Tests for the RSS key generated by netdev_rss_key_fill().\n+ *\n+ * The property under test is that flows differing only in the low order bits\n+ * of one hashed header field land on distinct RX queues. It is checked here\n+ * from the definition of the Toeplitz hash, independently of the way\n+ * netdev_rss_key_init() achieves it.\n+ */\n+\n+#include \u003ckunit/test.h\u003e\n+#include \u003clinux/module.h\u003e\n+#include \u003clinux/random.h\u003e\n+#include \u003clinux/sort.h\u003e\n+\n+#include \"common.h\"\n+\n+MODULE_IMPORT_NS(\"EXPORTED_FOR_KUNIT_TESTING\");\n+\n+/* Longest hash input exercised here: an IPv6 header, a UDP header, a PSP\n+ * header and the inner TCP ports. See rss_key_test_fields[].\n+ */\n+#define RSS_KEY_TEST_INPUT_LEN\t\t68\n+\n+#define RSS_KEY_TEST_KEYS\t\t32\n+\n+/* Number of queue counts exercised end to end by rss_key_spread_test(), which\n+ * hashes 2 ** q inputs for each of them. The algebraic check covers all the\n+ * queue counts up to NETDEV_RSS_KEY_QMAX.\n+ */\n+#define RSS_KEY_TEST_SPREAD_QMAX\t6\n+\n+/* Position of the least significant bit of each field, counting from the most\n+ * significant bit of the hash input, and the length of that input. These come\n+ * from the definition of the hash, not from the key generator.\n+ */\n+static const struct rss_key_test_field {\n+\tconst char\t*name;\n+\tunsigned int\tlsb;\n+\tunsigned int\tnbits;\n+} rss_key_test_fields[] = {\n+\t{ \"IPv4 saddr\",\t\t31,\t96 },\n+\t{ \"IPv4 daddr\",\t\t63,\t96 },\n+\t{ \"IPv4 sport\",\t\t79,\t96 },\n+\t{ \"IPv4 dport\",\t\t95,\t96 },\n+\t{ \"IPv6 saddr\",\t\t127,\t288 },\n+\t{ \"IPv6 daddr\",\t\t255,\t288 },\n+\t{ \"IPv6 sport\",\t\t271,\t288 },\n+\t{ \"IPv6 dport\",\t\t287,\t288 },\n+\t/* Hardware is free to hash an encapsulated header instead, and then\n+\t * it reads the key far past the 40 bytes an IPv6 4-tuple needs. These\n+\t * offsets are those of PSP transport mode over UDP over IPv6\n+\t * (Documentation/networking/psp.rst): 40 bytes of IPv6, 8 of UDP,\n+\t * PSP_HDR_SIZE of PSP, then the inner TCP ports. Prepending an\n+\t * Ethernet header, or the 4 extra bytes of an encapsulation tag,\n+\t * shifts all of this by a whole number of 16-bit units.\n+\t */\n+\t{ \"PSP outer IPv6 saddr\",\t191,\t544 },\n+\t{ \"PSP outer IPv6 daddr\",\t319,\t544 },\n+\t{ \"PSP inner sport\",\t\t527,\t544 },\n+\t{ \"PSP inner dport\",\t\t543,\t544 },\n+};\n+\n+static bool rss_key_test_bit(const u8 *buf, unsigned int bit)\n+{\n+\treturn buf[bit / BITS_PER_BYTE] \u0026 (0x80 \u003e\u003e (bit % BITS_PER_BYTE));\n+}\n+\n+static void rss_key_test_assign_bit(u8 *buf, unsigned int bit, bool value)\n+{\n+\tu8 mask = 0x80 \u003e\u003e (bit % BITS_PER_BYTE);\n+\n+\tif (value)\n+\t\tbuf[bit / BITS_PER_BYTE] |= mask;\n+\telse\n+\t\tbuf[bit / BITS_PER_BYTE] \u0026= ~mask;\n+}\n+\n+/* The 32 key bits starting at @bit, which is what input bit @bit contributes\n+ * to the hash.\n+ */\n+static u32 rss_key_test_window(const u8 *key, unsigned int bit)\n+{\n+\tu32 window = 0;\n+\tunsigned int i;\n+\n+\tfor (i = 0; i \u003c 32; i++)\n+\t\twindow = (window \u003c\u003c 1) | rss_key_test_bit(key, bit + i);\n+\n+\treturn window;\n+}\n+\n+static u32 rss_key_test_toeplitz(const u8 *key, const u8 *input,\n+\t\t\t\t unsigned int nbits)\n+{\n+\tu32 hash = 0;\n+\tunsigned int i;\n+\n+\tfor (i = 0; i \u003c nbits; i++)\n+\t\tif (rss_key_test_bit(input, i))\n+\t\t\thash ^= rss_key_test_window(key, i);\n+\n+\treturn hash;\n+}\n+\n+/* Is the map from the q low order bits of the field at @lsb to the q low order\n+ * bits of the hash a bijection? Gaussian elimination over GF(2) on the q\n+ * windows involved, reduced to their q low order bits.\n+ */\n+static bool rss_key_test_full_rank(const u8 *key, unsigned int lsb,\n+\t\t\t\t   unsigned int q)\n+{\n+\tu32 basis[NETDEV_RSS_KEY_QMAX] = {};\n+\tunsigned int j;\n+\n+\tfor (j = 0; j \u003c q; j++) {\n+\t\tu32 v = rss_key_test_window(key, lsb - j) \u0026 (BIT(q) - 1);\n+\n+\t\twhile (v) {\n+\t\t\tunsigned int b = __ffs(v);\n+\n+\t\t\tif (!basis[b]) {\n+\t\t\t\tbasis[b] = v;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tv ^= basis[b];\n+\t\t}\n+\n+\t\tif (!v)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+/* Degenerate keys the rank check must reject, so that a check accepting\n+ * everything can not make the other tests pass.\n+ */\n+static void rss_key_checker_test(struct kunit *test)\n+{\n+\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\n+\n+\tKUNIT_ASSERT_NOT_NULL(test, key);\n+\n+\t/* All the windows are zero. */\n+\tKUNIT_EXPECT_FALSE(test, rss_key_test_full_rank(key, 31, 1));\n+\n+\t/* All the windows are equal, which is enough for one queue only. */\n+\tmemset(key, 0xff, NETDEV_RSS_KEY_LEN);\n+\tKUNIT_EXPECT_TRUE(test, rss_key_test_full_rank(key, 31, 1));\n+\tKUNIT_EXPECT_FALSE(test, rss_key_test_full_rank(key, 31, 2));\n+}\n+\n+static void rss_key_property_test(struct kunit *test)\n+{\n+\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\n+\tunsigned int i, j, q;\n+\n+\tKUNIT_ASSERT_NOT_NULL(test, key);\n+\n+\tfor (i = 0; i \u003c RSS_KEY_TEST_KEYS; i++) {\n+\t\tnetdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);\n+\n+\t\tfor (j = 0; j \u003c ARRAY_SIZE(rss_key_test_fields); j++) {\n+\t\t\tconst struct rss_key_test_field *f;\n+\n+\t\t\tf = \u0026rss_key_test_fields[j];\n+\n+\t\t\tfor (q = 1; q \u003c= NETDEV_RSS_KEY_QMAX; q++)\n+\t\t\t\tKUNIT_ASSERT_TRUE_MSG(test,\n+\t\t\t\t\t\t      rss_key_test_full_rank(key, f-\u003elsb, q),\n+\t\t\t\t\t\t      \"%s does not spread over %u queues\",\n+\t\t\t\t\t\t      f-\u003ename, 1U \u003c\u003c q);\n+\t\t}\n+\t}\n+}\n+\n+/* rss_key_test_fields[] can only list the layouts somebody thought of, but\n+ * the generator does not get to know what the hardware hashes. Sweep the\n+ * whole key instead: the property has to hold at every 16-bit aligned\n+ * position, which is where a field of any layout can end.\n+ */\n+static void rss_key_grid_test(struct kunit *test)\n+{\n+\tunsigned int bits = NETDEV_RSS_KEY_LEN * BITS_PER_BYTE;\n+\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\n+\tunsigned int i, lsb, q;\n+\n+\tKUNIT_ASSERT_NOT_NULL(test, key);\n+\n+\tfor (i = 0; i \u003c RSS_KEY_TEST_KEYS; i++) {\n+\t\tnetdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);\n+\n+\t\tfor (lsb = 15; lsb + 32 \u003c= bits; lsb += 16)\n+\t\t\tfor (q = 1; q \u003c= NETDEV_RSS_KEY_QMAX; q++)\n+\t\t\t\tKUNIT_ASSERT_TRUE_MSG(test,\n+\t\t\t\t\t\t      rss_key_test_full_rank(key, lsb, q),\n+\t\t\t\t\t\t      \"field ending at bit %u does not spread over %u queues\",\n+\t\t\t\t\t\t      lsb, 1U \u003c\u003c q);\n+\t}\n+}\n+\n+static int rss_key_test_cmp(const void *a, const void *b)\n+{\n+\tu32 x = *(const u32 *)a, y = *(const u32 *)b;\n+\n+\treturn x \u003c y ? -1 : x \u003e y;\n+}\n+\n+/* Two input bits contributing the same 32-bit window are indistinguishable\n+ * to the hash: flipping both of them leaves it unchanged, so the flows of a\n+ * burst differing in exactly those two bits all collide. A uniformly random\n+ * key has such a pair with probability 2 ** -11, and the generated key must\n+ * not do worse.\n+ *\n+ * netdev_rss_key_init() redraws on a collision at a distance that is a\n+ * multiple of 8, which is where the fixup makes one likely, and leaves every\n+ * other distance at the odds of a random key. So assert on what it\n+ * guarantees: group the windows by their offset modulo 8 and sort each group\n+ * on its own. Sorting all of them together instead would be asserting on the\n+ * random odds, and would fail about one run in 26 on a correct kernel.\n+ */\n+static void rss_key_alias_test(struct kunit *test)\n+{\n+\tunsigned int count = NETDEV_RSS_KEY_LEN * BITS_PER_BYTE - 31;\n+\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\n+\tunsigned int i, j, n, r;\n+\tu32 *windows;\n+\n+\twindows = kunit_kcalloc(test, count, sizeof(*windows), GFP_KERNEL);\n+\tKUNIT_ASSERT_NOT_NULL(test, key);\n+\tKUNIT_ASSERT_NOT_NULL(test, windows);\n+\n+\tfor (i = 0; i \u003c RSS_KEY_TEST_KEYS; i++) {\n+\t\tnetdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);\n+\n+\t\tfor (r = 0; r \u003c 8; r++) {\n+\t\t\tn = 0;\n+\t\t\tfor (j = r; j \u003c count; j += 8)\n+\t\t\t\twindows[n++] = rss_key_test_window(key, j);\n+\n+\t\t\tsort(windows, n, sizeof(*windows),\n+\t\t\t     rss_key_test_cmp, NULL);\n+\n+\t\t\tfor (j = 1; j \u003c n; j++)\n+\t\t\t\tKUNIT_ASSERT_NE_MSG(test, windows[j],\n+\t\t\t\t\t\t    windows[j - 1],\n+\t\t\t\t\t\t    \"two input bits a multiple of 8 apart read the same key window %08x\",\n+\t\t\t\t\t\t    windows[j]);\n+\t\t}\n+\t}\n+}\n+\n+/* Hash the inputs of a burst differing only in the low order bits of one\n+ * field, and check that they fill the indirection table evenly.\n+ */\n+static void rss_key_spread_test(struct kunit *test)\n+{\n+\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\n+\tu8 *input = kunit_kzalloc(test, RSS_KEY_TEST_INPUT_LEN, GFP_KERNEL);\n+\tunsigned int i, j, q;\n+\n+\tKUNIT_ASSERT_NOT_NULL(test, key);\n+\tKUNIT_ASSERT_NOT_NULL(test, input);\n+\n+\tnetdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);\n+\n+\tfor (i = 0; i \u003c ARRAY_SIZE(rss_key_test_fields); i++) {\n+\t\tconst struct rss_key_test_field *f = \u0026rss_key_test_fields[i];\n+\n+\t\tfor (q = 1; q \u003c= RSS_KEY_TEST_SPREAD_QMAX; q++) {\n+\t\t\tu64 seen = 0;\n+\n+\t\t\tget_random_bytes(input, RSS_KEY_TEST_INPUT_LEN);\n+\n+\t\t\tfor (j = 0; j \u003c (1U \u003c\u003c q); j++) {\n+\t\t\t\tunsigned int t, queue;\n+\t\t\t\tu32 hash;\n+\n+\t\t\t\tfor (t = 0; t \u003c q; t++)\n+\t\t\t\t\trss_key_test_assign_bit(input,\n+\t\t\t\t\t\t\t\tf-\u003elsb - t,\n+\t\t\t\t\t\t\t\tj \u0026 BIT(t));\n+\n+\t\t\t\thash = rss_key_test_toeplitz(key, input,\n+\t\t\t\t\t\t\t     f-\u003enbits);\n+\t\t\t\tqueue = hash \u0026 (BIT(q) - 1);\n+\n+\t\t\t\tKUNIT_ASSERT_FALSE_MSG(test, seen \u0026 BIT_ULL(queue),\n+\t\t\t\t\t\t       \"%s hits queue %u twice out of %u\",\n+\t\t\t\t\t\t       f-\u003ename, queue, 1U \u003c\u003c q);\n+\t\t\t\tseen |= BIT_ULL(queue);\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n+static struct kunit_case rss_key_test_cases[] = {\n+\tKUNIT_CASE(rss_key_checker_test),\n+\tKUNIT_CASE(rss_key_property_test),\n+\tKUNIT_CASE(rss_key_grid_test),\n+\tKUNIT_CASE(rss_key_alias_test),\n+\tKUNIT_CASE(rss_key_spread_test),\n+\t{},\n+};\n+\n+static struct kunit_suite rss_key_test_suite = {\n+\t.name = \"ethtool-rss-key\",\n+\t.test_cases = rss_key_test_cases,\n+};\n+\n+kunit_test_suite(rss_key_test_suite);\n+\n+MODULE_DESCRIPTION(\"Tests for the RSS key generated by netdev_rss_key_fill()\");\n+MODULE_LICENSE(\"GPL\");\ndiff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile\nindex 8aebdc6feb177..9bcf3c1e8caa2 100644\n--- a/tools/testing/selftests/drivers/net/hw/Makefile\n+++ b/tools/testing/selftests/drivers/net/hw/Makefile\n@@ -46,6 +46,7 @@ TEST_PROGS = \\\n \trss_drv.py \\\n \trss_flow_label.py \\\n \trss_input_xfrm.py \\\n+\trss_key.py \\\n \ttoeplitz.py \\\n \ttso.py \\\n \tuserns_devmem.py \\\ndiff --git a/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py b/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py\nindex 81e1d1865cd50..96edd9dfe9e3b 100644\n--- a/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py\n+++ b/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py\n@@ -26,6 +26,8 @@ try:\n         fd_read_timeout, ip, rand_port, rand_ports, wait_port_listen, \\\n         wait_file, ctl_file_write, tool\n     from net.lib.py import bpf_map_set, bpf_map_dump, bpf_prog_map_ids\n+    from net.lib.py import RSS_KEY_QMAX, rss_key_bit, rss_key_assign_bit, \\\n+        rss_key_window, rss_key_toeplitz, rss_key_full_rank, rss_key_layout\n     from net.lib.py import KsftSkipEx, KsftFailEx, KsftXfailEx\n     from net.lib.py import ksft_disruptive, ksft_exit, ksft_pr, ksft_run, \\\n         ksft_setup, ksft_variants, KsftNamedVariant\n@@ -42,6 +44,9 @@ try:\n                \"fd_read_timeout\", \"ip\", \"rand_port\", \"rand_ports\",\n                \"wait_port_listen\", \"wait_file\", \"ctl_file_write\", \"tool\",\n                \"bpf_map_set\", \"bpf_map_dump\", \"bpf_prog_map_ids\",\n+               \"RSS_KEY_QMAX\", \"rss_key_bit\", \"rss_key_assign_bit\",\n+               \"rss_key_window\", \"rss_key_toeplitz\", \"rss_key_full_rank\",\n+               \"rss_key_layout\",\n                \"KsftSkipEx\", \"KsftFailEx\", \"KsftXfailEx\",\n                \"ksft_disruptive\", \"ksft_exit\", \"ksft_pr\", \"ksft_run\",\n                \"ksft_setup\", \"ksft_variants\", \"KsftNamedVariant\",\ndiff --git a/tools/testing/selftests/drivers/net/hw/rss_key.py b/tools/testing/selftests/drivers/net/hw/rss_key.py\nnew file mode 100755\nindex 0000000000000..dc7095f6663cd\n--- /dev/null\n+++ b/tools/testing/selftests/drivers/net/hw/rss_key.py\n@@ -0,0 +1,172 @@\n+#!/usr/bin/env python3\n+# SPDX-License-Identifier: GPL-2.0\n+\n+\"\"\"\n+Check that the RSS key a device actually uses spreads flows over all of the\n+entries of its indirection table.\n+\n+Most drivers take their key from netdev_rss_key_fill(), which generates keys\n+having that property, but some bring their own and firmware sometimes\n+installs one of its own. This reads back the key the device reports, so it\n+covers wherever the key came from. See net/lib/py/rsskey.py for what the\n+property is and why a random key is not good enough.\n+\"\"\"\n+\n+import random\n+\n+from lib.py import ksft_run, ksft_exit, ksft_pr\n+from lib.py import ksft_eq\n+from lib.py import KsftSkipEx\n+from lib.py import NetDrvEnv, EthtoolFamily, cmd\n+from lib.py import RSS_KEY_QMAX, rss_key_assign_bit, rss_key_toeplitz, \\\n+    rss_key_full_rank, rss_key_layout\n+\n+# \"define\" for the ID of the Toeplitz hash function\n+ETH_RSS_HASH_TOP = 1\n+\n+FLOW_TYPES = (\"tcp4\", \"udp4\", \"tcp6\", \"udp6\")\n+\n+# How ethtool -n spells the fields of the hash input.\n+FIELD_NAMES = {\n+    \"IP SA\": \"s\",\n+    \"IP DA\": \"d\",\n+    \"L3 proto\": \"t\",\n+    \"L4 bytes 0 \u0026 1 [TCP/UDP src port]\": \"f\",\n+    \"L4 bytes 2 \u0026 3 [TCP/UDP dst port]\": \"n\",\n+    \"IPv6 Flow Label\": \"l\",\n+}\n+\n+\n+def _get_rss(cfg):\n+    \"\"\"The key and indirection table of @cfg's device, or a skip.\"\"\"\n+    rss = cfg.ethnl.rss_get({\"header\": {\"dev-index\": cfg.ifindex}})\n+\n+    hkey = rss.get(\"hkey\")\n+    if not hkey or not any(hkey):\n+        raise KsftSkipEx(f\"{cfg.ifname} does not report an RSS key\")\n+\n+    if rss.get(\"hfunc\") != ETH_RSS_HASH_TOP:\n+        raise KsftSkipEx(f\"{cfg.ifname} does not use the Toeplitz hash\")\n+\n+    if rss.get(\"input-xfrm\"):\n+        raise KsftSkipEx(f\"{cfg.ifname} transforms the hash input\")\n+\n+    indir = rss.get(\"indir\")\n+    if not indir:\n+        raise KsftSkipEx(f\"{cfg.ifname} does not report an indirection table\")\n+\n+    if len(indir) \u0026 (len(indir) - 1):\n+        raise KsftSkipEx(f\"{cfg.ifname} has {len(indir)} indirection table \"\n+                         \"entries, which is not a power of two\")\n+\n+    return bytes(hkey), indir\n+\n+\n+def _get_layouts(cfg):\n+    \"\"\"The hash input layouts in use, mapped to the flow types sharing them.\"\"\"\n+    layouts = {}\n+\n+    for fl_type in FLOW_TYPES:\n+        proc = cmd(f\"ethtool -n {cfg.ifname} rx-flow-hash {fl_type}\",\n+                   fail=False)\n+        if proc.ret:\n+            continue\n+\n+        fields = \"\"\n+        for line in proc.stdout.split(\"\\n\")[1:-2]:\n+            # if this raises we probably need to add more keys to FIELD_NAMES\n+            fields += FIELD_NAMES[line]\n+\n+        layout, nbits = rss_key_layout(fields, fl_type.endswith(\"6\"))\n+        if layout is None:\n+            ksft_pr(f\"{fl_type}: not checked, hashes fields we can not place \"\n+                    f\"({fields})\")\n+            continue\n+\n+        layouts.setdefault((tuple(layout), nbits), []).append(fl_type)\n+\n+    if not layouts:\n+        raise KsftSkipEx(\"no flow type with a hash input we can describe\")\n+\n+    return layouts\n+\n+\n+def test_rss_key_rank(cfg) -\u003e None:\n+    \"\"\"The key has to be non singular for the size of the table.\"\"\"\n+    hkey, indir = _get_rss(cfg)\n+    q = min((len(indir) - 1).bit_length(), RSS_KEY_QMAX)\n+    degenerate = []\n+\n+    if not q:\n+        raise KsftSkipEx(\"the indirection table has a single entry\")\n+\n+    for (layout, _), fl_types in _get_layouts(cfg).items():\n+        for name, lsb in layout:\n+            if lsb + 32 \u003e len(hkey) * 8:\n+                ksft_pr(f\"{name}: not checked, the key is {len(hkey)} bytes\")\n+                continue\n+\n+            if not rss_key_full_rank(hkey, lsb, q):\n+                degenerate.append(f\"{'/'.join(fl_types)} {name}\")\n+\n+    for bad in degenerate:\n+        ksft_pr(f\"degenerate: {bad}\")\n+\n+    ksft_eq(len(degenerate), 0,\n+            f\"the key of {cfg.ifname} does not spread flows over the \"\n+            f\"{1 \u003c\u003c q} entries of its indirection table\")\n+\n+\n+def test_rss_key_spread(cfg) -\u003e None:\n+    \"\"\"Hash bursts differing in one field only, and place them in the table.\"\"\"\n+    hkey, indir = _get_rss(cfg)\n+    q = (len(indir) - 1).bit_length()\n+    collisions = []\n+\n+    if q \u003e RSS_KEY_QMAX:\n+        raise KsftSkipEx(f\"{len(indir)} indirection table entries is more \"\n+                         \"than the kernel guarantees\")\n+    if not q:\n+        raise KsftSkipEx(\"the indirection table has a single entry\")\n+\n+    for (layout, nbits), fl_types in _get_layouts(cfg).items():\n+        # Unlike the rank check, this hashes the whole input, so it reads\n+        # the key up to 31 bits past its last bit rather than past the last\n+        # bit of one field.\n+        if nbits + 31 \u003e len(hkey) * 8:\n+            ksft_pr(f\"{'/'.join(fl_types)}: not checked, the key is \"\n+                    f\"{len(hkey)} bytes\")\n+            continue\n+\n+        for name, lsb in layout:\n+            inp = bytearray(random.randbytes(nbits // 8))\n+            entries = set()\n+            for value in range(1 \u003c\u003c q):\n+                for bit in range(q):\n+                    rss_key_assign_bit(inp, lsb - bit, value \u0026 (1 \u003c\u003c bit))\n+                hash_ = rss_key_toeplitz(hkey, inp, nbits)\n+                entries.add(hash_ \u0026 (len(indir) - 1))\n+\n+            if len(entries) != 1 \u003c\u003c q:\n+                collisions.append(f\"{'/'.join(fl_types)} {name} reaches \"\n+                                  f\"{len(entries)} of the {1 \u003c\u003c q} entries\")\n+\n+    for bad in collisions:\n+        ksft_pr(bad)\n+\n+    ksft_eq(len(collisions), 0,\n+            f\"flows differing in one field only do not fill the \"\n+            f\"indirection table of {cfg.ifname}\")\n+\n+\n+def main() -\u003e None:\n+    \"\"\" Ksft boiler plate main \"\"\"\n+\n+    with NetDrvEnv(__file__, nsim_test=False) as cfg:\n+        cfg.ethnl = EthtoolFamily()\n+        ksft_run(globs=globals(), case_pfx={\"test_\"}, args=(cfg, ))\n+    ksft_exit()\n+\n+\n+if __name__ == \"__main__\":\n+    main()\ndiff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile\nindex 3ee3378f8b26e..cba6084914af5 100644\n--- a/tools/testing/selftests/net/Makefile\n+++ b/tools/testing/selftests/net/Makefile\n@@ -67,6 +67,7 @@ TEST_PROGS := \\\n \tnat6to4.sh \\\n \tndisc_unsolicited_na_test.sh \\\n \tnetdev-l2addr.sh \\\n+\tnetdev_rss_key.py \\\n \tnetdevice.sh \\\n \tnetns-name.sh \\\n \tnetns-sysctl.sh \\\ndiff --git a/tools/testing/selftests/net/lib/py/__init__.py b/tools/testing/selftests/net/lib/py/__init__.py\nindex 71df5880b356a..7648ab6c2adae 100644\n--- a/tools/testing/selftests/net/lib/py/__init__.py\n+++ b/tools/testing/selftests/net/lib/py/__init__.py\n@@ -16,6 +16,8 @@ from .utils import CmdExitFailure, fd_read_timeout, cmd, bkg, defer, \\\n     bpftool, ip, ethtool, bpftrace, rand_port, rand_ports, wait_port_listen, \\\n     ctl_file_write, wait_file, tool, tc\n from .bpf import bpf_map_set, bpf_map_dump, bpf_prog_map_ids\n+from .rsskey import RSS_KEY_QMAX, rss_key_bit, rss_key_assign_bit, \\\n+    rss_key_window, rss_key_toeplitz, rss_key_full_rank, rss_key_layout\n from .ynl import NlError, NlctrlFamily, YnlFamily, \\\n     EthtoolFamily, NetdevFamily, RtnlFamily, RtnlAddrFamily, RtnlRouteFamily\n from .ynl import NetshaperFamily, DevlinkFamily, PSPFamily, Netlink\n@@ -31,6 +33,9 @@ __all__ = [\"KSRC\",\n            \"bpftool\", \"ip\", \"ethtool\", \"bpftrace\", \"rand_port\", \"rand_ports\",\n            \"wait_port_listen\", \"ctl_file_write\", \"wait_file\", \"tool\", \"tc\",\n            \"bpf_map_set\", \"bpf_map_dump\", \"bpf_prog_map_ids\",\n+           \"RSS_KEY_QMAX\", \"rss_key_bit\", \"rss_key_assign_bit\",\n+           \"rss_key_window\", \"rss_key_toeplitz\", \"rss_key_full_rank\",\n+           \"rss_key_layout\",\n            \"NetdevSim\", \"NetdevSimDev\",\n            \"NetshaperFamily\", \"DevlinkFamily\", \"PSPFamily\", \"NlError\",\n            \"YnlFamily\", \"EthtoolFamily\", \"NetdevFamily\", \"RtnlFamily\",\ndiff --git a/tools/testing/selftests/net/lib/py/rsskey.py b/tools/testing/selftests/net/lib/py/rsskey.py\nnew file mode 100644\nindex 0000000000000..4451eb80fb457\n--- /dev/null\n+++ b/tools/testing/selftests/net/lib/py/rsskey.py\n@@ -0,0 +1,108 @@\n+# SPDX-License-Identifier: GPL-2.0\n+\n+\"\"\"\n+Helpers to check the quality of an RSS key.\n+\n+The Toeplitz hash is linear over GF(2): the hash is the XOR of the 32 bit key\n+windows selected by the set bits of the input, and hardware indexes the\n+indirection table with the low order bits of the hash. The windows belonging\n+to the q lowest bits of a header field therefore form a Toeplitz matrix, and\n+when that matrix is singular the flows of a burst differing only in those\n+bits, consecutive ephemeral ports typically, can not reach all of the 2 ** q\n+entries of the table. A key drawn uniformly at random is singular for a given\n+field and a given q with probability 1/2.\n+\n+netdev_rss_key_fill() generates keys that are non singular for every field of\n+the hash input and every q up to RSS_KEY_QMAX.\n+\"\"\"\n+\n+# Matches NETDEV_RSS_KEY_QMAX, that is up to 256 entries of the table.\n+RSS_KEY_QMAX = 8\n+\n+\n+def rss_key_bit(buf, bit):\n+    \"\"\"Bit @bit of @buf, counting from the most significant bit of byte 0.\"\"\"\n+    return (buf[bit // 8] \u003e\u003e (7 - bit % 8)) \u0026 1\n+\n+\n+def rss_key_assign_bit(buf, bit, value):\n+    mask = 0x80 \u003e\u003e (bit % 8)\n+\n+    if value:\n+        buf[bit // 8] |= mask\n+    else:\n+        buf[bit // 8] \u0026= ~mask\n+\n+\n+def rss_key_window(key, bit):\n+    \"\"\"The 32 key bits starting at @bit, what input bit @bit contributes.\"\"\"\n+    value = 0\n+\n+    for i in range(32):\n+        value = (value \u003c\u003c 1) | rss_key_bit(key, bit + i)\n+\n+    return value\n+\n+\n+def rss_key_toeplitz(key, inp, nbits):\n+    \"\"\"The Toeplitz hash of the @nbits long input @inp under @key.\"\"\"\n+    value = 0\n+\n+    for i in range(nbits):\n+        if rss_key_bit(inp, i):\n+            value ^= rss_key_window(key, i)\n+\n+    return value\n+\n+\n+def rss_key_full_rank(key, lsb, q):\n+    \"\"\"Do the q low order bits of the field at @lsb reach all 2 ** q entries?\n+\n+    Gaussian elimination over GF(2) on the q windows involved, reduced to\n+    their q low order bits, which are the ones indexing the table.\n+    \"\"\"\n+    basis = {}\n+\n+    for j in range(q):\n+        vector = rss_key_window(key, lsb - j) \u0026 ((1 \u003c\u003c q) - 1)\n+\n+        while vector:\n+            low = vector \u0026 -vector\n+            if low not in basis:\n+                basis[low] = vector\n+                break\n+            vector ^= basis[low]\n+\n+        if not vector:\n+            return False\n+\n+    return True\n+\n+\n+def rss_key_layout(fields, ipv6):\n+    \"\"\"Describe the hash input built from @fields, as ethtool -n reports it.\n+\n+    @fields is the flow hash configuration, \"sdfn\" for a 4-tuple or \"sd\" for\n+    a 2-tuple. Returns the list of (name, position of the least significant\n+    bit) and the length of the input in bits, or None if the layout involves\n+    something this does not know how to place.\n+    \"\"\"\n+    addr_bits = 128 if ipv6 else 32\n+    known = ((\"s\", \"saddr\", addr_bits),\n+             (\"d\", \"daddr\", addr_bits),\n+             (\"f\", \"sport\", 16),\n+             (\"n\", \"dport\", 16))\n+\n+    if set(fields) - {flag for flag, _, _ in known}:\n+        return None, 0\n+\n+    layout = []\n+    nbits = 0\n+\n+    for flag, name, width in known:\n+        if flag not in fields:\n+            continue\n+        nbits += width\n+        layout.append((name, nbits - 1))\n+\n+    return layout, nbits\ndiff --git a/tools/testing/selftests/net/netdev_rss_key.py b/tools/testing/selftests/net/netdev_rss_key.py\nnew file mode 100755\nindex 0000000000000..37be2ebea6f7c\n--- /dev/null\n+++ b/tools/testing/selftests/net/netdev_rss_key.py\n@@ -0,0 +1,117 @@\n+#!/usr/bin/env python3\n+# SPDX-License-Identifier: GPL-2.0\n+\n+\"\"\"\n+Check the quality of the host RSS key, /proc/sys/net/core/netdev_rss_key.\n+\n+This is the key netdev_rss_key_fill() hands to the drivers. It has to be non\n+singular for every field of the hash input and every queue count up to\n+2 ** RSS_KEY_QMAX, see lib/py/rsskey.py for what that means and why it\n+matters. Unlike the KUnit tests of the generator, this checks the key the\n+running kernel has actually handed out.\n+\n+The key is generated lazily, the first time a driver asks for it, so this\n+test skips until a driver has done so. Any NIC calling netdev_rss_key_fill()\n+is enough; in a virtual machine, virtio_net does it from\n+virtnet_init_default_rss() once RSS has been negotiated.\n+\n+Checking what a given NIC really uses is a different question, since a\n+driver may bring its own key. See drivers/net/hw/rss_key.py for that.\n+\"\"\"\n+\n+from lib.py import ksft_run, ksft_exit, ksft_pr\n+from lib.py import ksft_eq, ksft_ge\n+from lib.py import KsftSkipEx\n+from lib.py import RSS_KEY_QMAX, rss_key_full_rank, rss_key_layout\n+\n+KEY_PATH = \"/proc/sys/net/core/netdev_rss_key\"\n+\n+# Shortest key able to hash an IPv6 4-tuple.\n+MIN_KEY_LEN = 40\n+\n+\n+def _read_key():\n+    \"\"\"Return the host RSS key, skipping if it has not been generated.\"\"\"\n+    try:\n+        with open(KEY_PATH, \"r\", encoding=\"ascii\") as fp:\n+            text = fp.read().strip()\n+    except FileNotFoundError as exc:\n+        raise KsftSkipEx(f\"{KEY_PATH} is not available\") from exc\n+\n+    key = bytes(int(byte, 16) for byte in text.split(\":\"))\n+\n+    if not any(key):\n+        raise KsftSkipEx(\"the host RSS key has not been generated yet, \"\n+                         \"no driver has called netdev_rss_key_fill()\")\n+\n+    return key\n+\n+\n+def check_length() -\u003e None:\n+    key = _read_key()\n+\n+    ksft_pr(f\"host RSS key is {len(key)} bytes\")\n+    ksft_ge(len(key), MIN_KEY_LEN, \"key too short to hash an IPv6 4-tuple\")\n+\n+\n+def check_spread() -\u003e None:\n+    key = _read_key()\n+    degenerate = []\n+\n+    for ipv6 in (False, True):\n+        layout, _ = rss_key_layout(\"sdfn\", ipv6)\n+        family = \"IPv6\" if ipv6 else \"IPv4\"\n+\n+        for name, lsb in layout:\n+            if lsb + 32 \u003e len(key) * 8:\n+                continue\n+\n+            for q in range(1, RSS_KEY_QMAX + 1):\n+                if not rss_key_full_rank(key, lsb, q):\n+                    degenerate.append(f\"{family} {name} over {1 \u003c\u003c q} queues\")\n+\n+    for bad in degenerate:\n+        ksft_pr(f\"degenerate: {bad}\")\n+\n+    ksft_eq(len(degenerate), 0,\n+            \"the host RSS key does not spread flows over all the queues\")\n+\n+\n+def check_grid() -\u003e None:\n+    \"\"\"Sweep the whole key, not only the fields of the usual layouts.\n+\n+    netdev_rss_key_fill() does not get to know what the hardware hashes, so\n+    it gives the property at every 16-bit aligned position of the key. A NIC\n+    hashing an encapsulated header reads the key well past the first 40\n+    bytes, and has to find the same guarantee there.\n+    \"\"\"\n+    key = _read_key()\n+    bits = len(key) * 8\n+    positions = 0\n+    degenerate = []\n+\n+    for lsb in range(15, bits - 31, 16):\n+        positions += 1\n+\n+        for q in range(1, RSS_KEY_QMAX + 1):\n+            if not rss_key_full_rank(key, lsb, q):\n+                degenerate.append(f\"field ending at bit {lsb} \"\n+                                  f\"over {1 \u003c\u003c q} queues\")\n+\n+    ksft_pr(f\"checked {positions} positions of the {len(key)} byte key\")\n+\n+    for bad in degenerate[:8]:\n+        ksft_pr(f\"degenerate: {bad}\")\n+\n+    ksft_eq(len(degenerate), 0,\n+            \"the host RSS key does not spread flows over all the queues \"\n+            \"at every 16-bit aligned position\")\n+\n+\n+def main() -\u003e None:\n+    ksft_run(globs=globals(), case_pfx={\"check_\"})\n+    ksft_exit()\n+\n+\n+if __name__ == \"__main__\":\n+    main()\n"
}

2/1 2026/09/23 18:08 agent patch-evaluator
4m Model:
core

Args:
null

Results:
{
  "EnableConfigs": [
    "NET",
    "SYSCTL",
    "VIRTIO_NET"
  ],
  "FocusSymbols": [
    "proc_do_rss_key",
    "netdev_rss_key_fill",
    "netdev_rss_key_init",
    "netdev_rss_key_aliases",
    "netdev_rss_key_fixup_field"
  ],
  "Reasoning": "The patch introduces new algorithmic key generation and alias-checking logic in net/ethtool/ioctl.c (netdev_rss_key_init(), netdev_rss_key_fixup_field(), netdev_rss_key_aliases()) used by netdev_rss_key_fill() to generate non-singular Toeplitz RSS keys. It also updates the procfs sysctl handler proc_do_rss_key() in net/core/sysctl_net_core.c with memory barriers and initialization state tracking. Because this touches core networking logic reachable via virtual network drivers (e.g. virtio_net in QEMU, gve in GCE) as well as the /proc/sys/net/core/netdev_rss_key sysctl interface, it touches reachable executable code and warrants fuzzing.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 8db3b7dacd5116913755365bd01f62cd92bd07bd
Author: syz-cluster <triage@syzkaller.com>
Date:   Wed Sep 23 18:08:13 2026 +0000

    syz-cluster: applied patch under review

diff --git a/Documentation/networking/scaling.rst b/Documentation/networking/scaling.rst
index 6c261eb48845a..6c9836000a8d1 100644
--- a/Documentation/networking/scaling.rst
+++ b/Documentation/networking/scaling.rst
@@ -48,6 +48,15 @@ count is not a power of two. NICs should provide an indirection table
 at least 4 times larger than the queue count. 4x table results in ~16%
 imbalance between the queues, which is acceptable for most applications.
 
+The Toeplitz hash is linear over GF(2), so the quality of the hash key
+matters as much as its randomness. For a key made of uniformly random
+bytes, the q lowest order bits of a given header field fail to spread
+flows over all 2^q queues with probability 1/2, and a burst of connections
+picking nearly consecutive ephemeral ports then lands on a fraction of the
+queues while the others stay idle. The netdev_rss_key_fill() helper draws
+a random key that is free of this defect; drivers should use it rather
+than seeding a key of their own.
+
 Some NICs support symmetric RSS hashing where, if the IP (source address,
 destination address) and TCP/UDP (source port, destination port) tuples
 are swapped, the computed hash is the same. This is beneficial in some
diff --git a/net/Kconfig b/net/Kconfig
index e384773935515..4a8dc0e5b075a 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -540,4 +540,18 @@ config NET_TEST
 
 	  If unsure, say N.
 
+config ETHTOOL_RSS_KEY_KUNIT_TEST
+	tristate "KUnit tests for the generated RSS key" if !KUNIT_ALL_TESTS
+	depends on KUNIT
+	default KUNIT_ALL_TESTS
+	help
+	  KUnit tests checking the RSS key that netdev_rss_key_fill() hands
+	  to the drivers: flows differing only in the low order bits of one
+	  hashed header field have to spread over all the RX queues, for
+	  every field of the Toeplitz hash inputs, for every 16-bit aligned
+	  position of the key, and for every queue count up to
+	  2 ** NETDEV_RSS_KEY_QMAX.
+
+	  If unsure, say N.
+
 endif   # if NET
diff --git a/net/core/dev.h b/net/core/dev.h
index b757faead4d1a..0127b4d03e525 100644
--- a/net/core/dev.h
+++ b/net/core/dev.h
@@ -95,6 +95,7 @@ extern int		netdev_unregister_timeout_secs;
 extern int		weight_p;
 extern int		dev_weight_rx_bias;
 extern int		dev_weight_tx_bias;
+extern bool		netdev_rss_key_initialized;
 
 extern struct rw_semaphore dev_addr_sem;
 
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 23310581f4945..e30219765db39 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -338,9 +338,14 @@ static int proc_do_rss_key(const struct ctl_table *table, int write,
 	char buf[NETDEV_RSS_KEY_LEN * 3];
 	struct ctl_table fake_table;
 	char *pos = buf;
+	bool initialized;
+
+	initialized = READ_ONCE(netdev_rss_key_initialized);
+	/* Pair with smp_wmb() in netdev_rss_key_fill(). */
+	smp_rmb();
 
 	for (int i = 0; i < NETDEV_RSS_KEY_LEN; i++) {
-		pos = hex_byte_pack(pos, netdev_rss_key[i]);
+		pos = hex_byte_pack(pos, initialized ? netdev_rss_key[i] : 0);
 		*pos++ = ':';
 	}
 	*(--pos) = 0;
diff --git a/net/ethtool/Makefile b/net/ethtool/Makefile
index 629c10916670e..6588cfe652810 100644
--- a/net/ethtool/Makefile
+++ b/net/ethtool/Makefile
@@ -10,3 +10,5 @@ ethtool_nl-y	:= netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \
 		   tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \
 		   module.o cmis_fw_update.o cmis_cdb.o pse-pd.o plca.o \
 		   phy.o tsconfig.o mse.o
+
+obj-$(CONFIG_ETHTOOL_RSS_KEY_KUNIT_TEST)	+= rss_key_test.o
diff --git a/net/ethtool/common.h b/net/ethtool/common.h
index 4e5356e26f400..c1b6191f45693 100644
--- a/net/ethtool/common.h
+++ b/net/ethtool/common.h
@@ -15,6 +15,17 @@
 #define __SOF_TIMESTAMPING_CNT (const_ilog2(SOF_TIMESTAMPING_LAST) + 1)
 #define __HWTSTAMP_FLAG_CNT (const_ilog2(HWTSTAMP_FLAG_LAST) + 1)
 
+/* netdev_rss_key_fill() guarantees that flows differing only in the low order
+ * bits of one hashed header field spread over all the RX queues, for any queue
+ * count up to 2 ** NETDEV_RSS_KEY_QMAX and any 16-bit aligned field of the
+ * hash input. See netdev_rss_key_init().
+ */
+#define NETDEV_RSS_KEY_QMAX	8
+
+#if IS_ENABLED(CONFIG_KUNIT)
+void netdev_rss_key_init(u8 *key, size_t len);
+#endif
+
 struct genl_info;
 struct hwtstamp_provider_desc;
 
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 4b0bc503f9307..e625175ed1cbd 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -25,15 +25,20 @@
 #include <linux/rtnetlink.h>
 #include <linux/sched/signal.h>
 #include <linux/net.h>
+#include <linux/once.h>
 #include <linux/pm_runtime.h>
+#include <linux/random.h>
+#include <linux/unaligned.h>
 #include <linux/utsname.h>
 #include <linux/ethtool_netlink.h>
+#include <kunit/visibility.h>
 #include <net/devlink.h>
 #include <net/ipv6.h>
 #include <net/flow_offload.h>
 #include <net/netdev_lock.h>
 #include <net/netdev_queues.h>
 
+#include "../core/dev.h"
 #include "common.h"
 
 /* State held across locks and calls for commands which have devlink fallback */
@@ -1302,11 +1307,174 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,
 }
 
 u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly;
+bool netdev_rss_key_initialized __read_mostly;
+
+/* Toeplitz is linear over GF(2): the hash is the XOR of the 32-bit key
+ * windows selected by the set bits of the input, and hardware indexes the
+ * indirection table with the low order bits of the hash. Only the tail of
+ * each window therefore matters for queue selection:
+ *
+ *	v(i) = key bits [i + 32 - q .. i + 31]
+ *
+ * for input bit @i, with q = log2(number of RX queues). Consecutive input
+ * bits give windows overlapping in q - 1 positions, so the matrix formed by
+ * the windows of the q lowest bits of a header field is a Toeplitz matrix
+ * built from 2 * q - 1 key bits, not from q * q independent ones. A random
+ * Toeplitz matrix over GF(2) is singular with probability 1/2, whatever its
+ * size, and when it is singular the flows of a burst differing only in the
+ * low order bits of that field (consecutive ephemeral ports, typically)
+ * cannot reach all the RX queues no matter how many of them are configured.
+ *
+ * Keep the key random, but constrain the few bits that decide this. The
+ * fixup is applied at every 16-bit aligned position of the key, rather than
+ * at the offsets of the one hash input layout the software happens to know
+ * about: hardware is free to hash whatever it wants, but the fields it picks
+ * are 16 bits wide at the smallest and are not expected to straddle that
+ * grid, so an encapsulated or offloaded layout is covered like the usual
+ * 2-tuple and 4-tuple ones. Each position constrains 2 * q - 1 bits, so
+ * NETDEV_RSS_KEY_QMAX is both enough for 256 queues and the largest value
+ * keeping the ranges of two adjacent positions disjoint.
+ */
+#define NETDEV_RSS_KEY_SPAN	(2 * NETDEV_RSS_KEY_QMAX - 1)
+
+static bool netdev_rss_key_bit(const u8 *key, unsigned int bit)
+{
+	return key[bit / BITS_PER_BYTE] & (0x80 >> (bit % BITS_PER_BYTE));
+}
+
+static void netdev_rss_key_assign_bit(u8 *key, unsigned int bit, bool value)
+{
+	u8 mask = 0x80 >> (bit % BITS_PER_BYTE);
+
+	if (value)
+		key[bit / BITS_PER_BYTE] |= mask;
+	else
+		key[bit / BITS_PER_BYTE] &= ~mask;
+}
+
+/* Writing d[t] for key bit (@lsb + 31 - t), the matrices of all the q values
+ * up to NETDEV_RSS_KEY_QMAX are non singular if and only if
+ *
+ *	d[2 * i] = 1 ^ d[i] ^ d[i + 1] ^ ... ^ d[2 * i - 1]
+ *
+ * The odd positions stay free, so this is a one pass fixup rather than a
+ * search. It is also a bijection onto the set of the values having the
+ * property, so the key stays uniformly distributed over that set. It costs
+ * NETDEV_RSS_KEY_QMAX bits of entropy per position.
+ */
+static void netdev_rss_key_fixup_field(u8 *key, unsigned int lsb)
+{
+	bool d[NETDEV_RSS_KEY_SPAN];
+	unsigned int i, t;
+
+	for (t = 0; t < NETDEV_RSS_KEY_SPAN; t++)
+		d[t] = netdev_rss_key_bit(key, lsb + 31 - t);
+
+	for (i = 0; 2 * i < NETDEV_RSS_KEY_SPAN; i++) {
+		bool value = true;
+
+		for (t = i; t < 2 * i; t++)
+			value ^= d[t];
+
+		d[2 * i] = value;
+	}
+
+	for (t = 0; t < NETDEV_RSS_KEY_SPAN; t++)
+		netdev_rss_key_assign_bit(key, lsb + 31 - t, d[t]);
+}
+
+/* The 32 key bits starting at @bit, which is what input bit @bit contributes
+ * to the hash. @bit + 32 must fit in the key.
+ */
+static u32 netdev_rss_key_window(const u8 *key, unsigned int bit)
+{
+	unsigned int byte = bit / BITS_PER_BYTE;
+	unsigned int shift = bit % BITS_PER_BYTE;
+	u32 window = get_unaligned_be32(key + byte);
+
+	if (shift)
+		window = (window << shift) |
+			 (key[byte + 4] >> (BITS_PER_BYTE - shift));
+
+	return window;
+}
+
+/* Two input bits contributing the same window are indistinguishable to the
+ * hash, since flipping both of them leaves it unchanged. For a uniformly
+ * random key that is a 2 ** -32 event per pair of positions, but the fixup
+ * makes it likelier: it derives 8 of every 16 bits from the 8 others, so a
+ * 16-bit aligned word only takes 2 ** 8 values and two windows a whole
+ * number of words apart collide with probability 2 ** -16 instead. Half a
+ * word apart is less affected but still well clear of the random odds, so
+ * cover every distance that is a multiple of 8. What is left after that is
+ * below what a plain random key gives.
+ *
+ * Two windows at a distance that is a multiple of 8 are two windows at the
+ * same offset modulo 8. Caching a whole class would put 253 u32 on the
+ * stack, so cache one class modulo 16 and stream the class 8 bits above it
+ * against it.
+ */
+static bool netdev_rss_key_aliases(const u8 *key, unsigned int bits)
+{
+	u32 windows[NETDEV_RSS_KEY_LEN * BITS_PER_BYTE / 16];
+	unsigned int i, j, n, r;
+
+	for (r = 0; r < 16; r++) {
+		n = 0;
+		for (i = r; i + 32 <= bits; i += 16)
+			windows[n++] = netdev_rss_key_window(key, i);
+
+		for (i = 0; i < n; i++)
+			for (j = i + 1; j < n; j++)
+				if (windows[i] == windows[j])
+					return true;
+
+		if (r >= 8)
+			continue;
+
+		for (i = r + 8; i + 32 <= bits; i += 16) {
+			u32 window = netdev_rss_key_window(key, i);
+
+			for (j = 0; j < n; j++)
+				if (windows[j] == window)
+					return true;
+		}
+	}
+
+	return false;
+}
+
+VISIBLE_IF_KUNIT void netdev_rss_key_init(u8 *key, size_t len)
+{
+	unsigned int lsb, bits = len * BITS_PER_BYTE;
+
+	/* Four keys out of five come out of the fixup free of aliases, so
+	 * drawing another one is both simpler and cheaper than repairing.
+	 */
+	do {
+		get_random_bytes(key, len);
+
+		/* A field ending at bit @lsb uses key bits [.. , @lsb + 31],
+		 * so stop as soon as a 32-bit window no longer fits in the
+		 * key.
+		 */
+		for (lsb = 15; lsb + 32 <= bits; lsb += 16)
+			netdev_rss_key_fixup_field(key, lsb);
+	} while (netdev_rss_key_aliases(key, bits));
+
+	if (key != netdev_rss_key)
+		return;
+
+	/* Pair with smp_rmb() in proc_do_rss_key(). */
+	smp_wmb();
+	WRITE_ONCE(netdev_rss_key_initialized, true);
+}
+EXPORT_SYMBOL_IF_KUNIT(netdev_rss_key_init);
 
 void netdev_rss_key_fill(void *buffer, size_t len)
 {
 	BUG_ON(len > sizeof(netdev_rss_key));
-	net_get_random_once(netdev_rss_key, sizeof(netdev_rss_key));
+	DO_ONCE(netdev_rss_key_init, netdev_rss_key, sizeof(netdev_rss_key));
 	memcpy(buffer, netdev_rss_key, len);
 }
 EXPORT_SYMBOL(netdev_rss_key_fill);
diff --git a/net/ethtool/rss_key_test.c b/net/ethtool/rss_key_test.c
new file mode 100644
index 0000000000000..1a583f2930c5b
--- /dev/null
+++ b/net/ethtool/rss_key_test.c
@@ -0,0 +1,314 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Tests for the RSS key generated by netdev_rss_key_fill().
+ *
+ * The property under test is that flows differing only in the low order bits
+ * of one hashed header field land on distinct RX queues. It is checked here
+ * from the definition of the Toeplitz hash, independently of the way
+ * netdev_rss_key_init() achieves it.
+ */
+
+#include <kunit/test.h>
+#include <linux/module.h>
+#include <linux/random.h>
+#include <linux/sort.h>
+
+#include "common.h"
+
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+
+/* Longest hash input exercised here: an IPv6 header, a UDP header, a PSP
+ * header and the inner TCP ports. See rss_key_test_fields[].
+ */
+#define RSS_KEY_TEST_INPUT_LEN		68
+
+#define RSS_KEY_TEST_KEYS		32
+
+/* Number of queue counts exercised end to end by rss_key_spread_test(), which
+ * hashes 2 ** q inputs for each of them. The algebraic check covers all the
+ * queue counts up to NETDEV_RSS_KEY_QMAX.
+ */
+#define RSS_KEY_TEST_SPREAD_QMAX	6
+
+/* Position of the least significant bit of each field, counting from the most
+ * significant bit of the hash input, and the length of that input. These come
+ * from the definition of the hash, not from the key generator.
+ */
+static const struct rss_key_test_field {
+	const char	*name;
+	unsigned int	lsb;
+	unsigned int	nbits;
+} rss_key_test_fields[] = {
+	{ "IPv4 saddr",		31,	96 },
+	{ "IPv4 daddr",		63,	96 },
+	{ "IPv4 sport",		79,	96 },
+	{ "IPv4 dport",		95,	96 },
+	{ "IPv6 saddr",		127,	288 },
+	{ "IPv6 daddr",		255,	288 },
+	{ "IPv6 sport",		271,	288 },
+	{ "IPv6 dport",		287,	288 },
+	/* Hardware is free to hash an encapsulated header instead, and then
+	 * it reads the key far past the 40 bytes an IPv6 4-tuple needs. These
+	 * offsets are those of PSP transport mode over UDP over IPv6
+	 * (Documentation/networking/psp.rst): 40 bytes of IPv6, 8 of UDP,
+	 * PSP_HDR_SIZE of PSP, then the inner TCP ports. Prepending an
+	 * Ethernet header, or the 4 extra bytes of an encapsulation tag,
+	 * shifts all of this by a whole number of 16-bit units.
+	 */
+	{ "PSP outer IPv6 saddr",	191,	544 },
+	{ "PSP outer IPv6 daddr",	319,	544 },
+	{ "PSP inner sport",		527,	544 },
+	{ "PSP inner dport",		543,	544 },
+};
+
+static bool rss_key_test_bit(const u8 *buf, unsigned int bit)
+{
+	return buf[bit / BITS_PER_BYTE] & (0x80 >> (bit % BITS_PER_BYTE));
+}
+
+static void rss_key_test_assign_bit(u8 *buf, unsigned int bit, bool value)
+{
+	u8 mask = 0x80 >> (bit % BITS_PER_BYTE);
+
+	if (value)
+		buf[bit / BITS_PER_BYTE] |= mask;
+	else
+		buf[bit / BITS_PER_BYTE] &= ~mask;
+}
+
+/* The 32 key bits starting at @bit, which is what input bit @bit contributes
+ * to the hash.
+ */
+static u32 rss_key_test_window(const u8 *key, unsigned int bit)
+{
+	u32 window = 0;
+	unsigned int i;
+
+	for (i = 0; i < 32; i++)
+		window = (window << 1) | rss_key_test_bit(key, bit + i);
+
+	return window;
+}
+
+static u32 rss_key_test_toeplitz(const u8 *key, const u8 *input,
+				 unsigned int nbits)
+{
+	u32 hash = 0;
+	unsigned int i;
+
+	for (i = 0; i < nbits; i++)
+		if (rss_key_test_bit(input, i))
+			hash ^= rss_key_test_window(key, i);
+
+	return hash;
+}
+
+/* Is the map from the q low order bits of the field at @lsb to the q low order
+ * bits of the hash a bijection? Gaussian elimination over GF(2) on the q
+ * windows involved, reduced to their q low order bits.
+ */
+static bool rss_key_test_full_rank(const u8 *key, unsigned int lsb,
+				   unsigned int q)
+{
+	u32 basis[NETDEV_RSS_KEY_QMAX] = {};
+	unsigned int j;
+
+	for (j = 0; j < q; j++) {
+		u32 v = rss_key_test_window(key, lsb - j) & (BIT(q) - 1);
+
+		while (v) {
+			unsigned int b = __ffs(v);
+
+			if (!basis[b]) {
+				basis[b] = v;
+				break;
+			}
+			v ^= basis[b];
+		}
+
+		if (!v)
+			return false;
+	}
+
+	return true;
+}
+
+/* Degenerate keys the rank check must reject, so that a check accepting
+ * everything can not make the other tests pass.
+ */
+static void rss_key_checker_test(struct kunit *test)
+{
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+
+	KUNIT_ASSERT_NOT_NULL(test, key);
+
+	/* All the windows are zero. */
+	KUNIT_EXPECT_FALSE(test, rss_key_test_full_rank(key, 31, 1));
+
+	/* All the windows are equal, which is enough for one queue only. */
+	memset(key, 0xff, NETDEV_RSS_KEY_LEN);
+	KUNIT_EXPECT_TRUE(test, rss_key_test_full_rank(key, 31, 1));
+	KUNIT_EXPECT_FALSE(test, rss_key_test_full_rank(key, 31, 2));
+}
+
+static void rss_key_property_test(struct kunit *test)
+{
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+	unsigned int i, j, q;
+
+	KUNIT_ASSERT_NOT_NULL(test, key);
+
+	for (i = 0; i < RSS_KEY_TEST_KEYS; i++) {
+		netdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);
+
+		for (j = 0; j < ARRAY_SIZE(rss_key_test_fields); j++) {
+			const struct rss_key_test_field *f;
+
+			f = &rss_key_test_fields[j];
+
+			for (q = 1; q <= NETDEV_RSS_KEY_QMAX; q++)
+				KUNIT_ASSERT_TRUE_MSG(test,
+						      rss_key_test_full_rank(key, f->lsb, q),
+						      "%s does not spread over %u queues",
+						      f->name, 1U << q);
+		}
+	}
+}
+
+/* rss_key_test_fields[] can only list the layouts somebody thought of, but
+ * the generator does not get to know what the hardware hashes. Sweep the
+ * whole key instead: the property has to hold at every 16-bit aligned
+ * position, which is where a field of any layout can end.
+ */
+static void rss_key_grid_test(struct kunit *test)
+{
+	unsigned int bits = NETDEV_RSS_KEY_LEN * BITS_PER_BYTE;
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+	unsigned int i, lsb, q;
+
+	KUNIT_ASSERT_NOT_NULL(test, key);
+
+	for (i = 0; i < RSS_KEY_TEST_KEYS; i++) {
+		netdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);
+
+		for (lsb = 15; lsb + 32 <= bits; lsb += 16)
+			for (q = 1; q <= NETDEV_RSS_KEY_QMAX; q++)
+				KUNIT_ASSERT_TRUE_MSG(test,
+						      rss_key_test_full_rank(key, lsb, q),
+						      "field ending at bit %u does not spread over %u queues",
+						      lsb, 1U << q);
+	}
+}
+
+static int rss_key_test_cmp(const void *a, const void *b)
+{
+	u32 x = *(const u32 *)a, y = *(const u32 *)b;
+
+	return x < y ? -1 : x > y;
+}
+
+/* Two input bits contributing the same 32-bit window are indistinguishable
+ * to the hash: flipping both of them leaves it unchanged, so the flows of a
+ * burst differing in exactly those two bits all collide. A uniformly random
+ * key has such a pair with probability 2 ** -11, and the generated key must
+ * not do worse.
+ *
+ * netdev_rss_key_init() redraws on a collision at a distance that is a
+ * multiple of 8, which is where the fixup makes one likely, and leaves every
+ * other distance at the odds of a random key. So assert on what it
+ * guarantees: group the windows by their offset modulo 8 and sort each group
+ * on its own. Sorting all of them together instead would be asserting on the
+ * random odds, and would fail about one run in 26 on a correct kernel.
+ */
+static void rss_key_alias_test(struct kunit *test)
+{
+	unsigned int count = NETDEV_RSS_KEY_LEN * BITS_PER_BYTE - 31;
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+	unsigned int i, j, n, r;
+	u32 *windows;
+
+	windows = kunit_kcalloc(test, count, sizeof(*windows), GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, key);
+	KUNIT_ASSERT_NOT_NULL(test, windows);
+
+	for (i = 0; i < RSS_KEY_TEST_KEYS; i++) {
+		netdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);
+
+		for (r = 0; r < 8; r++) {
+			n = 0;
+			for (j = r; j < count; j += 8)
+				windows[n++] = rss_key_test_window(key, j);
+
+			sort(windows, n, sizeof(*windows),
+			     rss_key_test_cmp, NULL);
+
+			for (j = 1; j < n; j++)
+				KUNIT_ASSERT_NE_MSG(test, windows[j],
+						    windows[j - 1],
+						    "two input bits a multiple of 8 apart read the same key window %08x",
+						    windows[j]);
+		}
+	}
+}
+
+/* Hash the inputs of a burst differing only in the low order bits of one
+ * field, and check that they fill the indirection table evenly.
+ */
+static void rss_key_spread_test(struct kunit *test)
+{
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+	u8 *input = kunit_kzalloc(test, RSS_KEY_TEST_INPUT_LEN, GFP_KERNEL);
+	unsigned int i, j, q;
+
+	KUNIT_ASSERT_NOT_NULL(test, key);
+	KUNIT_ASSERT_NOT_NULL(test, input);
+
+	netdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);
+
+	for (i = 0; i < ARRAY_SIZE(rss_key_test_fields); i++) {
+		const struct rss_key_test_field *f = &rss_key_test_fields[i];
+
+		for (q = 1; q <= RSS_KEY_TEST_SPREAD_QMAX; q++) {
+			u64 seen = 0;
+
+			get_random_bytes(input, RSS_KEY_TEST_INPUT_LEN);
+
+			for (j = 0; j < (1U << q); j++) {
+				unsigned int t, queue;
+				u32 hash;
+
+				for (t = 0; t < q; t++)
+					rss_key_test_assign_bit(input,
+								f->lsb - t,
+								j & BIT(t));
+
+				hash = rss_key_test_toeplitz(key, input,
+							     f->nbits);
+				queue = hash & (BIT(q) - 1);
+
+				KUNIT_ASSERT_FALSE_MSG(test, seen & BIT_ULL(queue),
+						       "%s hits queue %u twice out of %u",
+						       f->name, queue, 1U << q);
+				seen |= BIT_ULL(queue);
+			}
+		}
+	}
+}
+
+static struct kunit_case rss_key_test_cases[] = {
+	KUNIT_CASE(rss_key_checker_test),
+	KUNIT_CASE(rss_key_property_test),
+	KUNIT_CASE(rss_key_grid_test),
+	KUNIT_CASE(rss_key_alias_test),
+	KUNIT_CASE(rss_key_spread_test),
+	{},
+};
+
+static struct kunit_suite rss_key_test_suite = {
+	.name = "ethtool-rss-key",
+	.test_cases = rss_key_test_cases,
+};
+
+kunit_test_suite(rss_key_test_suite);
+
+MODULE_DESCRIPTION("Tests for the RSS key generated by netdev_rss_key_fill()");
+MODULE_LICENSE("GPL");
diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile
index 8aebdc6feb177..9bcf3c1e8caa2 100644
--- a/tools/testing/selftests/drivers/net/hw/Makefile
+++ b/tools/testing/selftests/drivers/net/hw/Makefile
@@ -46,6 +46,7 @@ TEST_PROGS = \
 	rss_drv.py \
 	rss_flow_label.py \
 	rss_input_xfrm.py \
+	rss_key.py \
 	toeplitz.py \
 	tso.py \
 	userns_devmem.py \
diff --git a/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py b/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py
index 81e1d1865cd50..96edd9dfe9e3b 100644
--- a/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py
+++ b/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py
@@ -26,6 +26,8 @@ try:
         fd_read_timeout, ip, rand_port, rand_ports, wait_port_listen, \
         wait_file, ctl_file_write, tool
     from net.lib.py import bpf_map_set, bpf_map_dump, bpf_prog_map_ids
+    from net.lib.py import RSS_KEY_QMAX, rss_key_bit, rss_key_assign_bit, \
+        rss_key_window, rss_key_toeplitz, rss_key_full_rank, rss_key_layout
     from net.lib.py import KsftSkipEx, KsftFailEx, KsftXfailEx
     from net.lib.py import ksft_disruptive, ksft_exit, ksft_pr, ksft_run, \
         ksft_setup, ksft_variants, KsftNamedVariant
@@ -42,6 +44,9 @@ try:
                "fd_read_timeout", "ip", "rand_port", "rand_ports",
                "wait_port_listen", "wait_file", "ctl_file_write", "tool",
                "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids",
+               "RSS_KEY_QMAX", "rss_key_bit", "rss_key_assign_bit",
+               "rss_key_window", "rss_key_toeplitz", "rss_key_full_rank",
+               "rss_key_layout",
                "KsftSkipEx", "KsftFailEx", "KsftXfailEx",
                "ksft_disruptive", "ksft_exit", "ksft_pr", "ksft_run",
                "ksft_setup", "ksft_variants", "KsftNamedVariant",
diff --git a/tools/testing/selftests/drivers/net/hw/rss_key.py b/tools/testing/selftests/drivers/net/hw/rss_key.py
new file mode 100755
index 0000000000000..dc7095f6663cd
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/hw/rss_key.py
@@ -0,0 +1,172 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""
+Check that the RSS key a device actually uses spreads flows over all of the
+entries of its indirection table.
+
+Most drivers take their key from netdev_rss_key_fill(), which generates keys
+having that property, but some bring their own and firmware sometimes
+installs one of its own. This reads back the key the device reports, so it
+covers wherever the key came from. See net/lib/py/rsskey.py for what the
+property is and why a random key is not good enough.
+"""
+
+import random
+
+from lib.py import ksft_run, ksft_exit, ksft_pr
+from lib.py import ksft_eq
+from lib.py import KsftSkipEx
+from lib.py import NetDrvEnv, EthtoolFamily, cmd
+from lib.py import RSS_KEY_QMAX, rss_key_assign_bit, rss_key_toeplitz, \
+    rss_key_full_rank, rss_key_layout
+
+# "define" for the ID of the Toeplitz hash function
+ETH_RSS_HASH_TOP = 1
+
+FLOW_TYPES = ("tcp4", "udp4", "tcp6", "udp6")
+
+# How ethtool -n spells the fields of the hash input.
+FIELD_NAMES = {
+    "IP SA": "s",
+    "IP DA": "d",
+    "L3 proto": "t",
+    "L4 bytes 0 & 1 [TCP/UDP src port]": "f",
+    "L4 bytes 2 & 3 [TCP/UDP dst port]": "n",
+    "IPv6 Flow Label": "l",
+}
+
+
+def _get_rss(cfg):
+    """The key and indirection table of @cfg's device, or a skip."""
+    rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}})
+
+    hkey = rss.get("hkey")
+    if not hkey or not any(hkey):
+        raise KsftSkipEx(f"{cfg.ifname} does not report an RSS key")
+
+    if rss.get("hfunc") != ETH_RSS_HASH_TOP:
+        raise KsftSkipEx(f"{cfg.ifname} does not use the Toeplitz hash")
+
+    if rss.get("input-xfrm"):
+        raise KsftSkipEx(f"{cfg.ifname} transforms the hash input")
+
+    indir = rss.get("indir")
+    if not indir:
+        raise KsftSkipEx(f"{cfg.ifname} does not report an indirection table")
+
+    if len(indir) & (len(indir) - 1):
+        raise KsftSkipEx(f"{cfg.ifname} has {len(indir)} indirection table "
+                         "entries, which is not a power of two")
+
+    return bytes(hkey), indir
+
+
+def _get_layouts(cfg):
+    """The hash input layouts in use, mapped to the flow types sharing them."""
+    layouts = {}
+
+    for fl_type in FLOW_TYPES:
+        proc = cmd(f"ethtool -n {cfg.ifname} rx-flow-hash {fl_type}",
+                   fail=False)
+        if proc.ret:
+            continue
+
+        fields = ""
+        for line in proc.stdout.split("\n")[1:-2]:
+            # if this raises we probably need to add more keys to FIELD_NAMES
+            fields += FIELD_NAMES[line]
+
+        layout, nbits = rss_key_layout(fields, fl_type.endswith("6"))
+        if layout is None:
+            ksft_pr(f"{fl_type}: not checked, hashes fields we can not place "
+                    f"({fields})")
+            continue
+
+        layouts.setdefault((tuple(layout), nbits), []).append(fl_type)
+
+    if not layouts:
+        raise KsftSkipEx("no flow type with a hash input we can describe")
+
+    return layouts
+
+
+def test_rss_key_rank(cfg) -> None:
+    """The key has to be non singular for the size of the table."""
+    hkey, indir = _get_rss(cfg)
+    q = min((len(indir) - 1).bit_length(), RSS_KEY_QMAX)
+    degenerate = []
+
+    if not q:
+        raise KsftSkipEx("the indirection table has a single entry")
+
+    for (layout, _), fl_types in _get_layouts(cfg).items():
+        for name, lsb in layout:
+            if lsb + 32 > len(hkey) * 8:
+                ksft_pr(f"{name}: not checked, the key is {len(hkey)} bytes")
+                continue
+
+            if not rss_key_full_rank(hkey, lsb, q):
+                degenerate.append(f"{'/'.join(fl_types)} {name}")
+
+    for bad in degenerate:
+        ksft_pr(f"degenerate: {bad}")
+
+    ksft_eq(len(degenerate), 0,
+            f"the key of {cfg.ifname} does not spread flows over the "
+            f"{1 << q} entries of its indirection table")
+
+
+def test_rss_key_spread(cfg) -> None:
+    """Hash bursts differing in one field only, and place them in the table."""
+    hkey, indir = _get_rss(cfg)
+    q = (len(indir) - 1).bit_length()
+    collisions = []
+
+    if q > RSS_KEY_QMAX:
+        raise KsftSkipEx(f"{len(indir)} indirection table entries is more "
+                         "than the kernel guarantees")
+    if not q:
+        raise KsftSkipEx("the indirection table has a single entry")
+
+    for (layout, nbits), fl_types in _get_layouts(cfg).items():
+        # Unlike the rank check, this hashes the whole input, so it reads
+        # the key up to 31 bits past its last bit rather than past the last
+        # bit of one field.
+        if nbits + 31 > len(hkey) * 8:
+            ksft_pr(f"{'/'.join(fl_types)}: not checked, the key is "
+                    f"{len(hkey)} bytes")
+            continue
+
+        for name, lsb in layout:
+            inp = bytearray(random.randbytes(nbits // 8))
+            entries = set()
+            for value in range(1 << q):
+                for bit in range(q):
+                    rss_key_assign_bit(inp, lsb - bit, value & (1 << bit))
+                hash_ = rss_key_toeplitz(hkey, inp, nbits)
+                entries.add(hash_ & (len(indir) - 1))
+
+            if len(entries) != 1 << q:
+                collisions.append(f"{'/'.join(fl_types)} {name} reaches "
+                                  f"{len(entries)} of the {1 << q} entries")
+
+    for bad in collisions:
+        ksft_pr(bad)
+
+    ksft_eq(len(collisions), 0,
+            f"flows differing in one field only do not fill the "
+            f"indirection table of {cfg.ifname}")
+
+
+def main() -> None:
+    """ Ksft boiler plate main """
+
+    with NetDrvEnv(__file__, nsim_test=False) as cfg:
+        cfg.ethnl = EthtoolFamily()
+        ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg, ))
+    ksft_exit()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 3ee3378f8b26e..cba6084914af5 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -67,6 +67,7 @@ TEST_PROGS := \
 	nat6to4.sh \
 	ndisc_unsolicited_na_test.sh \
 	netdev-l2addr.sh \
+	netdev_rss_key.py \
 	netdevice.sh \
 	netns-name.sh \
 	netns-sysctl.sh \
diff --git a/tools/testing/selftests/net/lib/py/__init__.py b/tools/testing/selftests/net/lib/py/__init__.py
index 71df5880b356a..7648ab6c2adae 100644
--- a/tools/testing/selftests/net/lib/py/__init__.py
+++ b/tools/testing/selftests/net/lib/py/__init__.py
@@ -16,6 +16,8 @@ from .utils import CmdExitFailure, fd_read_timeout, cmd, bkg, defer, \
     bpftool, ip, ethtool, bpftrace, rand_port, rand_ports, wait_port_listen, \
     ctl_file_write, wait_file, tool, tc
 from .bpf import bpf_map_set, bpf_map_dump, bpf_prog_map_ids
+from .rsskey import RSS_KEY_QMAX, rss_key_bit, rss_key_assign_bit, \
+    rss_key_window, rss_key_toeplitz, rss_key_full_rank, rss_key_layout
 from .ynl import NlError, NlctrlFamily, YnlFamily, \
     EthtoolFamily, NetdevFamily, RtnlFamily, RtnlAddrFamily, RtnlRouteFamily
 from .ynl import NetshaperFamily, DevlinkFamily, PSPFamily, Netlink
@@ -31,6 +33,9 @@ __all__ = ["KSRC",
            "bpftool", "ip", "ethtool", "bpftrace", "rand_port", "rand_ports",
            "wait_port_listen", "ctl_file_write", "wait_file", "tool", "tc",
            "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids",
+           "RSS_KEY_QMAX", "rss_key_bit", "rss_key_assign_bit",
+           "rss_key_window", "rss_key_toeplitz", "rss_key_full_rank",
+           "rss_key_layout",
            "NetdevSim", "NetdevSimDev",
            "NetshaperFamily", "DevlinkFamily", "PSPFamily", "NlError",
            "YnlFamily", "EthtoolFamily", "NetdevFamily", "RtnlFamily",
diff --git a/tools/testing/selftests/net/lib/py/rsskey.py b/tools/testing/selftests/net/lib/py/rsskey.py
new file mode 100644
index 0000000000000..4451eb80fb457
--- /dev/null
+++ b/tools/testing/selftests/net/lib/py/rsskey.py
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: GPL-2.0
+
+"""
+Helpers to check the quality of an RSS key.
+
+The Toeplitz hash is linear over GF(2): the hash is the XOR of the 32 bit key
+windows selected by the set bits of the input, and hardware indexes the
+indirection table with the low order bits of the hash. The windows belonging
+to the q lowest bits of a header field therefore form a Toeplitz matrix, and
+when that matrix is singular the flows of a burst differing only in those
+bits, consecutive ephemeral ports typically, can not reach all of the 2 ** q
+entries of the table. A key drawn uniformly at random is singular for a given
+field and a given q with probability 1/2.
+
+netdev_rss_key_fill() generates keys that are non singular for every field of
+the hash input and every q up to RSS_KEY_QMAX.
+"""
+
+# Matches NETDEV_RSS_KEY_QMAX, that is up to 256 entries of the table.
+RSS_KEY_QMAX = 8
+
+
+def rss_key_bit(buf, bit):
+    """Bit @bit of @buf, counting from the most significant bit of byte 0."""
+    return (buf[bit // 8] >> (7 - bit % 8)) & 1
+
+
+def rss_key_assign_bit(buf, bit, value):
+    mask = 0x80 >> (bit % 8)
+
+    if value:
+        buf[bit // 8] |= mask
+    else:
+        buf[bit // 8] &= ~mask
+
+
+def rss_key_window(key, bit):
+    """The 32 key bits starting at @bit, what input bit @bit contributes."""
+    value = 0
+
+    for i in range(32):
+        value = (value << 1) | rss_key_bit(key, bit + i)
+
+    return value
+
+
+def rss_key_toeplitz(key, inp, nbits):
+    """The Toeplitz hash of the @nbits long input @inp under @key."""
+    value = 0
+
+    for i in range(nbits):
+        if rss_key_bit(inp, i):
+            value ^= rss_key_window(key, i)
+
+    return value
+
+
+def rss_key_full_rank(key, lsb, q):
+    """Do the q low order bits of the field at @lsb reach all 2 ** q entries?
+
+    Gaussian elimination over GF(2) on the q windows involved, reduced to
+    their q low order bits, which are the ones indexing the table.
+    """
+    basis = {}
+
+    for j in range(q):
+        vector = rss_key_window(key, lsb - j) & ((1 << q) - 1)
+
+        while vector:
+            low = vector & -vector
+            if low not in basis:
+                basis[low] = vector
+                break
+            vector ^= basis[low]
+
+        if not vector:
+            return False
+
+    return True
+
+
+def rss_key_layout(fields, ipv6):
+    """Describe the hash input built from @fields, as ethtool -n reports it.
+
+    @fields is the flow hash configuration, "sdfn" for a 4-tuple or "sd" for
+    a 2-tuple. Returns the list of (name, position of the least significant
+    bit) and the length of the input in bits, or None if the layout involves
+    something this does not know how to place.
+    """
+    addr_bits = 128 if ipv6 else 32
+    known = (("s", "saddr", addr_bits),
+             ("d", "daddr", addr_bits),
+             ("f", "sport", 16),
+             ("n", "dport", 16))
+
+    if set(fields) - {flag for flag, _, _ in known}:
+        return None, 0
+
+    layout = []
+    nbits = 0
+
+    for flag, name, width in known:
+        if flag not in fields:
+            continue
+        nbits += width
+        layout.append((name, nbits - 1))
+
+    return layout, nbits
diff --git a/tools/testing/selftests/net/netdev_rss_key.py b/tools/testing/selftests/net/netdev_rss_key.py
new file mode 100755
index 0000000000000..37be2ebea6f7c
--- /dev/null
+++ b/tools/testing/selftests/net/netdev_rss_key.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""
+Check the quality of the host RSS key, /proc/sys/net/core/netdev_rss_key.
+
+This is the key netdev_rss_key_fill() hands to the drivers. It has to be non
+singular for every field of the hash input and every queue count up to
+2 ** RSS_KEY_QMAX, see lib/py/rsskey.py for what that means and why it
+matters. Unlike the KUnit tests of the generator, this checks the key the
+running kernel has actually handed out.
+
+The key is generated lazily, the first time a driver asks for it, so this
+test skips until a driver has done so. Any NIC calling netdev_rss_key_fill()
+is enough; in a virtual machine, virtio_net does it from
+virtnet_init_default_rss() once RSS has been negotiated.
+
+Checking what a given NIC really uses is a different question, since a
+driver may bring its own key. See drivers/net/hw/rss_key.py for that.
+"""
+
+from lib.py import ksft_run, ksft_exit, ksft_pr
+from lib.py import ksft_eq, ksft_ge
+from lib.py import KsftSkipEx
+from lib.py import RSS_KEY_QMAX, rss_key_full_rank, rss_key_layout
+
+KEY_PATH = "/proc/sys/net/core/netdev_rss_key"
+
+# Shortest key able to hash an IPv6 4-tuple.
+MIN_KEY_LEN = 40
+
+
+def _read_key():
+    """Return the host RSS key, skipping if it has not been generated."""
+    try:
+        with open(KEY_PATH, "r", encoding="ascii") as fp:
+            text = fp.read().strip()
+    except FileNotFoundError as exc:
+        raise KsftSkipEx(f"{KEY_PATH} is not available") from exc
+
+    key = bytes(int(byte, 16) for byte in text.split(":"))
+
+    if not any(key):
+        raise KsftSkipEx("the host RSS key has not been generated yet, "
+                         "no driver has called netdev_rss_key_fill()")
+
+    return key
+
+
+def check_length() -> None:
+    key = _read_key()
+
+    ksft_pr(f"host RSS key is {len(key)} bytes")
+    ksft_ge(len(key), MIN_KEY_LEN, "key too short to hash an IPv6 4-tuple")
+
+
+def check_spread() -> None:
+    key = _read_key()
+    degenerate = []
+
+    for ipv6 in (False, True):
+        layout, _ = rss_key_layout("sdfn", ipv6)
+        family = "IPv6" if ipv6 else "IPv4"
+
+        for name, lsb in layout:
+            if lsb + 32 > len(key) * 8:
+                continue
+
+            for q in range(1, RSS_KEY_QMAX + 1):
+                if not rss_key_full_rank(key, lsb, q):
+                    degenerate.append(f"{family} {name} over {1 << q} queues")
+
+    for bad in degenerate:
+        ksft_pr(f"degenerate: {bad}")
+
+    ksft_eq(len(degenerate), 0,
+            "the host RSS key does not spread flows over all the queues")
+
+
+def check_grid() -> None:
+    """Sweep the whole key, not only the fields of the usual layouts.
+
+    netdev_rss_key_fill() does not get to know what the hardware hashes, so
+    it gives the property at every 16-bit aligned position of the key. A NIC
+    hashing an encapsulated header reads the key well past the first 40
+    bytes, and has to find the same guarantee there.
+    """
+    key = _read_key()
+    bits = len(key) * 8
+    positions = 0
+    degenerate = []
+
+    for lsb in range(15, bits - 31, 16):
+        positions += 1
+
+        for q in range(1, RSS_KEY_QMAX + 1):
+            if not rss_key_full_rank(key, lsb, q):
+                degenerate.append(f"field ending at bit {lsb} "
+                                  f"over {1 << q} queues")
+
+    ksft_pr(f"checked {positions} positions of the {len(key)} byte key")
+
+    for bad in degenerate[:8]:
+        ksft_pr(f"degenerate: {bad}")
+
+    ksft_eq(len(degenerate), 0,
+            "the host RSS key does not spread flows over all the queues "
+            "at every 16-bit aligned position")
+
+
+def main() -> None:
+    ksft_run(globs=globals(), case_pfx={"check_"})
+    ksft_exit()
+
+
+if __name__ == "__main__":
+    main()

3/2 2026/09/23 18:08 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 17288
							output: 22
							thoughts: 644
						

Thoughts:
**Fuzzing Evaluation: RSS Key Initialization Patch**

Okay, let's break this down. The request is straightforward: determine if this patch warrants syzkaller fuzzing. My immediate thought is to examine the changes closely.

First, let's look at the modified files. We have changes across documentation, Kconfig, `dev.h`, `sysctl_net_core.c`, ethtool, and tools. This suggests a potentially broad impact, making fuzzing more interesting. The presence of `tools/...` also makes me perk up; modifications in tools can expose interesting interactions.

Focusing on the executable kernel code, specifically `net/core/sysctl_net_core.c`, the key change in `proc_do_rss_key` looks like it is accessing the `netdev_rss_key` differently. The introduction of `initialized` and the `smp_rmb()` and `READ_ONCE()` calls is noteworthy, especially the conditional read based on an initialization flag. This raises the possibility of race conditions or initialization issues, making it a potential fuzzing target.

Now, looking deeper at `net/ethtool/ioctl.c`, the addition of numerous functions related to `netdev_rss_key` is significant. The introduction of `netdev_rss_key_initialized`, `netdev_rss_key_bit()`, `netdev_rss_key_assign_bit()`, `netdev_rss_key_fixup_field()`, `netdev_rss_key_window()`, `netdev_rss_key_aliases()`, and `netdev_rss_key_init()` are all new surface areas. The change in `netdev_rss_key_fill`, specifically the switch from `net_get_random_once` to `DO_ONCE`, is also interesting. It's moving from generating random keys at runtime to a more deterministic initialization process. This change by itself is not something to immediately fuzz, but the overall change set is beginning to show some potential.

However, the real question that pops up in my head is: where is `netdev_rss_key_fill` being called? If it is rarely called, it's not a strong candidate for fuzzing. If it is called from many places, it's very attractive. Let's find out... I will use `grepper` to determine the call sites for further analysis.



4/2 2026/09/23 18:08 tool grepper
0m Args:
{
  "Expression": "netdev_rss_key_fill"
}

Results:
{
  "Output": "Documentation/admin-guide/sysctl/net.rst=319=provide ethtool -x support yet.\n--\nDocumentation/admin-guide/sysctl/net.rst-325-\nDocumentation/admin-guide/sysctl/net.rst:326:File contains all nul bytes if no driver ever called netdev_rss_key_fill()\nDocumentation/admin-guide/sysctl/net.rst-327-function.\n--\nDocumentation/networking/scaling.rst=55=picking nearly consecutive ephemeral ports then lands on a fraction of the\nDocumentation/networking/scaling.rst:56:queues while the others stay idle. The netdev_rss_key_fill() helper draws\nDocumentation/networking/scaling.rst-57-a random key that is free of this defect; drivers should use it rather\n--\ndrivers/infiniband/hw/mana/qp.c=8=static int mana_ib_cfg_vport_steering(struct mana_ib_dev *dev,\n--\ndrivers/infiniband/hw/mana/qp.c-67-\telse\ndrivers/infiniband/hw/mana/qp.c:68:\t\tnetdev_rss_key_fill(req-\u003ehashkey, MANA_HASH_KEY_SIZE);\ndrivers/infiniband/hw/mana/qp.c-69-\n--\ndrivers/net/ethernet/amazon/ena/ena_com.c=1046=static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev)\n--\ndrivers/net/ethernet/amazon/ena/ena_com.c-1050-\ndrivers/net/ethernet/amazon/ena/ena_com.c:1051:\tnetdev_rss_key_fill(\u0026hash_key-\u003ekey, sizeof(hash_key-\u003ekey));\ndrivers/net/ethernet/amazon/ena/ena_com.c-1052-\t/* The key buffer is stored in the device in an array of\n--\ndrivers/net/ethernet/amd/xgbe/xgbe-main.c=152=int xgbe_config_netdev(struct xgbe_prv_data *pdata)\n--\ndrivers/net/ethernet/amd/xgbe/xgbe-main.c-214-\t/* Initialize RSS hash key */\ndrivers/net/ethernet/amd/xgbe/xgbe-main.c:215:\tnetdev_rss_key_fill(pdata-\u003erss_key, sizeof(pdata-\u003erss_key));\ndrivers/net/ethernet/amd/xgbe/xgbe-main.c-216-\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c=2080=int bnx2x_rss(struct bnx2x *bp, struct bnx2x_rss_config_obj *rss_obj,\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c-2127-\t\t/* RSS keys */\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c:2128:\t\tnetdev_rss_key_fill(params.rss_key, T_ETH_RSS_KEY * 4);\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c-2129-\t\t__set_bit(BNX2X_RSS_SET_SRCH, \u0026params.rss_flags);\n--\ndrivers/net/ethernet/broadcom/tg3.c=9944=static int tg3_reset_hw(struct tg3 *tp, bool reset_phy)\n--\ndrivers/net/ethernet/broadcom/tg3.c-10689-\ndrivers/net/ethernet/broadcom/tg3.c:10690:\t\tnetdev_rss_key_fill(rss_key, 10 * sizeof(u32));\ndrivers/net/ethernet/broadcom/tg3.c-10691-\n--\ndrivers/net/ethernet/brocade/bna/bnad.c=2027=bnad_init_rx_config(struct bnad *bnad, struct bna_rx_config *rx_config)\n--\ndrivers/net/ethernet/brocade/bna/bnad.c-2042-\t\t\t\tbnad-\u003enum_rxp_per_rx - 1;\ndrivers/net/ethernet/brocade/bna/bnad.c:2043:\t\tnetdev_rss_key_fill(rx_config-\u003erss_config.toeplitz_hash_key,\ndrivers/net/ethernet/brocade/bna/bnad.c-2044-\t\t\tsizeof(rx_config-\u003erss_config.toeplitz_hash_key));\n--\ndrivers/net/ethernet/cavium/thunder/nicvf_main.c=370=static int nicvf_rss_init(struct nicvf *nic)\n--\ndrivers/net/ethernet/cavium/thunder/nicvf_main.c-384-\ndrivers/net/ethernet/cavium/thunder/nicvf_main.c:385:\tnetdev_rss_key_fill(rss-\u003ekey, RSS_HASH_KEY_SIZE * sizeof(u64));\ndrivers/net/ethernet/cavium/thunder/nicvf_main.c-386-\tnicvf_set_rss_key(nic);\n--\ndrivers/net/ethernet/cisco/enic/enic_main.c=2087=static int enic_set_rsskey(struct enic *enic)\ndrivers/net/ethernet/cisco/enic/enic_main.c-2088-{\ndrivers/net/ethernet/cisco/enic/enic_main.c:2089:\tnetdev_rss_key_fill(enic-\u003erss_key, ENIC_RSS_LEN);\ndrivers/net/ethernet/cisco/enic/enic_main.c-2090-\n--\ndrivers/net/ethernet/emulex/benet/be_main.c=3685=static int be_rx_qs_create(struct be_adapter *adapter)\n--\ndrivers/net/ethernet/emulex/benet/be_main.c-3731-\ndrivers/net/ethernet/emulex/benet/be_main.c:3732:\t\tnetdev_rss_key_fill(rss_key, RSS_HASH_KEY_LEN);\ndrivers/net/ethernet/emulex/benet/be_main.c-3733-\t\trc = be_cmd_rss_config(adapter, rss-\u003ersstable, rss-\u003erss_flags,\n--\ndrivers/net/ethernet/fungible/funeth/funeth_main.c=1420=static int fun_init_rss(struct net_device *dev)\n--\ndrivers/net/ethernet/fungible/funeth/funeth_main.c-1434-\tfp-\u003ehash_algo = FUN_ETH_RSS_ALG_TOEPLITZ;\ndrivers/net/ethernet/fungible/funeth/funeth_main.c:1435:\tnetdev_rss_key_fill(fp-\u003erss_key, sizeof(fp-\u003erss_key));\ndrivers/net/ethernet/fungible/funeth/funeth_main.c-1436-\tfun_reset_rss_indir(dev, dev-\u003ereal_num_rx_queues);\n--\ndrivers/net/ethernet/google/gve/gve_main.c=1825=int gve_init_rss_config(struct gve_priv *priv, u16 num_queues)\n--\ndrivers/net/ethernet/google/gve/gve_main.c-1837-\ndrivers/net/ethernet/google/gve/gve_main.c:1838:\tnetdev_rss_key_fill(rss_config-\u003ehash_key, priv-\u003erss_key_size);\ndrivers/net/ethernet/google/gve/gve_main.c-1839-\n--\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c=299=static void hns_ppe_init_hw(struct hns_ppe_cb *ppe_cb)\n--\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c-306-\t/* get default RSS key */\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c:307:\tnetdev_rss_key_fill(ppe_cb-\u003erss_key, HNS_PPEV2_RSS_KEY_SIZE);\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c-308-\n--\ndrivers/net/ethernet/huawei/hinic/hinic_main.c=304=static int hinic_rss_init(struct hinic_dev *nic_dev)\n--\ndrivers/net/ethernet/huawei/hinic/hinic_main.c-314-\ndrivers/net/ethernet/huawei/hinic/hinic_main.c:315:\tnetdev_rss_key_fill(default_rss_key, sizeof(default_rss_key));\ndrivers/net/ethernet/huawei/hinic/hinic_main.c-316-\tfor (i = 0; i \u003c HINIC_RSS_INDIR_SIZE; i++)\n--\ndrivers/net/ethernet/huawei/hinic3/hinic3_rss.c=72=static int alloc_rss_resource(struct net_device *netdev)\n--\ndrivers/net/ethernet/huawei/hinic3/hinic3_rss.c-81-\ndrivers/net/ethernet/huawei/hinic3/hinic3_rss.c:82:\tnetdev_rss_key_fill(nic_dev-\u003erss_hkey, L2NIC_RSS_KEY_SIZE);\ndrivers/net/ethernet/huawei/hinic3/hinic3_rss.c-83-\n--\ndrivers/net/ethernet/intel/e1000e/netdev.c=3455=static void e1000e_setup_rss_hash(struct e1000_adapter *adapter)\n--\ndrivers/net/ethernet/intel/e1000e/netdev.c-3461-\ndrivers/net/ethernet/intel/e1000e/netdev.c:3462:\tnetdev_rss_key_fill(rss_key, sizeof(rss_key));\ndrivers/net/ethernet/intel/e1000e/netdev.c-3463-\tfor (i = 0; i \u003c 10; i++)\n--\ndrivers/net/ethernet/intel/fm10k/fm10k_pci.c=1967=static int fm10k_sw_init(struct fm10k_intfc *interface,\n--\ndrivers/net/ethernet/intel/fm10k/fm10k_pci.c-2068-\ndrivers/net/ethernet/intel/fm10k/fm10k_pci.c:2069:\tnetdev_rss_key_fill(rss_key, sizeof(rss_key));\ndrivers/net/ethernet/intel/fm10k/fm10k_pci.c-2070-\tmemcpy(interface-\u003erssrk, rss_key, sizeof(rss_key));\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c=1901=static int i40e_vsi_config_rss(struct i40e_vsi *vsi)\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c-1928-\telse\ndrivers/net/ethernet/intel/i40e/i40e_main.c:1929:\t\tnetdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);\ndrivers/net/ethernet/intel/i40e/i40e_main.c-1930-\tret = i40e_config_rss_aq(vsi, seed, lut, vsi-\u003erss_table_size);\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c=6190=static int i40e_vsi_reconfig_rss(struct i40e_vsi *vsi, u16 rss_size)\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c-6218-\telse\ndrivers/net/ethernet/intel/i40e/i40e_main.c:6219:\t\tnetdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);\ndrivers/net/ethernet/intel/i40e/i40e_main.c-6220-\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c=12472=static int i40e_pf_config_rss(struct i40e_pf *pf)\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c-12527-\telse\ndrivers/net/ethernet/intel/i40e/i40e_main.c:12528:\t\tnetdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);\ndrivers/net/ethernet/intel/i40e/i40e_main.c-12529-\tret = i40e_config_rss(vsi, seed, lut, vsi-\u003erss_table_size);\n--\ndrivers/net/ethernet/intel/iavf/iavf_main.c=1738=static int iavf_init_rss(struct iavf_adapter *adapter)\n--\ndrivers/net/ethernet/intel/iavf/iavf_main.c-1755-\tiavf_fill_rss_lut(adapter);\ndrivers/net/ethernet/intel/iavf/iavf_main.c:1756:\tnetdev_rss_key_fill((void *)adapter-\u003erss_key, adapter-\u003erss_key_size);\ndrivers/net/ethernet/intel/iavf/iavf_main.c-1757-\n--\ndrivers/net/ethernet/intel/ice/ice_lib.c=1499=int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi)\n--\ndrivers/net/ethernet/intel/ice/ice_lib.c-1550-\telse\ndrivers/net/ethernet/intel/ice/ice_lib.c:1551:\t\tnetdev_rss_key_fill((void *)key, ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE);\ndrivers/net/ethernet/intel/ice/ice_lib.c-1552-\n--\ndrivers/net/ethernet/intel/idpf/idpf_lib.c=1246=static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,\n--\ndrivers/net/ethernet/intel/idpf/idpf_lib.c-1320-\t/* Initialize default RSS key */\ndrivers/net/ethernet/intel/idpf/idpf_lib.c:1321:\tnetdev_rss_key_fill((void *)rss_data-\u003erss_key, rss_data-\u003erss_key_size);\ndrivers/net/ethernet/intel/idpf/idpf_lib.c-1322-\n--\ndrivers/net/ethernet/intel/igb/igb_main.c=4043=static int igb_sw_init(struct igb_adapter *adapter)\n--\ndrivers/net/ethernet/intel/igb/igb_main.c-4051-\t/* init RSS key */\ndrivers/net/ethernet/intel/igb/igb_main.c:4052:\tnetdev_rss_key_fill(adapter-\u003erss_key, sizeof(adapter-\u003erss_key));\ndrivers/net/ethernet/intel/igb/igb_main.c-4053-\n--\ndrivers/net/ethernet/intel/igc/igc_main.c=5041=static int igc_sw_init(struct igc_adapter *adapter)\n--\ndrivers/net/ethernet/intel/igc/igc_main.c-5049-\t/* init RSS key */\ndrivers/net/ethernet/intel/igc/igc_main.c:5050:\tnetdev_rss_key_fill(adapter-\u003erss_key, sizeof(adapter-\u003erss_key));\ndrivers/net/ethernet/intel/igc/igc_main.c-5051-\n--\ndrivers/net/ethernet/intel/ixgbe/ixgbe_main.c=4228=static inline int ixgbe_init_rss_key(struct ixgbe_adapter *adapter)\n--\ndrivers/net/ethernet/intel/ixgbe/ixgbe_main.c-4236-\ndrivers/net/ethernet/intel/ixgbe/ixgbe_main.c:4237:\t\tnetdev_rss_key_fill(rss_key, IXGBE_RSS_KEY_SIZE);\ndrivers/net/ethernet/intel/ixgbe/ixgbe_main.c-4238-\t\tadapter-\u003erss_key = rss_key;\n--\ndrivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c=1879=static inline int ixgbevf_init_rss_key(struct ixgbevf_adapter *adapter)\n--\ndrivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c-1887-\ndrivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:1888:\t\tnetdev_rss_key_fill(rss_key, IXGBEVF_RSS_HASH_KEY_SIZE);\ndrivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c-1889-\t\tadapter-\u003erss_key = rss_key;\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c=392=int otx2_rss_init(struct otx2_nic *pfvf)\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c-400-\tif (!rss-\u003eenable)\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c:401:\t\tnetdev_rss_key_fill(rss-\u003ekey, sizeof(rss-\u003ekey));\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c-402-\totx2_set_rss_key(pfvf);\n--\ndrivers/net/ethernet/marvell/sky2.c=1282=static void rx_set_rss(struct net_device *dev, netdev_features_t features)\n--\ndrivers/net/ethernet/marvell/sky2.c-1297-\ndrivers/net/ethernet/marvell/sky2.c:1298:\t\tnetdev_rss_key_fill(rss_key, sizeof(rss_key));\ndrivers/net/ethernet/marvell/sky2.c-1299-\t\tfor (i = 0; i \u003c nkeys; i++)\n--\ndrivers/net/ethernet/mellanox/mlx4/en_netdev.c=3161=int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,\n--\ndrivers/net/ethernet/mellanox/mlx4/en_netdev.c-3209-\tpriv-\u003etx_work_limit = MLX4_EN_DEFAULT_TX_WORK;\ndrivers/net/ethernet/mellanox/mlx4/en_netdev.c:3210:\tnetdev_rss_key_fill(priv-\u003erss_key, sizeof(priv-\u003erss_key));\ndrivers/net/ethernet/mellanox/mlx4/en_netdev.c-3211-\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en/rss.c=185=static void mlx5e_rss_params_init(struct mlx5e_rss *rss)\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en/rss.c-190-\trss-\u003ehash.hfunc = ETH_RSS_HASH_TOP;\ndrivers/net/ethernet/mellanox/mlx5/core/en/rss.c:191:\tnetdev_rss_key_fill(rss-\u003ehash.toeplitz_hash_key,\ndrivers/net/ethernet/mellanox/mlx5/core/en/rss.c-192-\t\t\t    sizeof(rss-\u003ehash.toeplitz_hash_key));\n--\ndrivers/net/ethernet/microsoft/mana/mana_en.c=3807=static int mana_probe_port(struct mana_context *ac, int port_idx,\n--\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3864-\ndrivers/net/ethernet/microsoft/mana/mana_en.c:3865:\tnetdev_rss_key_fill(apc-\u003ehashkey, MANA_HASH_KEY_SIZE);\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3866-\n--\ndrivers/net/ethernet/netronome/nfp/nfp_net_common.c=2618=static void nfp_net_rss_init(struct nfp_net *nn)\n--\ndrivers/net/ethernet/netronome/nfp/nfp_net_common.c-2637-\ndrivers/net/ethernet/netronome/nfp/nfp_net_common.c:2638:\tnetdev_rss_key_fill(nn-\u003erss_key, nfp_net_rss_key_sz(nn));\ndrivers/net/ethernet/netronome/nfp/nfp_net_common.c-2639-\n--\ndrivers/net/ethernet/pensando/ionic/ionic_lif.c=3235=int ionic_lif_alloc(struct ionic *ionic)\n--\ndrivers/net/ethernet/pensando/ionic/ionic_lif.c-3348-\t}\ndrivers/net/ethernet/pensando/ionic/ionic_lif.c:3349:\tnetdev_rss_key_fill(lif-\u003erss_hash_key, IONIC_RSS_HASH_KEY_SIZE);\ndrivers/net/ethernet/pensando/ionic/ionic_lif.c-3350-\n--\ndrivers/net/ethernet/qlogic/qede/qede_filter.c=564=void qede_fill_rss_params(struct qede_dev *edev,\n--\ndrivers/net/ethernet/qlogic/qede/qede_filter.c-602-\tif (!(edev-\u003erss_params_inited \u0026 QEDE_RSS_KEY_INITED)) {\ndrivers/net/ethernet/qlogic/qede/qede_filter.c:603:\t\tnetdev_rss_key_fill(edev-\u003erss_key, sizeof(edev-\u003erss_key));\ndrivers/net/ethernet/qlogic/qede/qede_filter.c-604-\t\tedev-\u003erss_params_inited |= QEDE_RSS_KEY_INITED;\n--\ndrivers/net/ethernet/sfc/ef100_netdev.c=423=int ef100_probe_netdev(struct efx_probe_data *probe_data)\n--\ndrivers/net/ethernet/sfc/ef100_netdev.c-474-\ndrivers/net/ethernet/sfc/ef100_netdev.c:475:\tnetdev_rss_key_fill(efx-\u003erss_context.rx_hash_key,\ndrivers/net/ethernet/sfc/ef100_netdev.c-476-\t\t\t    sizeof(efx-\u003erss_context.rx_hash_key));\n--\ndrivers/net/ethernet/sfc/efx.c=259=static int efx_probe_nic(struct efx_nic *efx)\n--\ndrivers/net/ethernet/sfc/efx.c-301-\tif (efx-\u003en_channels \u003e 1)\ndrivers/net/ethernet/sfc/efx.c:302:\t\tnetdev_rss_key_fill(efx-\u003erss_context.rx_hash_key,\ndrivers/net/ethernet/sfc/efx.c-303-\t\t\t\t    sizeof(efx-\u003erss_context.rx_hash_key));\n--\ndrivers/net/ethernet/sfc/ethtool_common.c=1219=int efx_ethtool_create_rxfh_context(struct net_device *net_dev,\n--\ndrivers/net/ethernet/sfc/ethtool_common.c-1238-\tif (!rxfh-\u003ekey)\ndrivers/net/ethernet/sfc/ethtool_common.c:1239:\t\tnetdev_rss_key_fill(ethtool_rxfh_context_key(ctx),\ndrivers/net/ethernet/sfc/ethtool_common.c-1240-\t\t\t\t    ctx-\u003ekey_size);\n--\ndrivers/net/ethernet/sfc/falcon/efx.c=1607=static int ef4_probe_nic(struct ef4_nic *efx)\n--\ndrivers/net/ethernet/sfc/falcon/efx.c-1647-\tif (efx-\u003en_channels \u003e 1)\ndrivers/net/ethernet/sfc/falcon/efx.c:1648:\t\tnetdev_rss_key_fill(\u0026efx-\u003erx_hash_key,\ndrivers/net/ethernet/sfc/falcon/efx.c-1649-\t\t\t\t    sizeof(efx-\u003erx_hash_key));\n--\ndrivers/net/ethernet/sfc/siena/efx.c=267=static int efx_probe_nic(struct efx_nic *efx)\n--\ndrivers/net/ethernet/sfc/siena/efx.c-309-\tif (efx-\u003en_channels \u003e 1)\ndrivers/net/ethernet/sfc/siena/efx.c:310:\t\tnetdev_rss_key_fill(efx-\u003erss_context.rx_hash_key,\ndrivers/net/ethernet/sfc/siena/efx.c-311-\t\t\t\t    sizeof(efx-\u003erss_context.rx_hash_key));\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c=7875=static int __stmmac_dvr_probe(struct device *device,\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c-8070-\trxq = priv-\u003eplat-\u003erx_queues_to_use;\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c:8071:\tnetdev_rss_key_fill(priv-\u003erss.key, sizeof(priv-\u003erss.key));\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c-8072-\tfor (i = 0; i \u003c ARRAY_SIZE(priv-\u003erss.table); i++)\n--\ndrivers/net/ethernet/synopsys/dwc-xlgmac-common.c=65=static int xlgmac_init(struct xlgmac_pdata *pdata)\n--\ndrivers/net/ethernet/synopsys/dwc-xlgmac-common.c-151-\t/* Initialize RSS hash key and lookup table */\ndrivers/net/ethernet/synopsys/dwc-xlgmac-common.c:152:\tnetdev_rss_key_fill(pdata-\u003erss_key, sizeof(pdata-\u003erss_key));\ndrivers/net/ethernet/synopsys/dwc-xlgmac-common.c-153-\n--\ndrivers/net/ethernet/wangxun/libwx/wx_hw.c=2456=static int wx_init_rss_key(struct wx *wx)\n--\ndrivers/net/ethernet/wangxun/libwx/wx_hw.c-2464-\ndrivers/net/ethernet/wangxun/libwx/wx_hw.c:2465:\t\tnetdev_rss_key_fill(rss_key, WX_RSS_KEY_SIZE);\ndrivers/net/ethernet/wangxun/libwx/wx_hw.c-2466-\t\twx-\u003erss_key = rss_key;\n--\ndrivers/net/ethernet/wangxun/libwx/wx_vf_lib.c=208=void wx_setup_vfmrqc_vf(struct wx *wx)\n--\ndrivers/net/ethernet/wangxun/libwx/wx_vf_lib.c-214-\t/* Fill out hash function seeds */\ndrivers/net/ethernet/wangxun/libwx/wx_vf_lib.c:215:\tnetdev_rss_key_fill(wx-\u003erss_key, WX_RSS_KEY_SIZE);\ndrivers/net/ethernet/wangxun/libwx/wx_vf_lib.c-216-\tfor (i = 0; i \u003c WX_RSS_KEY_SIZE / 4; i++)\n--\ndrivers/net/virtio_net.c=4251=static void virtnet_init_default_rss(struct virtnet_info *vi)\n--\ndrivers/net/virtio_net.c-4262-\ndrivers/net/virtio_net.c:4263:\tnetdev_rss_key_fill(vi-\u003erss_hash_key_data, vi-\u003erss_key_size);\ndrivers/net/virtio_net.c-4264-}\n--\ndrivers/net/vmxnet3/vmxnet3_drv.c=2899=vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)\n--\ndrivers/net/vmxnet3/vmxnet3_drv.c-3012-\t\trssConf-\u003eindTableSize = VMXNET3_RSS_IND_TABLE_SIZE;\ndrivers/net/vmxnet3/vmxnet3_drv.c:3013:\t\tnetdev_rss_key_fill(rssConf-\u003ehashKey, sizeof(rssConf-\u003ehashKey));\ndrivers/net/vmxnet3/vmxnet3_drv.c-3014-\n--\ndrivers/net/wireless/intel/iwlwifi/mld/fw.c=35=static int iwl_mld_send_rss_cfg_cmd(struct iwl_mld *mld)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/fw.c-52-\t\t\t1 + (i % (mld-\u003etrans-\u003einfo.num_rxqs - 1));\ndrivers/net/wireless/intel/iwlwifi/mld/fw.c:53:\tnetdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));\ndrivers/net/wireless/intel/iwlwifi/mld/fw.c-54-\n--\ndrivers/net/wireless/intel/iwlwifi/mvm/debugfs.c=1214=static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm,\n--\ndrivers/net/wireless/intel/iwlwifi/mvm/debugfs.c-1247-\ndrivers/net/wireless/intel/iwlwifi/mvm/debugfs.c:1248:\tnetdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));\ndrivers/net/wireless/intel/iwlwifi/mvm/debugfs.c-1249-\n--\ndrivers/net/wireless/intel/iwlwifi/mvm/fw.c=47=static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm)\n--\ndrivers/net/wireless/intel/iwlwifi/mvm/fw.c-66-\t\t\t1 + (i % (mvm-\u003etrans-\u003einfo.num_rxqs - 1));\ndrivers/net/wireless/intel/iwlwifi/mvm/fw.c:67:\tnetdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));\ndrivers/net/wireless/intel/iwlwifi/mvm/fw.c-68-\n--\ninclude/linux/netdevice.h=5326=extern u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly;\ninclude/linux/netdevice.h:5327:void netdev_rss_key_fill(void *buffer, size_t len);\ninclude/linux/netdevice.h-5328-\n--\nnet/Kconfig=543=config ETHTOOL_RSS_KEY_KUNIT_TEST\n--\nnet/Kconfig-547-\thelp\nnet/Kconfig:548:\t  KUnit tests checking the RSS key that netdev_rss_key_fill() hands\nnet/Kconfig-549-\t  to the drivers: flows differing only in the low order bits of one\n--\nnet/core/sysctl_net_core.c=335=static int proc_do_rss_key(const struct ctl_table *table, int write,\n--\nnet/core/sysctl_net_core.c-343-\tinitialized = READ_ONCE(netdev_rss_key_initialized);\nnet/core/sysctl_net_core.c:344:\t/* Pair with smp_wmb() in netdev_rss_key_fill(). */\nnet/core/sysctl_net_core.c-345-\tsmp_rmb();\n--\nnet/ethtool/common.h-17-\nnet/ethtool/common.h:18:/* netdev_rss_key_fill() guarantees that flows differing only in the low order\nnet/ethtool/common.h-19- * bits of one hashed header field spread over all the RX queues, for any queue\n--\nnet/ethtool/ioctl.c=1472=EXPORT_SYMBOL_IF_KUNIT(netdev_rss_key_init);\nnet/ethtool/ioctl.c-1473-\nnet/ethtool/ioctl.c:1474:void netdev_rss_key_fill(void *buffer, size_t len)\nnet/ethtool/ioctl.c-1475-{\n--\nnet/ethtool/ioctl.c-1479-}\nnet/ethtool/ioctl.c:1480:EXPORT_SYMBOL(netdev_rss_key_fill);\nnet/ethtool/ioctl.c-1481-\n--\nnet/ethtool/rss_key_test.c-1-// SPDX-License-Identifier: GPL-2.0-only\nnet/ethtool/rss_key_test.c:2:/* Tests for the RSS key generated by netdev_rss_key_fill().\nnet/ethtool/rss_key_test.c-3- *\n--\nnet/ethtool/rss_key_test.c=311=kunit_test_suite(rss_key_test_suite);\nnet/ethtool/rss_key_test.c-312-\nnet/ethtool/rss_key_test.c:313:MODULE_DESCRIPTION(\"Tests for the RSS key generated by netdev_rss_key_fill()\");\nnet/ethtool/rss_key_test.c-314-MODULE_LICENSE(\"GPL\");\n--\ntools/testing/selftests/drivers/net/hw/rss_key.py=6=entries of its indirection table.\ntools/testing/selftests/drivers/net/hw/rss_key.py-7-\ntools/testing/selftests/drivers/net/hw/rss_key.py:8:Most drivers take their key from netdev_rss_key_fill(), which generates keys\ntools/testing/selftests/drivers/net/hw/rss_key.py-9-having that property, but some bring their own and firmware sometimes\n--\ntools/testing/selftests/net/lib/py/rsskey.py=13=field and a given q with probability 1/2.\ntools/testing/selftests/net/lib/py/rsskey.py-14-\ntools/testing/selftests/net/lib/py/rsskey.py:15:netdev_rss_key_fill() generates keys that are non singular for every field of\ntools/testing/selftests/net/lib/py/rsskey.py-16-the hash input and every q up to RSS_KEY_QMAX.\n--\ntools/testing/selftests/net/netdev_rss_key.py=5=Check the quality of the host RSS key, /proc/sys/net/core/netdev_rss_key.\ntools/testing/selftests/net/netdev_rss_key.py-6-\ntools/testing/selftests/net/netdev_rss_key.py:7:This is the key netdev_rss_key_fill() hands to the drivers. It has to be non\ntools/testing/selftests/net/netdev_rss_key.py-8-singular for every field of the hash input and every queue count up to\n--\ntools/testing/selftests/net/netdev_rss_key.py=13=The key is generated lazily, the first time a driver asks for it, so this\ntools/testing/selftests/net/netdev_rss_key.py:14:test skips until a driver has done so. Any NIC calling netdev_rss_key_fill()\ntools/testing/selftests/net/netdev_rss_key.py-15-is enough; in a virtual machine, virtio_net does it from\n--\ntools/testing/selftests/net/netdev_rss_key.py=33=def _read_key():\n--\ntools/testing/selftests/net/netdev_rss_key.py-44-        raise KsftSkipEx(\"the host RSS key has not been generated yet, \"\ntools/testing/selftests/net/netdev_rss_key.py:45:                         \"no driver has called netdev_rss_key_fill()\")\ntools/testing/selftests/net/netdev_rss_key.py-46-\n--\ntools/testing/selftests/net/netdev_rss_key.py=80=def check_grid() -\u003e None:\n--\ntools/testing/selftests/net/netdev_rss_key.py-82-\ntools/testing/selftests/net/netdev_rss_key.py:83:    netdev_rss_key_fill() does not get to know what the hardware hashes, so\ntools/testing/selftests/net/netdev_rss_key.py-84-    it gives the property at every 16-bit aligned position of the key. A NIC\n"
}

5/2 2026/09/23 18:08 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 28292
							output: 40
							thoughts: 160
						

Thoughts:
**Investigating RSS Key Initialization**

Okay, so I'm trying to get a handle on how the RSS key is initialized within the kernel. Let's trace where `netdev_rss_key_fill()` gets called. I know it's a key function for configuring Receive Side Scaling, so understanding its usage is critical. Right, let's see... looking at the code, it's called from `virtio_net` in `virtnet_init_default_rss()`, that makes sense. Also, there's a call in `efx_ethtool_create_rxfh_context`, `e1000e_setup_rss_hash`, and `igb_sw_init` amongst others. This confirms its use in various driver initializations.

Now, I also need to consider the sysctl interface – `/proc/sys/net/core/netdev_rss_key`. I remember that exposes the RSS key to user space.  Ah, right, `proc_do_rss_key` handles that interaction.  The crucial question is, does `proc_do_rss_key` itself call `netdev_rss_key_fill`? That would be interesting, so I'll need to confirm that. Let me jump into `net/core/sysctl_net_core.c` and take a look around line 335.



6/2 2026/09/23 18:08 tool read-file
0m Args:
{
  "File": "net/core/sysctl_net_core.c",
  "FirstLine": 330,
  "LineCount": 40
}

Results:
{
  "Contents": " 330:\t\tmutex_unlock(\u0026dev_weight_mutex);\n 331:\t\n 332:\t\treturn ret;\n 333:\t}\n 334:\t\n 335:\tstatic int proc_do_rss_key(const struct ctl_table *table, int write,\n 336:\t\t\t\t   void *buffer, size_t *lenp, loff_t *ppos)\n 337:\t{\n 338:\t\tchar buf[NETDEV_RSS_KEY_LEN * 3];\n 339:\t\tstruct ctl_table fake_table;\n 340:\t\tchar *pos = buf;\n 341:\t\tbool initialized;\n 342:\t\n 343:\t\tinitialized = READ_ONCE(netdev_rss_key_initialized);\n 344:\t\t/* Pair with smp_wmb() in netdev_rss_key_fill(). */\n 345:\t\tsmp_rmb();\n 346:\t\n 347:\t\tfor (int i = 0; i \u003c NETDEV_RSS_KEY_LEN; i++) {\n 348:\t\t\tpos = hex_byte_pack(pos, initialized ? netdev_rss_key[i] : 0);\n 349:\t\t\t*pos++ = ':';\n 350:\t\t}\n 351:\t\t*(--pos) = 0;\n 352:\t\n 353:\t\tfake_table.data = buf;\n 354:\t\tfake_table.maxlen = sizeof(buf);\n 355:\t\treturn proc_dostring(\u0026fake_table, write, buffer, lenp, ppos);\n 356:\t}\n 357:\t\n 358:\tstatic int proc_do_skb_defer_max(const struct ctl_table *table, int write,\n 359:\t\t\t void *buffer, size_t *lenp, loff_t *ppos)\n 360:\t{\n 361:\t\tstatic DEFINE_MUTEX(skb_defer_max_mutex);\n 362:\t\tint ret, oval, nval;\n 363:\t\n 364:\t\tmutex_lock(\u0026skb_defer_max_mutex);\n 365:\t\n 366:\t\toval = !net_hotdata.sysctl_skb_defer_max;\n 367:\t\tret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);\n 368:\t\tnval = !net_hotdata.sysctl_skb_defer_max;\n 369:\t\n"
}

7/2 2026/09/23 18:08 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 29460
							output: 22
							thoughts: 194
						

Thoughts:
Here's my analysis:

**Deconstructing the RSS Key Retrieval**

Okay, so `proc_do_rss_key` reads the `netdev_rss_key`. That's the starting point. Now, I need to understand where this `netdev_rss_key` is populated. The obvious next step is to examine `netdev_rss_key_fill` in `net/ethtool/ioctl.c`. Let's see... Ah, there it is:
```c
void netdev_rss_key_fill(void *buffer, size_t len)
{
	BUG_ON(len > sizeof(netdev_rss_key));
	DO_ONCE(netdev_rss_key_init, netdev_rss_key, sizeof(netdev_rss_key));
	memcpy(buffer, netdev_rss_key, len);
}
EXPORT_SYMBOL(netdev_rss_key_fill);
```
Right, so `netdev_rss_key_fill` seems to be responsible for copying the contents. The `DO_ONCE` macro ensures initialization once. The `EXPORT_SYMBOL` indicates that this function is available outside of the kernel module it's defined in. But, hold on a second... is `netdev_rss_key_fill` actually used? I need to trace its call sites. Let's see where `virtnet_init_default_rss()` is called, as that seems like a likely candidate given the context. That'll tell me if `netdev_rss_key_fill` is a relevant path.



8/2 2026/09/23 18:08 tool grepper
0m Args:
{
  "Expression": "virtnet_init_default_rss"
}

Results:
{
  "Output": "drivers/net/virtio_net.c=4228=static bool virtnet_commit_rss_command(struct virtnet_info *vi)\n--\ndrivers/net/virtio_net.c-4250-\ndrivers/net/virtio_net.c:4251:static void virtnet_init_default_rss(struct virtnet_info *vi)\ndrivers/net/virtio_net.c-4252-{\n--\ndrivers/net/virtio_net.c=6772=static int virtnet_probe(struct virtio_device *vdev)\n--\ndrivers/net/virtio_net.c-7044-\tif (vi-\u003ehas_rss || vi-\u003ehas_rss_hash_report)\ndrivers/net/virtio_net.c:7045:\t\tvirtnet_init_default_rss(vi);\ndrivers/net/virtio_net.c-7046-\n--\ntools/testing/selftests/net/netdev_rss_key.py=15=is enough; in a virtual machine, virtio_net does it from\ntools/testing/selftests/net/netdev_rss_key.py:16:virtnet_init_default_rss() once RSS has been negotiated.\ntools/testing/selftests/net/netdev_rss_key.py-17-\n"
}

9/2 2026/09/23 18:08 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 30365
							output: 25
							thoughts: 287
						

Thoughts:
**My Initial Concerns Regarding RSS Key Filling**

Okay, so I'm pondering whether a userspace process can initiate a call to `netdev_rss_key_fill()` directly, or if it has to be through some indirect pathway. This is important for security and control, so let's dig into the call sites of that function.

Aha, let's refresh our memory and check those calls, those I identified with `grepper` earlier:

*   First, we have `drivers/infiniband/hw/mana/qp.c`, which uses it within `mana_ib_cfg_vport_steering`. That's interesting, but not directly userspace-facing, I don't think.
*   Next, a *huge* list of Ethernet drivers are using it. (ena, xgbe, bnx2x, tg3, bnad, nicvf, enic, be_main, funeth, gve, hns, hinic, hinic3, e1000e, fm10k, i40e, iavf, ice, idpf, igb, igc, ixgbe, ixgbevf, otx2, sky2, mlx4, mlx5, mana, nfp, ionic, qede, sfc...). So, many Ethernet drivers rely on this function.
*   Finally, the third is in `drivers/net/ethernet/sfc/ethtool_common.c` within `efx_ethtool_create_rxfh_context`.

But wait, this last one with ethtool. **That's key.** Ethtool is the usual means of interacting with these settings from userspace. So I need to verify that `ethtool` isn't using it directly via ioctl, or netlink. Let's see if `ethtool` exposes those functions directly. I will search for the string `netdev_rss_key_fill` in `ethtool`. Also I will search for `rxfh`. It's possible that `ethtool` offers userspace control over RSS key filling. That's the next avenue to explore.



10/2 2026/09/23 18:09 tool grepper
0m Args:
{
  "Expression": "rxfh.*create|create.*rxfh"
}

Results:
{
  "Output": "drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c=1944=static int bnxt_rxfh_context_check(struct bnxt *bp,\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c-1965-\ndrivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:1966:static int bnxt_create_rxfh_context(struct net_device *dev,\ndrivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c-1967-\t\t\t\t    struct ethtool_rxfh_context *ctx,\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c=5727=const struct ethtool_ops bnxt_ethtool_ops = {\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c-5778-\t.set_rxfh_fields        = bnxt_set_rxfh_fields,\ndrivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:5779:\t.create_rxfh_context\t= bnxt_create_rxfh_context,\ndrivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c-5780-\t.modify_rxfh_context\t= bnxt_modify_rxfh_context,\n--\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c=5688=static bool mvpp2_ethtool_rxfh_okay(struct mvpp2_port *port,\n--\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c-5703-\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:5704:static int mvpp2_create_rxfh_context(struct net_device *dev,\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c-5705-\t\t\t\t     struct ethtool_rxfh_context *ctx,\n--\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c-5716-\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:5717:\tret = mvpp22_port_rss_ctx_create(port, rxfh-\u003erss_context);\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c-5718-\tif (ret)\n--\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c=5829=static const struct ethtool_ops mvpp2_eth_tool_ops = {\n--\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c-5855-\t.set_rxfh_fields\t= mvpp2_ethtool_set_rxfh_fields,\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:5856:\t.create_rxfh_context\t= mvpp2_create_rxfh_context,\ndrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c-5857-\t.modify_rxfh_context\t= mvpp2_modify_rxfh_context,\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c=807=static u32 otx2_get_rxfh_indir_size(struct net_device *dev)\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c-811-\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c:812:static int otx2_create_rxfh(struct net_device *dev,\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c-813-\t\t\t    struct ethtool_rxfh_context *ctx,\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c=1350=static const struct ethtool_ops otx2_ethtool_ops = {\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c-1376-\t.set_rxfh_fields\t= otx2_set_rss_hash_opts,\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c:1377:\t.create_rxfh_context\t= otx2_create_rxfh,\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c-1378-\t.modify_rxfh_context\t= otx2_modify_rxfh,\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c=1473=static const struct ethtool_ops otx2vf_ethtool_ops = {\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c-1495-\t.set_rxfh_fields\t= otx2_set_rss_hash_opts,\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c:1496:\t.create_rxfh_context\t= otx2_create_rxfh,\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c-1497-\t.modify_rxfh_context\t= otx2_modify_rxfh,\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c=1525=static int mlx5e_set_rxfh(struct net_device *dev,\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c-1544-\ndrivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c:1545:static int mlx5e_create_rxfh_context(struct net_device *dev,\ndrivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c-1546-\t\t\t\t     struct ethtool_rxfh_context *ctx,\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c=2716=const struct ethtool_ops mlx5e_ethtool_ops = {\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c-2754-\t.set_rxfh_fields   = mlx5e_set_rxfh_fields,\ndrivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c:2755:\t.create_rxfh_context\t= mlx5e_create_rxfh_context,\ndrivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c-2756-\t.modify_rxfh_context\t= mlx5e_modify_rxfh_context,\n--\ndrivers/net/ethernet/meta/fbnic/fbnic_ethtool.c=1478=static int\ndrivers/net/ethernet/meta/fbnic/fbnic_ethtool.c:1479:fbnic_create_rxfh_context(struct net_device *netdev,\ndrivers/net/ethernet/meta/fbnic/fbnic_ethtool.c-1480-\t\t\t  struct ethtool_rxfh_context *ctx,\n--\ndrivers/net/ethernet/meta/fbnic/fbnic_ethtool.c=2028=static const struct ethtool_ops fbnic_ethtool_ops = {\n--\ndrivers/net/ethernet/meta/fbnic/fbnic_ethtool.c-2066-\t.set_rxfh_fields\t\t= fbnic_set_rss_hash_opts,\ndrivers/net/ethernet/meta/fbnic/fbnic_ethtool.c:2067:\t.create_rxfh_context\t\t= fbnic_create_rxfh_context,\ndrivers/net/ethernet/meta/fbnic/fbnic_ethtool.c-2068-\t.modify_rxfh_context\t\t= fbnic_modify_rxfh_context,\n--\ndrivers/net/ethernet/sfc/ef100_ethtool.c=39=const struct ethtool_ops ef100_ethtool_ops = {\n--\ndrivers/net/ethernet/sfc/ef100_ethtool.c-66-\t.set_rxfh\t\t= efx_ethtool_set_rxfh,\ndrivers/net/ethernet/sfc/ef100_ethtool.c:67:\t.create_rxfh_context\t= efx_ethtool_create_rxfh_context,\ndrivers/net/ethernet/sfc/ef100_ethtool.c-68-\t.modify_rxfh_context\t= efx_ethtool_modify_rxfh_context,\n--\ndrivers/net/ethernet/sfc/ethtool.c=240=const struct ethtool_ops efx_ethtool_ops = {\n--\ndrivers/net/ethernet/sfc/ethtool.c-275-\t.get_rxfh_fields\t= efx_ethtool_get_rxfh_fields,\ndrivers/net/ethernet/sfc/ethtool.c:276:\t.create_rxfh_context\t= efx_ethtool_create_rxfh_context,\ndrivers/net/ethernet/sfc/ethtool.c-277-\t.modify_rxfh_context\t= efx_ethtool_modify_rxfh_context,\n--\ndrivers/net/ethernet/sfc/ethtool_common.c=1186=int efx_ethtool_modify_rxfh_context(struct net_device *net_dev,\n--\ndrivers/net/ethernet/sfc/ethtool_common.c-1218-\ndrivers/net/ethernet/sfc/ethtool_common.c:1219:int efx_ethtool_create_rxfh_context(struct net_device *net_dev,\ndrivers/net/ethernet/sfc/ethtool_common.c-1220-\t\t\t\t    struct ethtool_rxfh_context *ctx,\n--\ndrivers/net/ethernet/sfc/ethtool_common.h=53=int efx_ethtool_get_rxfh_fields(struct net_device *net_dev,\ndrivers/net/ethernet/sfc/ethtool_common.h-54-\t\t\t\tstruct ethtool_rxfh_fields *info);\ndrivers/net/ethernet/sfc/ethtool_common.h:55:int efx_ethtool_create_rxfh_context(struct net_device *net_dev,\ndrivers/net/ethernet/sfc/ethtool_common.h-56-\t\t\t\t    struct ethtool_rxfh_context *ctx,\n--\ninclude/linux/ethtool.h=923=struct kernel_ethtool_ts_info {\n--\ninclude/linux/ethtool.h-969- *\tthe core will only use IDs strictly less than this value, as the\ninclude/linux/ethtool.h:970: *\t@rss_context argument to @create_rxfh_context and friends.\ninclude/linux/ethtool.h-971- * @supported_coalesce_params: supported types of interrupt coalescing.\n--\ninclude/linux/ethtool.h-1087- * @set_rxfh_fields: Set header fields used for flow hashing.\ninclude/linux/ethtool.h:1088: * @create_rxfh_context: Create a new RSS context with the specified RX flow\ninclude/linux/ethtool.h-1089- *\thash indirection table, hash key, and hash function.\n--\ninclude/linux/ethtool.h=1206=struct ethtool_ops {\n--\ninclude/linux/ethtool.h-1285-\t\t\t\t   struct netlink_ext_ack *extack);\ninclude/linux/ethtool.h:1286:\tint\t(*create_rxfh_context)(struct net_device *,\ninclude/linux/ethtool.h-1287-\t\t\t\t       struct ethtool_rxfh_context *ctx,\n--\nnet/ethtool/ioctl.c=1602=static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,\n--\nnet/ethtool/ioctl.c-1631-\t/* Most drivers don't handle rss_context, check it's 0 as well */\nnet/ethtool/ioctl.c:1632:\tif (rxfh.rss_context \u0026\u0026 !ops-\u003ecreate_rxfh_context)\nnet/ethtool/ioctl.c-1633-\t\treturn -EOPNOTSUPP;\n--\nnet/ethtool/ioctl.c=1708=static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,\n--\nnet/ethtool/ioctl.c-1739-\t/* Most drivers don't handle rss_context, check it's 0 as well */\nnet/ethtool/ioctl.c:1740:\tif (rxfh.rss_context \u0026\u0026 !ops-\u003ecreate_rxfh_context)\nnet/ethtool/ioctl.c-1741-\t\treturn -EOPNOTSUPP;\n--\nnet/ethtool/ioctl.c-1749-\t\treturn -EOPNOTSUPP;\nnet/ethtool/ioctl.c:1750:\tcreate = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC;\nnet/ethtool/ioctl.c-1751-\n--\nnet/ethtool/ioctl.c-1877-\t\tntf = ETHTOOL_MSG_RSS_CREATE_NTF;\nnet/ethtool/ioctl.c:1878:\t\tret = ops-\u003ecreate_rxfh_context(dev, ctx, \u0026rxfh_dev, extack);\nnet/ethtool/ioctl.c-1879-\t\t/* Make sure driver populates defaults */\n--\nnet/ethtool/rss.c=260=rss_prepare_data(const struct ethnl_req_info *req_base,\n--\nnet/ethtool/rss.c-273-\t/* Some drivers don't handle rss_context */\nnet/ethtool/rss.c:274:\tif (request-\u003erss_context \u0026\u0026 !ops-\u003ecreate_rxfh_context)\nnet/ethtool/rss.c-275-\t\treturn -EOPNOTSUPP;\n--\nnet/ethtool/rss.c=582=ethnl_rss_set_validate(struct ethnl_req_info *req_info, struct genl_info *info)\n--\nnet/ethtool/rss.c-589-\nnet/ethtool/rss.c:590:\tif (request-\u003erss_context \u0026\u0026 !ops-\u003ecreate_rxfh_context)\nnet/ethtool/rss.c-591-\t\tbad_attr = bad_attr ?: tb[ETHTOOL_A_RSS_CONTEXT];\n--\nnet/ethtool/rss.c=946=ethnl_rss_create_validate(struct net_device *dev, struct genl_info *info)\n--\nnet/ethtool/rss.c-952-\nnet/ethtool/rss.c:953:\tif (!ops-\u003ecreate_rxfh_context)\nnet/ethtool/rss.c-954-\t\treturn -EOPNOTSUPP;\n--\nnet/ethtool/rss.c=1002=int ethnl_rss_create_doit(struct sk_buff *skb, struct genl_info *info)\n--\nnet/ethtool/rss.c-1083-\nnet/ethtool/rss.c:1084:\tret = ops-\u003ecreate_rxfh_context(dev, ctx, \u0026rxfh, info-\u003eextack);\nnet/ethtool/rss.c-1085-\tif (ret)\n--\nnet/ethtool/rss.c=1150=int ethnl_rss_delete_doit(struct sk_buff *skb, struct genl_info *info)\n--\nnet/ethtool/rss.c-1172-\nnet/ethtool/rss.c:1173:\tif (!ops-\u003ecreate_rxfh_context) {\nnet/ethtool/rss.c-1174-\t\tret = -EOPNOTSUPP;\n"
}

11/2 2026/09/23 18:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 35534
							output: 39
							thoughts: 123
						

Thoughts:
**Investigating RSS Key Filling in Virtualized Network Environments**

Okay, let's dive into this `netdev_rss_key_fill` function. I need to understand its behavior in a virtualized context, specifically within environments like syzkaller running QEMU, or even GCE with standard virtio_net or e1000e drivers. A key question jumps to mind: Wait, is virtio_net running in QEMU? Ah, right! Of course it is! Virtio-net is the default network device in QEMU and syzkaller - I should have known that. So, does virtio_net actually call this `netdev_rss_key_fill` function? Time to check. Let's start by inspecting the `virtnet_probe` function in `drivers/net/virtio_net.c`. That should give me the entry point I need.



12/2 2026/09/23 18:09 tool read-file
0m Args:
{
  "File": "drivers/net/virtio_net.c",
  "FirstLine": 7035,
  "LineCount": 25
}

Results:
{
  "Contents": "7035:\t\n7036:\t\tif (virtio_has_feature(vdev, VIRTIO_NET_F_STANDBY)) {\n7037:\t\t\tvi-\u003efailover = net_failover_create(vi-\u003edev);\n7038:\t\t\tif (IS_ERR(vi-\u003efailover)) {\n7039:\t\t\t\terr = PTR_ERR(vi-\u003efailover);\n7040:\t\t\t\tgoto free_page_pools;\n7041:\t\t\t}\n7042:\t\t}\n7043:\t\n7044:\t\tif (vi-\u003ehas_rss || vi-\u003ehas_rss_hash_report)\n7045:\t\t\tvirtnet_init_default_rss(vi);\n7046:\t\n7047:\t\tenable_rx_mode_work(vi);\n7048:\t\n7049:\t\tfor (i = 0; i \u003c ARRAY_SIZE(guest_offloads); i++) {\n7050:\t\t\tunsigned int fbit;\n7051:\t\n7052:\t\t\tfbit = virtio_offload_to_feature(guest_offloads[i]);\n7053:\t\t\tif (virtio_has_feature(vi-\u003evdev, fbit))\n7054:\t\t\t\tset_bit(guest_offloads[i], \u0026vi-\u003eguest_offloads);\n7055:\t\t}\n7056:\t\tvi-\u003eguest_offloads_capable = vi-\u003eguest_offloads;\n7057:\t\n7058:\t\tif (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) \u0026\u0026\n7059:\t\t    (vi-\u003eguest_offloads_capable \u0026 GUEST_OFFLOAD_GRO_HW_MASK))\n"
}

13/2 2026/09/23 18:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 36340
							output: 38
							thoughts: 415
						

Thoughts:
**Investigating the Linux Network RSS Key Initialization**

Okay, so I'm digging into how the Receive Side Scaling (RSS) key gets initialized, specifically in a virtualized environment. My first thought was to look at `netdev_rss_key.py`, and it seems like in a virtual machine using `virtio_net`, the RSS key is handled from `virtnet_init_default_rss()` once the negotiation is done.

But wait a minute... what if someone reads the contents of the `/proc/sys/net/core/netdev_rss_key` sysctl? It looks like reading that triggers `proc_do_rss_key`. Let's take a closer look at that function:

```c
static int proc_do_rss_key(const struct ctl_table *table, int write,
			   void *buffer, size_t *lenp, loff_t *ppos)
{
	char buf[NETDEV_RSS_KEY_LEN * 3];
	struct ctl_table fake_table;
	char *pos = buf;
	bool initialized;

	initialized = READ_ONCE(netdev_rss_key_initialized);
	/* Pair with smp_wmb() in netdev_rss_key_fill(). */
	smp_rmb();

	for (int i = 0; i < NETDEV_RSS_KEY_LEN; i++) {
		pos = hex_byte_pack(pos, initialized ? netdev_rss_key[i] : 0);
		*pos++ = ':';
	}
	*(--pos) = 0;

	fake_table.data = buf;
	fake_table.maxlen = sizeof(buf);
	return proc_dostring(&fake_table, write, buffer, lenp, ppos);
}
```

Okay, so `proc_do_rss_key` checks `netdev_rss_key_initialized` and then formats the RSS key (or zeros if it's not initialized) as a hex string with colons for that sysctl entry. This is interesting. Now, I have to think, can we write *to* `/proc/sys/net/core/netdev_rss_key`? It's time to check `net/core/sysctl_net_core.c` and see how this sysctl is actually registered, and if it's set up for writes. That will tell me a lot about the degree of control the user has over it.



14/2 2026/09/23 18:09 tool grepper
0m Args:
{
  "Expression": "netdev_rss_key",
  "PathPrefix": "net/core/sysctl_net_core.c"
}

Results:
{
  "Output": "net/core/sysctl_net_core.c=335=static int proc_do_rss_key(const struct ctl_table *table, int write,\n--\nnet/core/sysctl_net_core.c-342-\nnet/core/sysctl_net_core.c:343:\tinitialized = READ_ONCE(netdev_rss_key_initialized);\nnet/core/sysctl_net_core.c:344:\t/* Pair with smp_wmb() in netdev_rss_key_fill(). */\nnet/core/sysctl_net_core.c-345-\tsmp_rmb();\n--\nnet/core/sysctl_net_core.c-347-\tfor (int i = 0; i \u003c NETDEV_RSS_KEY_LEN; i++) {\nnet/core/sysctl_net_core.c:348:\t\tpos = hex_byte_pack(pos, initialized ? netdev_rss_key[i] : 0);\nnet/core/sysctl_net_core.c-349-\t\t*pos++ = ':';\n--\nnet/core/sysctl_net_core.c=436=static struct ctl_table net_core_table[] = {\n--\nnet/core/sysctl_net_core.c-483-\t{\nnet/core/sysctl_net_core.c:484:\t\t.procname\t= \"netdev_rss_key\",\nnet/core/sysctl_net_core.c:485:\t\t.data\t\t= \u0026netdev_rss_key,\nnet/core/sysctl_net_core.c-486-\t\t.maxlen\t\t= sizeof(int),\n"
}

15/2 2026/09/23 18:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 37778
							output: 40
							thoughts: 18
						

Thoughts:
Okay, let's dive into this. Here's my thought process on examining `netdev_rss_key`:

**Analyzing the `netdev_rss_key` sysctl Entry**

Right, so I'm interested in the `netdev_rss_key` entry within the `sysctl` table. My initial focus is to understand its current configuration and how it's being used. I'll need to know whether it's enabled, the actual key value if it's customized, and then correlate all of that back to the associated interface.

My immediate questions are:

*   What are the permitted values for this key? Is there a default value, or is it dynamically set?
*   How is this key impacting RSS (Receive Side Scaling) behavior on my network interfaces? Are packet distributions as expected?
*   What's the relationship between `netdev_rss_key`, the NIC driver, and the underlying hardware? Are there potential conflicts or optimizations I should be aware of?
*   If I change this key, will the change require a network restart or other system-level intervention?

I need to quickly establish the current state and interpret what the settings mean in the context of my network topology and workload. I'll probably start with the basic `sysctl` command. Then I'll look for any available documentation or kernel sources on this particular variable. I'll consider how these settings could interact with other network settings.



16/2 2026/09/23 18:09 tool read-file
0m Args:
{
  "File": "net/core/sysctl_net_core.c",
  "FirstLine": 480,
  "LineCount": 15
}

Results:
{
  "Contents": " 480:\t\t\t.mode\t\t= 0644,\n 481:\t\t\t.proc_handler\t= proc_dointvec\n 482:\t\t},\n 483:\t\t{\n 484:\t\t\t.procname\t= \"netdev_rss_key\",\n 485:\t\t\t.data\t\t= \u0026netdev_rss_key,\n 486:\t\t\t.maxlen\t\t= sizeof(int),\n 487:\t\t\t.mode\t\t= 0444,\n 488:\t\t\t.proc_handler\t= proc_do_rss_key,\n 489:\t\t},\n 490:\t#ifdef CONFIG_BPF_JIT\n 491:\t\t{\n 492:\t\t\t.procname\t= \"bpf_jit_enable\",\n 493:\t\t\t.data\t\t= \u0026bpf_jit_enable,\n 494:\t\t\t.maxlen\t\t= sizeof(int),\n"
}

17/2 2026/09/23 18:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 38385
							output: 33
							thoughts: 146
						

Thoughts:
Here's my thought process, as it stands:

**Analyzing `netdev_rss_key_fill` in a Syzkaller Context**

Okay, first things first, the mode is set to read-only, which is a good starting point. Now, the real question is whether we can actually trigger `netdev_rss_key_fill` within a Syzkaller environment. I need to figure out the network device setup Syzkaller typically uses. Ah, right, Syzkaller generally runs in a standard QEMU VM. So, what network devices are *likely* to be present in that kind of setup? My intuition says `virtio_net` is the most probable candidate.

Okay, let's drill down: Does `virtio_net` probe correctly in QEMU based on `vi->has_rss || vi->has_rss_hash_report`? I need to understand the conditions under which the driver declares RSS capabilities. Time to check when `vi->has_rss` is set to true. Let's start by grepping the source code for `has_rss` within `drivers/net/virtio_net.c`. That will give me the most efficient way to understand the control flow.



18/2 2026/09/23 18:09 tool grepper
0m Args:
{
  "Expression": "has_rss",
  "PathPrefix": "drivers/net/virtio_net.c"
}

Results:
{
  "Output": "drivers/net/virtio_net.c=384=struct virtnet_info {\n--\ndrivers/net/virtio_net.c-413-\t/* Host supports rss and/or hash report */\ndrivers/net/virtio_net.c:414:\tbool has_rss;\ndrivers/net/virtio_net.c:415:\tbool has_rss_hash_report;\ndrivers/net/virtio_net.c-416-\tu8 rss_key_size;\n--\ndrivers/net/virtio_net.c=532=static size_t virtnet_rss_hdr_size(const struct virtnet_info *vi)\ndrivers/net/virtio_net.c-533-{\ndrivers/net/virtio_net.c:534:\tu16 indir_table_size = vi-\u003ehas_rss ? vi-\u003erss_indir_table_size : 1;\ndrivers/net/virtio_net.c-535-\n--\ndrivers/net/virtio_net.c=2513=static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue *rq,\n--\ndrivers/net/virtio_net.c-2519-\thdr = skb_vnet_common_hdr(skb);\ndrivers/net/virtio_net.c:2520:\tif (dev-\u003efeatures \u0026 NETIF_F_RXHASH \u0026\u0026 vi-\u003ehas_rss_hash_report)\ndrivers/net/virtio_net.c-2521-\t\tvirtio_skb_set_hash(\u0026hdr-\u003ehash_v1_hdr, skb);\n--\ndrivers/net/virtio_net.c=3741=static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs)\n--\ndrivers/net/virtio_net.c-3758-\t */\ndrivers/net/virtio_net.c:3759:\tif (vi-\u003ehas_rss \u0026\u0026 !netif_is_rxfh_configured(dev)) {\ndrivers/net/virtio_net.c-3760-\t\told_rss_hdr = vi-\u003erss_hdr;\n--\ndrivers/net/virtio_net.c-3801-\t */\ndrivers/net/virtio_net.c:3802:\tif (vi-\u003ehas_rss)\ndrivers/net/virtio_net.c-3803-\t\tvi-\u003erss_trailer.max_tx_vq = cpu_to_le16(queue_pairs);\n--\ndrivers/net/virtio_net.c=4228=static bool virtnet_commit_rss_command(struct virtnet_info *vi)\n--\ndrivers/net/virtio_net.c-4238-\tif (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ,\ndrivers/net/virtio_net.c:4239:\t\t\t\t  vi-\u003ehas_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG\ndrivers/net/virtio_net.c-4240-\t\t\t\t  : VIRTIO_NET_CTRL_MQ_HASH_CONFIG, sgs))\n--\ndrivers/net/virtio_net.c=5574=static int virtnet_set_rxfh(struct net_device *dev,\n--\ndrivers/net/virtio_net.c-5586-\tif (rxfh-\u003eindir) {\ndrivers/net/virtio_net.c:5587:\t\tif (!vi-\u003ehas_rss)\ndrivers/net/virtio_net.c-5588-\t\t\treturn -EOPNOTSUPP;\n--\ndrivers/net/virtio_net.c-5599-\t\t */\ndrivers/net/virtio_net.c:5600:\t\tif (!vi-\u003ehas_rss \u0026\u0026 !vi-\u003ehas_rss_hash_report)\ndrivers/net/virtio_net.c-5601-\t\t\treturn -EOPNOTSUPP;\n--\ndrivers/net/virtio_net.c=6772=static int virtnet_probe(struct virtio_device *vdev)\n--\ndrivers/net/virtio_net.c-6895-\tif (virtio_has_feature(vdev, VIRTIO_NET_F_HASH_REPORT))\ndrivers/net/virtio_net.c:6896:\t\tvi-\u003ehas_rss_hash_report = true;\ndrivers/net/virtio_net.c-6897-\ndrivers/net/virtio_net.c-6898-\tif (virtio_has_feature(vdev, VIRTIO_NET_F_RSS)) {\ndrivers/net/virtio_net.c:6899:\t\tvi-\u003ehas_rss = true;\ndrivers/net/virtio_net.c-6900-\n--\ndrivers/net/virtio_net.c-6910-\ndrivers/net/virtio_net.c:6911:\tif (vi-\u003ehas_rss || vi-\u003ehas_rss_hash_report) {\ndrivers/net/virtio_net.c-6912-\t\tkey_sz = virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));\n--\ndrivers/net/virtio_net.c-6933-\t\tvi-\u003ehdr_len = sizeof(struct virtio_net_hdr_v1_hash_tunnel);\ndrivers/net/virtio_net.c:6934:\telse if (vi-\u003ehas_rss_hash_report)\ndrivers/net/virtio_net.c-6935-\t\tvi-\u003ehdr_len = sizeof(struct virtio_net_hdr_v1_hash);\n--\ndrivers/net/virtio_net.c-7043-\ndrivers/net/virtio_net.c:7044:\tif (vi-\u003ehas_rss || vi-\u003ehas_rss_hash_report)\ndrivers/net/virtio_net.c-7045-\t\tvirtnet_init_default_rss(vi);\n--\ndrivers/net/virtio_net.c-7076-\ndrivers/net/virtio_net.c:7077:\tif (vi-\u003ehas_rss || vi-\u003ehas_rss_hash_report) {\ndrivers/net/virtio_net.c-7078-\t\tif (!virtnet_commit_rss_command(vi)) {\n--\ndrivers/net/virtio_net.c-7080-\t\t\tdev-\u003ehw_features \u0026= ~NETIF_F_RXHASH;\ndrivers/net/virtio_net.c:7081:\t\t\tvi-\u003ehas_rss_hash_report = false;\ndrivers/net/virtio_net.c:7082:\t\t\tvi-\u003ehas_rss = false;\ndrivers/net/virtio_net.c-7083-\t\t}\n"
}

19/2 2026/09/23 18:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 40533
							output: 30
							thoughts: 94
						

Thoughts:
Here's my thought process, as it relates to the kernel code:

**Thinking Through RSS Initialization in the Virtual Network Driver**

Okay, so `virtnet_init_default_rss()` is called. That makes sense, but only if the virtual network card supports either `VIRTIO_NET_F_HASH_REPORT` or `VIRTIO_NET_F_RSS`. This all happens during `virtnet_probe()`. That's the standard initialization flow. But a more interesting question has just come to mind. I know this functionality mostly revolves around the hardware itself or, perhaps the hypervisor.

Now I'm wondering, can userspace really create virtual devices or network devices directly? Is there some interface in the kernel that I'm forgetting? Could a process in userspace create a completely virtual device? I know about `netdevsim`, and that's probably related, but I don't use it as much. Does `netdevsim` call `netdev_rss_key_fill`? If it doesn't, that affects my understanding of the initialization process for this kind of hardware. Let me double-check that by digging through the `netdevsim` source.



20/2 2026/09/23 18:09 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "rss.*key",
  "PathPrefix": "drivers/net/netdevsim"
}

Results:
{
  "error": "no matches"
}

21/2 2026/09/23 18:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 40925
							output: 30
							thoughts: 23
						

Thoughts:
Okay, here's my summary, tailored for an expert audience, as if it's coming directly from my own thought process:

**Diving into Network Device Simulation: RXFH and RSS**

Right, time to get my hands dirty. I'm thinking I need to jump into `drivers/net/netdevsim`. I'm going to quickly check that directory for anything related to Receive Flow Hash (`rxfh`) or Receive Side Scaling (`rss`). My immediate assumption is that there's some simulated hardware behavior in the network device simulation area, regarding traffic distribution and hashing. I'll need to figure out how they have simulated the implementation. My goal is to see how they have implemented it, and to gain insight into how it's handled in a simulated environment.



22/2 2026/09/23 18:09 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "rxfh",
  "PathPrefix": "drivers/net/netdevsim"
}

Results:
{
  "error": "no matches"
}

23/2 2026/09/23 18:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 41155
							output: 39
							thoughts: 1597
						

Thoughts:
**Investigating RSS Key Filling in Network Drivers for Syzkaller Coverage**

Okay, so I'm thinking about how `netdev_rss_key_fill` gets called within the context of syzkaller and virtualized environments. My immediate focus is on network drivers, specifically those that might be accessible or emulated within syzkaller's test runs. I've got a comprehensive list of potential drivers compiled. It's a pretty extensive list, including various Ethernet drivers from manufacturers like Intel, Mellanox, Broadcom, and others, as well as some wireless drivers, and drivers for network adapters from cloud vendors.

Initially, I'm just listing the call sites.

But then I stop and ask, "Hold on, what about virtual drivers? Are there any that would even be *calling* `netdev_rss_key_fill`?". My expertise suggests I must consider standard QEMU network adapters, or similar.

I remember that drivers like `mac80211_hwsim` (for wireless) likely aren't going to be relevant, since they aren't for the standard hypervisor.

Of course! Virtio-net, and e1000e are standard QEMU network adapters, and they are both likely to be targeted by syzkaller.

I confirm that QEMU supports both adapters. I remember that standard QEMU now supports RSS via virtio-net.

But, I must also think, "What if RSS *isn't* negotiated in a particular QEMU configuration?" I'm thinking I must evaluate both scenarios.

I then remember that virtio-net is probed at boot time by QEMU. That's good, but does syzkaller target the boot process? It is a kernel fuzzer, and so can I trigger runtime calls? I remember syzkaller targets syscalls.

The key question is: "Can syzkaller call `netdev_rss_key_fill` at runtime via those syscalls?". Can a device be bound, unbound, or can ethtool ioctls or netlink calls trigger it?

I now recall something... ethtool! I'm thinking of `drivers/net/ethernet/sfc/ethtool_common.c` and how it uses `efx_ethtool_create_rxfh_context`! But wait, sfc is specific hardware and PCIe. Not a good candidate.

I must now turn my attention to the virtio_net driver! Does it have a similar function? I now realize that I should be searching in `drivers/net/virtio_net.c`. I will check for the presence of `create_rxfh_context` or `set_rxfh`. I think there is `virtnet_set_rxfh`...



24/2 2026/09/23 18:09 tool read-file
0m Args:
{
  "File": "drivers/net/virtio_net.c",
  "FirstLine": 5570,
  "LineCount": 40
}

Results:
{
  "Contents": "5570:\t\n5571:\t\treturn 0;\n5572:\t}\n5573:\t\n5574:\tstatic int virtnet_set_rxfh(struct net_device *dev,\n5575:\t\t\t\t    struct ethtool_rxfh_param *rxfh,\n5576:\t\t\t\t    struct netlink_ext_ack *extack)\n5577:\t{\n5578:\t\tstruct virtnet_info *vi = netdev_priv(dev);\n5579:\t\tbool update = false;\n5580:\t\tint i;\n5581:\t\n5582:\t\tif (rxfh-\u003ehfunc != ETH_RSS_HASH_NO_CHANGE \u0026\u0026\n5583:\t\t    rxfh-\u003ehfunc != ETH_RSS_HASH_TOP)\n5584:\t\t\treturn -EOPNOTSUPP;\n5585:\t\n5586:\t\tif (rxfh-\u003eindir) {\n5587:\t\t\tif (!vi-\u003ehas_rss)\n5588:\t\t\t\treturn -EOPNOTSUPP;\n5589:\t\n5590:\t\t\tfor (i = 0; i \u003c vi-\u003erss_indir_table_size; ++i)\n5591:\t\t\t\tvi-\u003erss_hdr-\u003eindirection_table[i] = cpu_to_le16(rxfh-\u003eindir[i]);\n5592:\t\t\tupdate = true;\n5593:\t\t}\n5594:\t\n5595:\t\tif (rxfh-\u003ekey) {\n5596:\t\t\t/* If either _F_HASH_REPORT or _F_RSS are negotiated, the\n5597:\t\t\t * device provides hash calculation capabilities, that is,\n5598:\t\t\t * hash_key is configured.\n5599:\t\t\t */\n5600:\t\t\tif (!vi-\u003ehas_rss \u0026\u0026 !vi-\u003ehas_rss_hash_report)\n5601:\t\t\t\treturn -EOPNOTSUPP;\n5602:\t\n5603:\t\t\tmemcpy(vi-\u003erss_hash_key_data, rxfh-\u003ekey, vi-\u003erss_key_size);\n5604:\t\t\tupdate = true;\n5605:\t\t}\n5606:\t\n5607:\t\tif (update)\n5608:\t\t\tvirtnet_commit_rss_command(vi);\n5609:\t\n"
}

25/2 2026/09/23 18:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 44004
							output: 38
							thoughts: 80
						

Thoughts:
Here's my summary, as I delve into this code:

**Diving into `virtnet_set_rxfh` and RX Flow Hashing**

Okay, hold on a second. I need to understand what's happening with `virtnet_set_rxfh`. Specifically, I'm trying to figure out the scenario where `rxfh->key == NULL`. That seems odd, so I need to trace back and understand how this is handled.

Right, let me see... I recall `ethtool_set_rxfh` in `net/ethtool/ioctl.c` being the relevant function for setting Receive Side Scaling (RSS) configuration through ethtool. Let's start there. I'll open up `ethtool_set_rxfh` in `net/ethtool/ioctl.c` and dig into that function. I need to understand the control flow, the data structures being used, and, most importantly, how `rxfh->key` is populated (or not populated) within that function. I suspect the answer lies there.



26/2 2026/09/23 18:10 tool read-file
0m Args:
{
  "File": "net/ethtool/ioctl.c",
  "FirstLine": 1740,
  "LineCount": 60
}

Results:
{
  "Contents": "1740:\t\tif (rxfh.rss_context \u0026\u0026 !ops-\u003ecreate_rxfh_context)\n1741:\t\t\treturn -EOPNOTSUPP;\n1742:\t\t/* Check input data transformation capabilities */\n1743:\t\tif (rxfh.input_xfrm \u0026\u0026 rxfh.input_xfrm != RXH_XFRM_SYM_XOR \u0026\u0026\n1744:\t\t    rxfh.input_xfrm != RXH_XFRM_SYM_OR_XOR \u0026\u0026\n1745:\t\t    rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)\n1746:\t\t\treturn -EINVAL;\n1747:\t\tif (rxfh.input_xfrm != RXH_XFRM_NO_CHANGE \u0026\u0026\n1748:\t\t    rxfh.input_xfrm \u0026 ~ops-\u003esupported_input_xfrm)\n1749:\t\t\treturn -EOPNOTSUPP;\n1750:\t\tcreate = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC;\n1751:\t\n1752:\t\tif ((rxfh.indir_size \u0026\u0026\n1753:\t\t     rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE \u0026\u0026\n1754:\t\t     rxfh.indir_size != dev_indir_size) ||\n1755:\t\t    (rxfh.key_size \u0026\u0026 rxfh.key_size != dev_key_size))\n1756:\t\t\treturn -EINVAL;\n1757:\t\n1758:\t\t/* Must request at least one change: indir size, hash key, function\n1759:\t\t * or input transformation.\n1760:\t\t * There's no need for any of it in case of context creation.\n1761:\t\t */\n1762:\t\tif (!create \u0026\u0026\n1763:\t\t    (rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE \u0026\u0026\n1764:\t\t     rxfh.key_size == 0 \u0026\u0026 rxfh.hfunc == ETH_RSS_HASH_NO_CHANGE \u0026\u0026\n1765:\t\t     rxfh.input_xfrm == RXH_XFRM_NO_CHANGE))\n1766:\t\t\treturn -EINVAL;\n1767:\t\n1768:\t\tindir_bytes = dev_indir_size * sizeof(rxfh_dev.indir[0]);\n1769:\t\n1770:\t\t/* Check settings which may be global rather than per RSS-context */\n1771:\t\tif (rxfh.rss_context \u0026\u0026 !ops-\u003erxfh_per_ctx_key)\n1772:\t\t\tif (rxfh.key_size ||\n1773:\t\t\t    (rxfh.hfunc \u0026\u0026 rxfh.hfunc != ETH_RSS_HASH_NO_CHANGE) ||\n1774:\t\t\t    (rxfh.input_xfrm \u0026\u0026 rxfh.input_xfrm != RXH_XFRM_NO_CHANGE))\n1775:\t\t\t\treturn -EOPNOTSUPP;\n1776:\t\n1777:\t\trss_config = kzalloc(indir_bytes + dev_key_size, GFP_USER);\n1778:\t\tif (!rss_config)\n1779:\t\t\treturn -ENOMEM;\n1780:\t\n1781:\t\tnum_rx_rings = ethtool_get_rx_ring_count(dev);\n1782:\t\tif (num_rx_rings \u003c 0) {\n1783:\t\t\tret = num_rx_rings;\n1784:\t\t\tgoto out_free;\n1785:\t\t}\n1786:\t\n1787:\t\t/* rxfh.indir_size == 0 means reset the indir table to default (master\n1788:\t\t * context) or delete the context (other RSS contexts).\n1789:\t\t * rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE means leave it unchanged.\n1790:\t\t */\n1791:\t\tif (rxfh.indir_size \u0026\u0026\n1792:\t\t    rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE) {\n1793:\t\t\tuser_indir_len = indir_bytes;\n1794:\t\t\trxfh_dev.indir = (u32 *)rss_config;\n1795:\t\t\trxfh_dev.indir_size = dev_indir_size;\n1796:\t\t\tret = ethtool_copy_validate_indir(rxfh_dev.indir,\n1797:\t\t\t\t\t\t\t  useraddr + rss_cfg_offset,\n1798:\t\t\t\t\t\t\t  num_rx_rings,\n1799:\t\t\t\t\t\t\t  rxfh.indir_size);\n"
}

27/2 2026/09/23 18:10 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 45564
							output: 38
							thoughts: 16
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:

**Diving Back into `ethtool_set_rxfh`**

Alright, so we're circling back to `ethtool_set_rxfh`. I suppose we're picking up where we left off. Let's see what we've got. I'm expecting this function to be the core of configuring Receive Flow Hashing, which, of course, is crucial for optimizing network performance and balancing receive interrupts on multi-queue network interfaces. My intuition tells me this is where the meat of configuring the hash function type, key, and maybe the indirection table lies. I hope they are using an efficient method for making these changes, potentially something atomic or leveraging RCU to minimize disruption. Let's see if the code confirms my expectations or if it presents any interesting novel approaches. I'm eager to see how they handle potential race conditions when updating shared hardware state, and if it's all handled properly. This area can be a source of tricky bugs, so meticulous design is critical.



28/2 2026/09/23 18:10 tool read-file
0m Args:
{
  "File": "net/ethtool/ioctl.c",
  "FirstLine": 1800,
  "LineCount": 40
}

Results:
{
  "Contents": "1800:\t\t\tif (ret)\n1801:\t\t\t\tgoto out_free;\n1802:\t\t} else if (rxfh.indir_size == 0) {\n1803:\t\t\tif (rxfh.rss_context == 0) {\n1804:\t\t\t\tu32 *indir;\n1805:\t\n1806:\t\t\t\trxfh_dev.indir = (u32 *)rss_config;\n1807:\t\t\t\trxfh_dev.indir_size = dev_indir_size;\n1808:\t\t\t\tindir = rxfh_dev.indir;\n1809:\t\t\t\tfor (i = 0; i \u003c dev_indir_size; i++)\n1810:\t\t\t\t\tindir[i] =\n1811:\t\t\t\t\t\tethtool_rxfh_indir_default(i, num_rx_rings);\n1812:\t\t\t} else {\n1813:\t\t\t\trxfh_dev.rss_delete = true;\n1814:\t\t\t}\n1815:\t\t}\n1816:\t\n1817:\t\tif (rxfh.key_size) {\n1818:\t\t\trxfh_dev.key_size = dev_key_size;\n1819:\t\t\trxfh_dev.key = rss_config + indir_bytes;\n1820:\t\t\tif (copy_from_user(rxfh_dev.key,\n1821:\t\t\t\t\t   useraddr + rss_cfg_offset + user_indir_len,\n1822:\t\t\t\t\t   rxfh.key_size)) {\n1823:\t\t\t\tret = -EFAULT;\n1824:\t\t\t\tgoto out_free;\n1825:\t\t\t}\n1826:\t\t}\n1827:\t\n1828:\t\tmutex_lock(\u0026dev-\u003eethtool-\u003erss_lock);\n1829:\t\n1830:\t\tret = ethtool_check_flow_types(dev, rxfh.input_xfrm);\n1831:\t\tif (ret)\n1832:\t\t\tgoto out_unlock;\n1833:\t\n1834:\t\tif (rxfh.rss_context \u0026\u0026 rxfh_dev.rss_delete) {\n1835:\t\t\tret = ethtool_check_rss_ctx_busy(dev, rxfh.rss_context);\n1836:\t\t\tif (ret)\n1837:\t\t\t\tgoto out_unlock;\n1838:\t\t}\n1839:\t\n"
}

29/2 2026/09/23 18:10 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 46495
							output: 33
							thoughts: 3084
						

Thoughts:
**Analyzing RSS Key Initialization in Linux Kernel for Syzkaller Exploitation**

Okay, so I'm diving into this `ethtool_set_rxfh` function and realizing it doesn't directly call `netdev_rss_key_fill`. That gets me thinking, where *is* `netdev_rss_key_fill` used? I need to build a comprehensive picture, so I'm meticulously re-examining *every* call site of `netdev_rss_key_fill`. I've got a whole list now – from various Ethernet drivers like AMD's XGbE to Intel's i40e and even some virtual NICs like VMXNET3. There's a lot of hardware and virtual hardware here!

The focus turns to `virtnet_init_default_rss`. It's a key point because virtio-net is the standard network interface in QEMU, which is where Syzkaller runs. This raises the critical question: Does virtio-net probe during system boot? Yes, it does. So, since syzkaller runs in QEMU, not physical hardware, can it dynamically bind/unbind or create virtio-net devices? I know from my research, syzkaller is not a physical lab with real hardware; it's QEMU.

The `/proc/sys/net/core/netdev_rss_key` file becomes interesting. Can syzkaller read this file? Yes, it can, and the implications of this are huge. What does reading this `/proc` entry *do*? The kernel code reveals that it dumps the RSS key. A patch modifies how this key is read, potentially influencing the fuzzing.

My mind shifts to this crucial part: `netdev_rss_key_fill` and its initialization via `netdev_rss_key_init()`. This is where the core logic resides, and it uses a `DO_ONCE` construct. `DO_ONCE` executes the given code block only once during the lifetime of the system. I now understand that this `netdev_rss_key_init()` runs precisely once – the very first time any driver calls `netdev_rss_key_fill()` during boot. After that, no matter how many times `netdev_rss_key_fill()` gets called, `netdev_rss_key_init()` *never* runs again. This is vital to understanding a potential bug.

This brings up a key point. What if virtio-net (or another driver) *doesn't* call `netdev_rss_key_fill()` during boot? Can Syzkaller force it to call this function later? I have to consider all callers of `netdev_rss_key_fill` and try to understand how syzkaller might be able to trigger those drivers. I go through a laundry list of drivers and note the hardware and vendor they relate to. I quickly come to a conclusion.

Based on the Syzkaller documentation I've read, Syzkaller can't *un*bind and rebind PCI devices. That suggests `DO_ONCE` will run only when the system boots and never again. I'm going to dig into the `<linux/once.h>` header file to confirm my understanding of the `DO_ONCE` mechanism. I need to be sure.



30/2 2026/09/23 18:10 tool grepper
0m Args:
{
  "Expression": "#define DO_ONCE",
  "PathPrefix": "include/linux/once.h"
}

Results:
{
  "Output": "include/linux/once.h=17=void __do_once_sleepable_done(bool *done, struct static_key_true *once_key,\n--\ninclude/linux/once.h-45- */\ninclude/linux/once.h:46:#define DO_ONCE(func, ...)\t\t\t\t\t\t     \\\ninclude/linux/once.h-47-\t({\t\t\t\t\t\t\t\t     \\\n--\ninclude/linux/once.h-63-/* Variant of DO_ONCE() for process/sleepable contexts. */\ninclude/linux/once.h:64:#define DO_ONCE_SLEEPABLE(func, ...)\t\t\t\t\t\t\\\ninclude/linux/once.h-65-\t({\t\t\t\t\t\t\t\t\t\\\n"
}

31/2 2026/09/23 18:10 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 50506
							output: 24
							thoughts: 1800
						

Thoughts:
**WorthFuzzing Decision for netdev_rss_key**

Okay, let's break this down systematically. I see `DO_ONCE` and `func`, immediately my mind jumps to potential single-execution paths that might be missed by standard fuzzing.  Then I consider `proc_do_rss_key`. Does syzkaller even interact with this? Yes, it reads `/proc/sys/`, so that's a positive.

`proc_do_rss_key` itself looks straightforward at first glance, reading `netdev_rss_key_initialized`. It prints 0s if it's not initialized, and uses memory barriers. Not inherently complex, but the question is, is it *worth* fuzzing? My initial instinct is "no", but I need to be rigorous.

I need to apply the triage philosophy. This means carefully reading the criteria for "WorthFuzzing=false" and "WorthFuzzing=true". Section 1 emphasizes reachability.  Section 2, the negative criteria, provides clear exemptions: Documentation, user-space tools, non-executable code, unreachable hardware or execution paths.  Section 3, the positive criteria, lists what I *should* consider: Core subsystems, refactorings, assertions, and reachable drivers.

Now, let's get back to `proc_do_rss_key`. It’s connected to `netdev_rss_key_init`, `netdev_rss_key_fill`, and that's in `net/core/sysctl_net_core.c` and `net/ethtool/ioctl.c`.  Core networking. That's a strong positive signal.

But is `netdev_rss_key_init` reachable? Can syzkaller trigger it? Let's consider the boot process. Syzkaller's typical QEMU invocation uses virtio-net, right? So let's see: `tools/testing/selftests/net/netdev_rss_key.py` confirms that virtio-net does indeed interact with RSS. So, virtio-net is relevant in a virtual machine and the code executes once RSS is negotiated!

Now, does syzkaller fuzz boot-time code? No, not directly. It targets running kernels via syscalls. So, can I reach `netdev_rss_key_fill` from a syscall? That's the critical question. I need to exhaustively check *all* callers of `netdev_rss_key_fill` to see if *any* can be triggered through a syscall path. Let's start with `mana_ib_cfg_vport_steering`, and dig into its call stack and any entry points in `drivers/infiniband/hw/mana/qp.c`. This is where I begin the hunt for a fuzzer entrypoint.



32/2 2026/09/23 18:10 tool grepper
0m Args:
{
  "Expression": "mana_ib_cfg_vport_steering"
}

Results:
{
  "Output": "drivers/infiniband/hw/mana/qp.c-7-\ndrivers/infiniband/hw/mana/qp.c:8:static int mana_ib_cfg_vport_steering(struct mana_ib_dev *dev,\ndrivers/infiniband/hw/mana/qp.c-9-\t\t\t\t      struct net_device *ndev,\n--\ndrivers/infiniband/hw/mana/qp.c=78=static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd,\n--\ndrivers/infiniband/hw/mana/qp.c-237-\ndrivers/infiniband/hw/mana/qp.c:238:\tret = mana_ib_cfg_vport_steering(mdev, ndev, wq-\u003erx_object,\ndrivers/infiniband/hw/mana/qp.c-239-\t\t\t\t\t mana_ind_table,\n"
}

33/2 2026/09/23 18:10 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 53184
							output: 26
							thoughts: 1530
						

Thoughts:
**Analyzing RSS Key Initialization and Syzkaller's Reach**

Okay, let's break this down. My initial thought is that some operations require a MANA IB device, but that's not the central focus here. I'm primarily concerned with how syzkaller can interact with RSS key initialization and manipulation, specifically with `netdev_rss_key_fill` and `netdev_rss_key_init`.

I see that `efx_ethtool_create_rxfh_context` handles the Solarflare NICs, which are PCI NICs, and that userspace can't create them. Likewise, `iwl_dbgfs_indirection_tbl_write` requires an iwlwifi device. These are not promising leads for syzkaller exploitation.

My immediate thought went to `virtio_net` and USB net devices, wondering if they might be reloaded or probed in a way that would trigger the relevant functions. However, my inspection of USB net devices showed that `netdev_rss_key_fill` isn't called there.

Then, I focused on `netdev_rss_key_init`. I realized that this is tested by KUnit. However, KUnit tests are test cases, not fuzzed by syzkaller. The presence of the `CONFIG_ETHTOOL_RSS_KEY_KUNIT_TEST` configuration option and the `EXPORT_SYMBOL_IF_KUNIT` macro support this. So, KUnit is a dead end for syzkaller.

Aha! Then, I turned my attention to `/proc/sys/net/core/netdev_rss_key`. I remembered that syzkaller *can* read files under `/proc/sys/`. This means that syzkaller can trigger `proc_do_rss_key`. Looking at the code for `proc_do_rss_key`, I noticed a key change in the patch. The addition of `initialized ? netdev_rss_key[i] : 0` in the `hex_byte_pack` call combined with the `smp_rmb()` makes me think this is where the vulnerability may be.

I confirmed that these changes are in `sysctl_net_core.c`. Then, I double-checked the patch's file list: `Documentation/networking/scaling.rst`, `net/Kconfig`, `net/core/dev.h`, `net/core/sysctl_net_core.c`, `net/ethtool/Makefile`, `net/ethtool/common.h`, `net/ethtool/ioctl.c`, `net/ethtool/rss_key_test.c`, and some selftests.

Crucially, I reviewed `net/ethtool/ioctl.c` and saw the functions: `netdev_rss_key_fill`, `netdev_rss_key_init`, `netdev_rss_key_aliases`, `netdev_rss_key_window`, `netdev_rss_key_fixup_field`, `netdev_rss_key_assign_bit`, and `netdev_rss_key_bit`. The key question is whether syzkaller can *ever* trigger the execution of `netdev_rss_key_fill` or `netdev_rss_key_init` during fuzzing.

I analyzed two cases:

*   **Case A:** If a driver like virtio-net or e1000e probes at boot, `netdev_rss_key_fill` would be called, and `netdev_rss_key_init` would run *once* because of `DO_ONCE`. Syzkaller starts later. It's impossible for syzkaller to cause `netdev_rss_key_init` to run again. The `DO_ONCE` construct prevents it.

*   **Case B:** No driver calls `netdev_rss_key_fill` at boot. How could syzkaller make `netdev_rss_key_fill` be called? Can a driver be triggered during fuzzing via probe, reset, or an ethtool command that would call `netdev_rss_key_fill`?

I started checking drivers:
-   `tg3_reset_hw` requires Broadcom Tigon3 hardware. It won't work without it.
-   `e1000e_setup_rss_hash` could be a possible target. I'll need to check when it's called to decide.

My immediate focus is on whether syzkaller can manipulate `netdev_rss_key_fill` directly by inducing a driver reset or ethtool command.



34/2 2026/09/23 18:11 tool grepper
0m Args:
{
  "Expression": "e1000e_setup_rss_hash"
}

Results:
{
  "Output": "drivers/net/ethernet/intel/e1000e/netdev.c=3404=static void e1000e_set_rx_mode(struct net_device *netdev)\n--\ndrivers/net/ethernet/intel/e1000e/netdev.c-3454-\ndrivers/net/ethernet/intel/e1000e/netdev.c:3455:static void e1000e_setup_rss_hash(struct e1000_adapter *adapter)\ndrivers/net/ethernet/intel/e1000e/netdev.c-3456-{\n--\ndrivers/net/ethernet/intel/e1000e/netdev.c=3766=static void e1000_configure(struct e1000_adapter *adapter)\n--\ndrivers/net/ethernet/intel/e1000e/netdev.c-3777-\tif (adapter-\u003enetdev-\u003efeatures \u0026 NETIF_F_RXHASH)\ndrivers/net/ethernet/intel/e1000e/netdev.c:3778:\t\te1000e_setup_rss_hash(adapter);\ndrivers/net/ethernet/intel/e1000e/netdev.c-3779-\te1000_setup_rctl(adapter);\n"
}

35/2 2026/09/23 18:11 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 56101
							output: 38
							thoughts: 257
						

Thoughts:
**My Line of Inquiry: Network Device RSS Key Generation in Syzkaller Fuzzing**

Okay, so I'm trying to piece something together in my head regarding syzkaller's interaction with network devices, specifically focusing on the RSS key generation. First, I need to confirm if syzkaller even *uses* an e1000e device within QEMU during standard Linux kernel fuzzing. I should double-check the standard syzkaller VM configuration or the kernel configuration it uses. I'm pretty sure syzkaller *usually* leverages `-netdev user,id=net0,restrict=on -device virtio-net-pci,netdev=net0`.

But hold on, it’s not always so straightforward, is it? In some QEMU setups, you *might* see either e1000 or virtio-net. Now, what happens if an e1000e is present, and you end up calling `ifconfig eth0 up` or, more directly, `dev_open` on it?

That's the crux. When the interface comes up, `e1000_open` gets called, which in turn calls `e1000_configure`. And *that* function calls `e1000e_setup_rss_hash`, which is the critical function that I'm interested in because it calls `netdev_rss_key_fill`. That's where the RSS key should be getting generated.

What about virtio_net, though? I need to make sure I'm not missing anything. I need to investigate if virtio_net calls `netdev_rss_key_fill`, and where it does, or if `virtnet_probe` is the only point it might.

Okay, time to grep for `virtnet_init_default_rss` again. I need to make sure I'm not missing something in the code.



36/2 2026/09/23 18:11 tool grepper
0m Args:
{
  "Expression": "virtnet_init_default_rss",
  "PathPrefix": "drivers/net/virtio_net.c"
}

Results:
{
  "Output": "drivers/net/virtio_net.c=4228=static bool virtnet_commit_rss_command(struct virtnet_info *vi)\n--\ndrivers/net/virtio_net.c-4250-\ndrivers/net/virtio_net.c:4251:static void virtnet_init_default_rss(struct virtnet_info *vi)\ndrivers/net/virtio_net.c-4252-{\n--\ndrivers/net/virtio_net.c=6772=static int virtnet_probe(struct virtio_device *vdev)\n--\ndrivers/net/virtio_net.c-7044-\tif (vi-\u003ehas_rss || vi-\u003ehas_rss_hash_report)\ndrivers/net/virtio_net.c:7045:\t\tvirtnet_init_default_rss(vi);\ndrivers/net/virtio_net.c-7046-\n"
}

37/2 2026/09/23 18:11 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 57052
							output: 22
							thoughts: 875
						

Thoughts:
**RSS Key Initialization: A Dive into Network Driver Landscape**

Okay, so `virtnet_init_default_rss` is only called during the `virtnet_probe` function. That seems straightforward, but it makes me think... what about other drivers? Could some of them be calling `netdev_rss_key_fill` in an ethtool callback, ioctl, or netlink function? This deserves a deeper look.

First, I checked `efx_ethtool_create_rxfh_context`. Nope. That's for the Solarflare's `sfc` hardware, which Syzkaller wouldn't be able to touch. Then, I looked at `mana_ib_create_qp_rss` but MANA is also Azure hardware, and `iwl_dbgfs_indirection_tbl_write`, which is for Intel WiFi. Not relevant to this kind of fuzzer.

Okay, let's cast a wider net and consider *all* the other callers of `netdev_rss_key_fill`. It's a long list, but here's what I found: I've gone through each of them:

- AWS ENA (`ena_com_hash_key_fill_default_key`)
- AMD XGBE (`xgbe_config_netdev`)
- Broadcom bnx2x (`bnx2x_rss`) & tg3 (`tg3_reset_hw`)
- Brocade bna (`bnad_init_rx_config`)
- Cavium Thunder nicvf (`nicvf_rss_init`)
- Cisco enic (`enic_set_rsskey`)
- Emulex benet (`be_rx_qs_create`)
- Fungible funeth (`fun_init_rss`)
- Google Virtual Ethernet (GCE) (`gve_init_rss_config`)
- HiSilicon hns (`hns_ppe_init_hw`)
- Huawei hinic (`hinic_rss_init`) & hinic3 (`hinic3_rss.c`)
- Intel fm10k (`fm10k_sw_init`), i40e (`i40e_*`), iavf (`iavf_init_rss`), ice (`ice_vsi_cfg_rss_lut_key`), idpf (`idpf_vport_alloc`), igb (`igb_sw_init`), igc (`igc_sw_init`), ixgbe (`ixgbe_init_rss_key`), ixgbevf (`ixgbevf_init_rss_key`)
- Marvell otx2 (`otx2_rss_init`) and sky2 (`sky2.c`)
- Mellanox mlx4 (`mlx4_en_init_netdev`) & mlx5 (`mlx5e_rss_params_init`)
- Microsoft mana (`mana_probe_port`)
- Netronome nfp (`nfp_net_rss_init`)
- Pensando ionic (`ionic_lif_alloc`)
- QLogic qede (`qede_fill_rss_params`)
- Solarflare (`ef100_probe_netdev`, `efx_probe_nic`, `ef4_probe_nic`, `siena/efx.c`)
- stmmac (`__stmmac_dvr_probe`)
- Synopsys (`xlgmac_init`)
- Wangxun (`wx_init_rss_key`, `wx_setup_vfmrqc_vf`)
- VMware vmxnet3 (`vmxnet3_setup_driver_shared`)
- Intel WiFi (`iwlwifi`)

Okay, the list is huge, and I'm looking for where a probe or reconfiguration would call this, which would indicate a good place for fuzzing. The key here is to look for the virtual drivers.

Wait a second... *Google Virtual Ethernet* (GVE)! That's a virtual NIC on Google Compute Engine VMs! That's the one! Let's check `gve_init_rss_config` within `drivers/net/ethernet/google/gve/gve_main.c` . That is likely an interesting place to investigate. Now we have something.



38/2 2026/09/23 18:11 tool grepper
0m Args:
{
  "Expression": "gve_init_rss_config"
}

Results:
{
  "Output": "drivers/net/ethernet/google/gve/gve.h=1322=int gve_flow_rules_reset(struct gve_priv *priv);\ndrivers/net/ethernet/google/gve/gve.h-1323-/* RSS config */\ndrivers/net/ethernet/google/gve/gve.h:1324:int gve_init_rss_config(struct gve_priv *priv, u16 num_queues);\ndrivers/net/ethernet/google/gve/gve.h-1325-/* PTP and timestamping */\n--\ndrivers/net/ethernet/google/gve/gve_main.c=638=static int gve_setup_device_resources(struct gve_priv *priv)\n--\ndrivers/net/ethernet/google/gve/gve_main.c-690-\ndrivers/net/ethernet/google/gve/gve_main.c:691:\terr = gve_init_rss_config(priv, priv-\u003erx_cfg.num_queues);\ndrivers/net/ethernet/google/gve/gve_main.c-692-\tif (err) {\n--\ndrivers/net/ethernet/google/gve/gve_main.c=1397=static int gve_queues_start(struct gve_priv *priv,\n--\ndrivers/net/ethernet/google/gve/gve_main.c-1432-\tif (rx_alloc_cfg-\u003ereset_rss) {\ndrivers/net/ethernet/google/gve/gve_main.c:1433:\t\terr = gve_init_rss_config(priv, priv-\u003erx_cfg.num_queues);\ndrivers/net/ethernet/google/gve/gve_main.c-1434-\t\tif (err)\n--\ndrivers/net/ethernet/google/gve/gve_main.c=1804=static int gve_xdp(struct net_device *dev, struct netdev_bpf *xdp)\n--\ndrivers/net/ethernet/google/gve/gve_main.c-1824-\ndrivers/net/ethernet/google/gve/gve_main.c:1825:int gve_init_rss_config(struct gve_priv *priv, u16 num_queues)\ndrivers/net/ethernet/google/gve/gve_main.c-1826-{\n--\ndrivers/net/ethernet/google/gve/gve_main.c=1891=int gve_adjust_queues(struct gve_priv *priv,\n--\ndrivers/net/ethernet/google/gve/gve_main.c-1913-\tif (reset_rss) {\ndrivers/net/ethernet/google/gve/gve_main.c:1914:\t\terr = gve_init_rss_config(priv, new_rx_config.num_queues);\ndrivers/net/ethernet/google/gve/gve_main.c-1915-\t\tif (err)\n"
}

39/2 2026/09/23 18:11 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 59659
							output: 24
							thoughts: 1784
						

Thoughts:
**Fuzzing Decision for RSS Key Initialization**

Okay, let's break this down systematically. My immediate thought is, based on these instructions, I need to determine if the modified code warrants fuzzing. The key question is whether it's *reachable* code. The initial guidance says if it's unreachable, don't bother; if it's reachable and altered, then fuzz it. Seems straightforward, right?

First, I need to check the scope. Section 2 defines the *negative* criteria, the only reasons to *not* fuzz. It says "ONLY IF all modified code falls strictly into one or more of these categories." Crucially, it's an "all or nothing" proposition. If any part of this code *doesn't* fit into those categories, then it's fuzzed, by default.

Alright, the provided code modifications are within `net/ethtool/ioctl.c` and `net/core/sysctl_net_core.c`. Definitely not documentation or user-space code. The code is compiled into the kernel image (`vmlinux`), ruling out the first negative criterion.

Next, are these "structurally unreachable hardware"? No. The `net/ethtool/` and `net/core/` are core networking components. They're definitely *not* vendor-specific hardware requiring special emulation. These network subsystems are reached through `virtio_net` (emulated in standard QEMU) and `gve` (in standard GCE), and even exposed through the `/proc/sys/net/core/netdev_rss_key` sysctl interface. So, it's not the second negative criterion.

Finally, "Unreachable execution paths"? Definitely not. No driver teardown, not architecture-specific code. This is core networking. So, this code isn't structurally unreachable. It is *not* one of the negative criteria. It is *reachable*. Therefore, by default, it should be fuzzed!

Okay, let's hone in on this. Considering the functions defined in the patch, I can see `netdev_rss_key_init` could be fuzzed by syzkaller.

Let's inspect `netdev_rss_key_init`:
It looks like this function initializes the RSS (Receive Side Scaling) key. It generates a random key and performs some fixups, ensuring that there are no "aliases". The loop and calls to `netdev_rss_key_fixup_field` and `netdev_rss_key_aliases` look interesting from a fuzzing perspective, as they manipulate the key and check for certain properties.

The function `netdev_rss_key_aliases` calculates a 32-bit window and performs comparisons of windows. It uses a `windows` array defined as `u32 windows[NETDEV_RSS_KEY_LEN * BITS_PER_BYTE / 16]`.

Now, let's determine the value of `NETDEV_RSS_KEY_LEN`. I'll need to grep for this in the kernel source. The array size depends on `NETDEV_RSS_KEY_LEN`, and that's something that can potentially be manipulated during fuzzing. That may be an interesting area to probe.

So, the conclusion is clear: This code *must* be fuzzed. It's reachable code, it's part of a core networking subsystem and likely accessed via a sysctl! Now, I need to assess how I can trigger these functions within a fuzzing context and identify potential interesting parameters to vary to expose vulnerabilities.



40/2 2026/09/23 18:11 tool grepper
0m Args:
{
  "Expression": "#define NETDEV_RSS_KEY_LEN"
}

Results:
{
  "Output": "include/linux/netdevice.h=5322=void netdev_lower_state_changed(struct net_device *lower_dev,\n--\ninclude/linux/netdevice.h-5324-\ninclude/linux/netdevice.h:5325:#define NETDEV_RSS_KEY_LEN 256\ninclude/linux/netdevice.h-5326-extern u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly;\n"
}

41/2 2026/09/23 18:11 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 62364
							output: 33
							thoughts: 3657
						

Thoughts:
**Analysis of Kernel Patch for RSS Key Concurrency and Security**

Okay, here's the breakdown. I'm looking at a patch that introduces concurrency synchronization for the RSS key configuration via the `/proc/sys/net/core/netdev_rss_key` interface. `NETDEV_RSS_KEY_LEN` is 256 bytes. I've walked through the code, focusing on `netdev_rss_key_window`, `netdev_rss_key_aliases`, and the potential for out-of-bounds access. The patch focuses on synchronizing access to RSS key data between `/proc/sys/net/core/netdev_rss_key` and other kernel modules, specifically `netdev_rss_key_fill`. Crucially, I've identified that `proc_do_rss_key` and `netdev_rss_key_fill` are reachable via sysctl and from drivers such as virtio-net, respectively, which means syzkaller can potentially trigger those functions. This patch touches the core networking subsystem, and it does make logic modifications within the kernel. Therefore, according to the project's guidelines, `WorthFuzzing` must be `true`.

I'm now identifying `FocusSymbols` to guide fuzzing. These should be the specific functions that embody the changes: `proc_do_rss_key`, `netdev_rss_key_fill` and `netdev_rss_key_init`, since they are the core entry points for the feature under review. The static helper functions in `net/ethtool/ioctl.c`, even if inlined, are still relevant because they're part of the flow that's being modified. `netdev_rss_key_bit`, `netdev_rss_key_assign_bit`, `netdev_rss_key_window`, `netdev_rss_key_fixup_field`, `netdev_rss_key_aliases` are still potentially called from the main three focus symbols and are thus also worth a deeper analysis. Regarding `EnableConfigs`, I'll need to check the relevant Makefiles to determine which kernel configuration options are required to build and enable the modified code, including the KUnit test `net/ethtool/rss_key_test.c`. Also, I will investigate the callers of the modified functions, such as `virtnet_init_default_rss`, and `gve_init_rss_config`.



42/2 2026/09/23 18:11 tool read-file
0m Args:
{
  "File": "net/ethtool/Makefile",
  "FirstLine": 1,
  "LineCount": 20
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0-only\n   2:\t\n   3:\tobj-y\t\t\t\t+= ioctl.o common.o\n   4:\t\n   5:\tobj-$(CONFIG_ETHTOOL_NETLINK)\t+= ethtool_nl.o\n   6:\t\n   7:\tethtool_nl-y\t:= netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \\\n   8:\t\t\t   linkstate.o debug.o wol.o features.o privflags.o rings.o \\\n   9:\t\t\t   channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \\\n  10:\t\t\t   tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \\\n  11:\t\t\t   module.o cmis_fw_update.o cmis_cdb.o pse-pd.o plca.o \\\n  12:\t\t\t   phy.o tsconfig.o mse.o\n  13:\t\n  14:\tobj-$(CONFIG_ETHTOOL_RSS_KEY_KUNIT_TEST)\t+= rss_key_test.o\n"
}

43/2 2026/09/23 18:11 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 66884
							output: 26
							thoughts: 43
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Investigating the Build Configuration for net/ethtool/ioctl.o**

Alright, so `net/ethtool/ioctl.o` is flagged as `obj-y`. That's the key indicator – it's going to be *built* as part of this particular target. The inclusion in `obj-y` means that the kernel build system will unconditionally include the object file. That's good, but it immediately raises a question in my mind: What actually triggers the *inclusion* of this code in the first place? It's not necessarily a module if it's in `obj-y`. It could be a static component of a larger subsystem, but what enables `net/ethtool/` itself to be part of the final image or a loaded module?

The logical next step is to go straight to the source, the `net/Makefile`. I need to figure out the dependencies and conditional build flags that control the compilation of that directory. I need to understand how `ethtool` is being integrated within the larger networking stack. It's almost certain that the `Makefile` in the `net/` directory will specify which components are built based on various kernel configuration options. I'll be looking for `Kconfig` symbols or conditionals that directly relate to `net/ethtool/`. From there, I'll be able to trace how this specific object file gets pulled in, depending on the kernel configuration.



44/2 2026/09/23 18:11 tool grepper
0m Args:
{
  "Expression": "ethtool",
  "PathPrefix": "net/Makefile"
}

Results:
{
  "Output": "net/Makefile=14=obj-$(CONFIG_LLC)\t\t+= llc/\nnet/Makefile:15:obj-y\t\t\t\t+= ethernet/ 802/ sched/ netlink/ bpf/ ethtool/\nnet/Makefile-16-obj-$(CONFIG_NETFILTER)\t\t+= netfilter/\n"
}

45/2 2026/09/23 18:11 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 67360
							output: 31
							thoughts: 46
						

Thoughts:
Here's my thought process, as requested:

**Navigating the Linux Networking Codebase**

Okay, so I see a reference to `ethtool` within `net/Makefile`. Right, that's expected. `obj-y += ... ethtool/` means it's being compiled into the kernel. Now, where else might ethtool's influence be? My initial thought is `net/core/sysctl_net_core.c`. These sysctl files often contain knobs for various networking parameters, and given `ethtool` interacts with driver settings, it's a likely place for related configurations. But I should confirm what is included in the net/core sub directory. Let's quickly check `net/core/Makefile` to see what is built. That should give me a good overview of what's tied into the core networking subsystem there.



46/2 2026/09/23 18:11 tool grepper
0m Args:
{
  "Expression": "sysctl_net_core",
  "PathPrefix": "net/core/Makefile"
}

Results:
{
  "Output": "net/core/Makefile=6=obj-y := sock.o skbuff.o datagram.o stream.o scm.o \\\n--\nnet/core/Makefile-9-\nnet/core/Makefile:10:obj-$(CONFIG_SYSCTL) += sysctl_net_core.o\nnet/core/Makefile-11-\n"
}

47/2 2026/09/23 18:11 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 67715
							output: 30
							thoughts: 398
						

Thoughts:
**Analyzing Network Configuration Dependencies**

Okay, let's break this down. I see that `obj-$(CONFIG_SYSCTL) += sysctl_net_core.o` is in play, and that `NET` also brings in `net/Makefile`. I need to figure out the interplay between these and specific configurations, like `CONFIG_ETHTOOL_RSS_KEY_KUNIT_TEST`.

I'll check `net/Kconfig` for that: Ah, `CONFIG_ETHTOOL_RSS_KEY_KUNIT_TEST` is a tristate, depending on `KUNIT` and defaulting to `KUNIT_ALL_TESTS`. It's essentially KUnit tests for RSS key generation. I also want to investigate `VIRTIO_NET`.

Now, looking at `drivers/net/Kconfig`, I see `CONFIG_VIRTIO_NET`. The key now seems to be how these all interact. I'll double-check `CONFIG_SYSCTL` and `CONFIG_NET`. Then, I'll go back to the `net/ethtool/ioctl.c` file. I see the function `netdev_rss_key_init(u8 *key, size_t len)` and how `VISIBLE_IF_KUNIT` makes this visible if KUnit is enabled. This is important!

Hmm, is `CONFIG_SYSCTL` actually required for `proc_do_rss_key`? Yes, `sysctl_net_core.o` depends on `CONFIG_SYSCTL`. And, of course, on `CONFIG_NET`. Good.

I circle back to `CONFIG_VIRTIO_NET`. Let's see... the virtio net driver initializes default RSS if the hardware supports it. Specifically, it calls `virtnet_init_default_rss`, which in turn calls `netdev_rss_key_fill`. So, this `netdev_rss_key_fill` function is called and then exposed through the KUnit test, and `CONFIG_SYSCTL` is required. I need to now check if `CONFIG_VIRTIO_NET` itself depends on `VIRTIO`, as that's a key piece of the puzzle.



48/2 2026/09/23 18:12 tool grepper
0m Args:
{
  "Expression": "config VIRTIO_NET",
  "PathPrefix": "drivers/net/"
}

Results:
{
  "Output": "drivers/net/Kconfig=435=config VETH\n--\ndrivers/net/Kconfig-442-\ndrivers/net/Kconfig:443:config VIRTIO_NET\ndrivers/net/Kconfig-444-\ttristate \"Virtio network driver\"\n"
}

49/2 2026/09/23 18:12 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 68697
							output: 34
							thoughts: 19
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and presented as if it were my own internal monologue:

**Investigating a Network Driver Configuration**

Alright, I'm diving into a configuration issue, and my instinct is leading me towards the `drivers/net/Kconfig` file. Specifically, I'm honing in on line 443. My experience tells me that's a likely spot for a configuration option or dependency related to the network driver(s) I'm currently focused on. I'm probably looking for a specific symbol definition, perhaps a conditional statement, or a dependency check that's relevant to the problematic behavior I'm troubleshooting. This file is often a critical junction for understanding how various network features and drivers are enabled and interact. I'll need to rapidly parse the Kconfig syntax and understand the logic around that line to identify the potential root cause. I'm expecting to find a conditional that’s either incorrectly set or that I can tweak to rectify the situation.



50/2 2026/09/23 18:12 tool read-file
0m Args:
{
  "File": "drivers/net/Kconfig",
  "FirstLine": 442,
  "LineCount": 10
}

Results:
{
  "Contents": " 442:\t\n 443:\tconfig VIRTIO_NET\n 444:\t\ttristate \"Virtio network driver\"\n 445:\t\tdepends on VIRTIO\n 446:\t\tselect NET_FAILOVER\n 447:\t\tselect DIMLIB\n 448:\t\tselect PAGE_POOL\n 449:\t\thelp\n 450:\t\t  This is the virtual network driver for virtio.  It can be used with\n 451:\t\t  QEMU based VMMs (like KVM or Xen).  Say Y or M.\n"
}

51/2 2026/09/23 18:12 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 69120
							output: 280
							thoughts: 606
						

Thoughts:
**My Assessment of the Patch's Reach and Fuzzing Suitability**

Okay, let's break this down systematically. First, I need to confirm the dependencies. `CONFIG_VIRTIO_NET` hinges on `CONFIG_VIRTIO` – check. `CONFIG_SYSCTL` is standard, so that's covered. Now, `CONFIG_ETHTOOL_NETLINK` – let's see... in `net/ethtool/Makefile`, `ioctl.o` is built with `obj-y`, and `sysctl_net_core.c` utilizes `CONFIG_SYSCTL`. And, of course, `NET` is standard. Excellent.

Now, a quick double-check on requirements. My EnableConfigs are `NET`, `SYSCTL`, and `VIRTIO_NET`. I've also identified my FocusSymbols: `proc_do_rss_key`, `netdev_rss_key_fill`, `netdev_rss_key_init`, `netdev_rss_key_fixup_field`, and `netdev_rss_key_aliases`.

Wait a minute, are `netdev_rss_key_fixup_field` and `netdev_rss_key_aliases` really the best FocusSymbols? I need to consider if the compiler could potentially inline those, or if they're static. Let's dig deeper. `netdev_rss_key_aliases` has nested loops, so it's quite involved. `netdev_rss_key_fixup_field` is called within a loop in `netdev_rss_key_init`. Okay, including them along with `netdev_rss_key_init`, `netdev_rss_key_fill`, and `proc_do_rss_key` is highly targeted and precise.

Now, let's review the reasoning to ensure it's airtight. Essentially, the patch is touching core networking code, specifically in `net/ethtool/ioctl.c` and `net/core/sysctl_net_core.c`. It's fundamentally changing how the RSS hash key is generated via `netdev_rss_key_fill()` by introducing a deterministic fixup algorithm involving `netdev_rss_key_init()`, `netdev_rss_key_fixup_field()`, and `netdev_rss_key_aliases()` to ensure Toeplitz hash non-singularity across queues. The patch also updates the `/proc/sys/net/core/netdev_rss_key` sysctl reporting (`proc_do_rss_key()`) with synchronization primitives. This is *crucial* – this code executes in virtualized environments like QEMU with virtio-net or GCE with gve, and it's exposed to userspace via the sysctl interface, which makes it an ideal target for fuzzing. It's reachable, and that's the key.

Yep, the picture is clear. It's a solid assessment that hits all the right points. The reasoning is sound, the targets are well-defined, and the fuzzing is justified. I'm ready to proceed. Let's call `set-results`.



52/2 2026/09/23 18:12 tool set-results
0m Args:
{
  "EnableConfigs": [
    "NET",
    "SYSCTL",
    "VIRTIO_NET"
  ],
  "FocusSymbols": [
    "proc_do_rss_key",
    "netdev_rss_key_fill",
    "netdev_rss_key_init",
    "netdev_rss_key_aliases",
    "netdev_rss_key_fixup_field"
  ],
  "Reasoning": "The patch introduces new algorithmic key generation and alias-checking logic in net/ethtool/ioctl.c (netdev_rss_key_init(), netdev_rss_key_fixup_field(), netdev_rss_key_aliases()) used by netdev_rss_key_fill() to generate non-singular Toeplitz RSS keys. It also updates the procfs sysctl handler proc_do_rss_key() in net/core/sysctl_net_core.c with memory barriers and initialization state tracking. Because this touches core networking logic reachable via virtual network drivers (e.g. virtio_net in QEMU, gve in GCE) as well as the /proc/sys/net/core/netdev_rss_key sysctl interface, it touches reachable executable code and warrants fuzzing.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "NET",
    "SYSCTL",
    "VIRTIO_NET"
  ],
  "FocusSymbols": [
    "proc_do_rss_key",
    "netdev_rss_key_fill",
    "netdev_rss_key_init",
    "netdev_rss_key_aliases",
    "netdev_rss_key_fixup_field"
  ],
  "Reasoning": "The patch introduces new algorithmic key generation and alias-checking logic in net/ethtool/ioctl.c (netdev_rss_key_init(), netdev_rss_key_fixup_field(), netdev_rss_key_aliases()) used by netdev_rss_key_fill() to generate non-singular Toeplitz RSS keys. It also updates the procfs sysctl handler proc_do_rss_key() in net/core/sysctl_net_core.c with memory barriers and initialization state tracking. Because this touches core networking logic reachable via virtual network drivers (e.g. virtio_net in QEMU, gve in GCE) as well as the /proc/sys/net/core/netdev_rss_key sysctl interface, it touches reachable executable code and warrants fuzzing.",
  "WorthFuzzing": true
}

53/1 2026/09/23 18:12 action If
2m Args:
{
  "WorthFuzzing": true
}

Results:
null

54/2 2026/09/23 18:12 agent kmsan-evaluator
2m Model:
core

Args:
null

Results:
{
  "KMSANReasoning": "The patch series enhances the Toeplitz RSS key generation in netdev_rss_key_fill() to ensure non-singularity and avoid collisions across receive queues, adds associated sysctl synchronization, and introduces KUnit and selftests.\n\nAnalysis of uninitialized memory and information leak risks:\n1. All buffers and arrays introduced or modified are properly initialized:\n   - In `netdev_rss_key_init()`, `get_random_bytes()` initializes the entire key buffer before any fixup operations are performed.\n   - The stack array `d` in `netdev_rss_key_fixup_field()` is completely populated in an initial loop prior to any reads.\n   - In `netdev_rss_key_aliases()`, stack array `windows` is populated sequentially up to `n`, and only elements in range `[0, n)` are subsequently read.\n   - In `proc_do_rss_key()`, the output string buffer `buf` is completely written with hex bytes and a null terminator before being passed to `proc_dostring()`. Furthermore, an explicit `netdev_rss_key_initialized` barrier prevents reading `netdev_rss_key` prior to initialization.\n   - The KUnit tests use zero-initialized memory allocations (`kunit_kzalloc` / `kunit_kcalloc`).\n2. No kernel structures with padding or uninitialized fields are exposed or copied to user space.\n3. No conditional branches or control flow decisions rely on uninitialized values.\n\nAny potential bounds or overflow issues would be covered by standard KASAN/UBSAN builds. A dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Instruction:
You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.

CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
  a comprehensive suite of debugging tools and sanitizers, including KASAN
  (out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
  (locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
  or page allocations) and kernel-to-user memory info-leaks.

Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.

Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.

Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
   attributes, ioctl output arguments, socket options, or BPF buffers) where fields
   or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
   or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
   could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
   uninitialized bytes of existing buffers.

Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
  dereferences, locking deadlocks, or use-after-free bugs (these are already caught
  by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
  or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.

Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 8db3b7dacd5116913755365bd01f62cd92bd07bd
Author: syz-cluster <triage@syzkaller.com>
Date:   Wed Sep 23 18:08:13 2026 +0000

    syz-cluster: applied patch under review

diff --git a/Documentation/networking/scaling.rst b/Documentation/networking/scaling.rst
index 6c261eb48845a..6c9836000a8d1 100644
--- a/Documentation/networking/scaling.rst
+++ b/Documentation/networking/scaling.rst
@@ -48,6 +48,15 @@ count is not a power of two. NICs should provide an indirection table
 at least 4 times larger than the queue count. 4x table results in ~16%
 imbalance between the queues, which is acceptable for most applications.
 
+The Toeplitz hash is linear over GF(2), so the quality of the hash key
+matters as much as its randomness. For a key made of uniformly random
+bytes, the q lowest order bits of a given header field fail to spread
+flows over all 2^q queues with probability 1/2, and a burst of connections
+picking nearly consecutive ephemeral ports then lands on a fraction of the
+queues while the others stay idle. The netdev_rss_key_fill() helper draws
+a random key that is free of this defect; drivers should use it rather
+than seeding a key of their own.
+
 Some NICs support symmetric RSS hashing where, if the IP (source address,
 destination address) and TCP/UDP (source port, destination port) tuples
 are swapped, the computed hash is the same. This is beneficial in some
diff --git a/net/Kconfig b/net/Kconfig
index e384773935515..4a8dc0e5b075a 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -540,4 +540,18 @@ config NET_TEST
 
 	  If unsure, say N.
 
+config ETHTOOL_RSS_KEY_KUNIT_TEST
+	tristate "KUnit tests for the generated RSS key" if !KUNIT_ALL_TESTS
+	depends on KUNIT
+	default KUNIT_ALL_TESTS
+	help
+	  KUnit tests checking the RSS key that netdev_rss_key_fill() hands
+	  to the drivers: flows differing only in the low order bits of one
+	  hashed header field have to spread over all the RX queues, for
+	  every field of the Toeplitz hash inputs, for every 16-bit aligned
+	  position of the key, and for every queue count up to
+	  2 ** NETDEV_RSS_KEY_QMAX.
+
+	  If unsure, say N.
+
 endif   # if NET
diff --git a/net/core/dev.h b/net/core/dev.h
index b757faead4d1a..0127b4d03e525 100644
--- a/net/core/dev.h
+++ b/net/core/dev.h
@@ -95,6 +95,7 @@ extern int		netdev_unregister_timeout_secs;
 extern int		weight_p;
 extern int		dev_weight_rx_bias;
 extern int		dev_weight_tx_bias;
+extern bool		netdev_rss_key_initialized;
 
 extern struct rw_semaphore dev_addr_sem;
 
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 23310581f4945..e30219765db39 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -338,9 +338,14 @@ static int proc_do_rss_key(const struct ctl_table *table, int write,
 	char buf[NETDEV_RSS_KEY_LEN * 3];
 	struct ctl_table fake_table;
 	char *pos = buf;
+	bool initialized;
+
+	initialized = READ_ONCE(netdev_rss_key_initialized);
+	/* Pair with smp_wmb() in netdev_rss_key_fill(). */
+	smp_rmb();
 
 	for (int i = 0; i < NETDEV_RSS_KEY_LEN; i++) {
-		pos = hex_byte_pack(pos, netdev_rss_key[i]);
+		pos = hex_byte_pack(pos, initialized ? netdev_rss_key[i] : 0);
 		*pos++ = ':';
 	}
 	*(--pos) = 0;
diff --git a/net/ethtool/Makefile b/net/ethtool/Makefile
index 629c10916670e..6588cfe652810 100644
--- a/net/ethtool/Makefile
+++ b/net/ethtool/Makefile
@@ -10,3 +10,5 @@ ethtool_nl-y	:= netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \
 		   tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \
 		   module.o cmis_fw_update.o cmis_cdb.o pse-pd.o plca.o \
 		   phy.o tsconfig.o mse.o
+
+obj-$(CONFIG_ETHTOOL_RSS_KEY_KUNIT_TEST)	+= rss_key_test.o
diff --git a/net/ethtool/common.h b/net/ethtool/common.h
index 4e5356e26f400..c1b6191f45693 100644
--- a/net/ethtool/common.h
+++ b/net/ethtool/common.h
@@ -15,6 +15,17 @@
 #define __SOF_TIMESTAMPING_CNT (const_ilog2(SOF_TIMESTAMPING_LAST) + 1)
 #define __HWTSTAMP_FLAG_CNT (const_ilog2(HWTSTAMP_FLAG_LAST) + 1)
 
+/* netdev_rss_key_fill() guarantees that flows differing only in the low order
+ * bits of one hashed header field spread over all the RX queues, for any queue
+ * count up to 2 ** NETDEV_RSS_KEY_QMAX and any 16-bit aligned field of the
+ * hash input. See netdev_rss_key_init().
+ */
+#define NETDEV_RSS_KEY_QMAX	8
+
+#if IS_ENABLED(CONFIG_KUNIT)
+void netdev_rss_key_init(u8 *key, size_t len);
+#endif
+
 struct genl_info;
 struct hwtstamp_provider_desc;
 
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 4b0bc503f9307..e625175ed1cbd 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -25,15 +25,20 @@
 #include <linux/rtnetlink.h>
 #include <linux/sched/signal.h>
 #include <linux/net.h>
+#include <linux/once.h>
 #include <linux/pm_runtime.h>
+#include <linux/random.h>
+#include <linux/unaligned.h>
 #include <linux/utsname.h>
 #include <linux/ethtool_netlink.h>
+#include <kunit/visibility.h>
 #include <net/devlink.h>
 #include <net/ipv6.h>
 #include <net/flow_offload.h>
 #include <net/netdev_lock.h>
 #include <net/netdev_queues.h>
 
+#include "../core/dev.h"
 #include "common.h"
 
 /* State held across locks and calls for commands which have devlink fallback */
@@ -1302,11 +1307,174 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,
 }
 
 u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly;
+bool netdev_rss_key_initialized __read_mostly;
+
+/* Toeplitz is linear over GF(2): the hash is the XOR of the 32-bit key
+ * windows selected by the set bits of the input, and hardware indexes the
+ * indirection table with the low order bits of the hash. Only the tail of
+ * each window therefore matters for queue selection:
+ *
+ *	v(i) = key bits [i + 32 - q .. i + 31]
+ *
+ * for input bit @i, with q = log2(number of RX queues). Consecutive input
+ * bits give windows overlapping in q - 1 positions, so the matrix formed by
+ * the windows of the q lowest bits of a header field is a Toeplitz matrix
+ * built from 2 * q - 1 key bits, not from q * q independent ones. A random
+ * Toeplitz matrix over GF(2) is singular with probability 1/2, whatever its
+ * size, and when it is singular the flows of a burst differing only in the
+ * low order bits of that field (consecutive ephemeral ports, typically)
+ * cannot reach all the RX queues no matter how many of them are configured.
+ *
+ * Keep the key random, but constrain the few bits that decide this. The
+ * fixup is applied at every 16-bit aligned position of the key, rather than
+ * at the offsets of the one hash input layout the software happens to know
+ * about: hardware is free to hash whatever it wants, but the fields it picks
+ * are 16 bits wide at the smallest and are not expected to straddle that
+ * grid, so an encapsulated or offloaded layout is covered like the usual
+ * 2-tuple and 4-tuple ones. Each position constrains 2 * q - 1 bits, so
+ * NETDEV_RSS_KEY_QMAX is both enough for 256 queues and the largest value
+ * keeping the ranges of two adjacent positions disjoint.
+ */
+#define NETDEV_RSS_KEY_SPAN	(2 * NETDEV_RSS_KEY_QMAX - 1)
+
+static bool netdev_rss_key_bit(const u8 *key, unsigned int bit)
+{
+	return key[bit / BITS_PER_BYTE] & (0x80 >> (bit % BITS_PER_BYTE));
+}
+
+static void netdev_rss_key_assign_bit(u8 *key, unsigned int bit, bool value)
+{
+	u8 mask = 0x80 >> (bit % BITS_PER_BYTE);
+
+	if (value)
+		key[bit / BITS_PER_BYTE] |= mask;
+	else
+		key[bit / BITS_PER_BYTE] &= ~mask;
+}
+
+/* Writing d[t] for key bit (@lsb + 31 - t), the matrices of all the q values
+ * up to NETDEV_RSS_KEY_QMAX are non singular if and only if
+ *
+ *	d[2 * i] = 1 ^ d[i] ^ d[i + 1] ^ ... ^ d[2 * i - 1]
+ *
+ * The odd positions stay free, so this is a one pass fixup rather than a
+ * search. It is also a bijection onto the set of the values having the
+ * property, so the key stays uniformly distributed over that set. It costs
+ * NETDEV_RSS_KEY_QMAX bits of entropy per position.
+ */
+static void netdev_rss_key_fixup_field(u8 *key, unsigned int lsb)
+{
+	bool d[NETDEV_RSS_KEY_SPAN];
+	unsigned int i, t;
+
+	for (t = 0; t < NETDEV_RSS_KEY_SPAN; t++)
+		d[t] = netdev_rss_key_bit(key, lsb + 31 - t);
+
+	for (i = 0; 2 * i < NETDEV_RSS_KEY_SPAN; i++) {
+		bool value = true;
+
+		for (t = i; t < 2 * i; t++)
+			value ^= d[t];
+
+		d[2 * i] = value;
+	}
+
+	for (t = 0; t < NETDEV_RSS_KEY_SPAN; t++)
+		netdev_rss_key_assign_bit(key, lsb + 31 - t, d[t]);
+}
+
+/* The 32 key bits starting at @bit, which is what input bit @bit contributes
+ * to the hash. @bit + 32 must fit in the key.
+ */
+static u32 netdev_rss_key_window(const u8 *key, unsigned int bit)
+{
+	unsigned int byte = bit / BITS_PER_BYTE;
+	unsigned int shift = bit % BITS_PER_BYTE;
+	u32 window = get_unaligned_be32(key + byte);
+
+	if (shift)
+		window = (window << shift) |
+			 (key[byte + 4] >> (BITS_PER_BYTE - shift));
+
+	return window;
+}
+
+/* Two input bits contributing the same window are indistinguishable to the
+ * hash, since flipping both of them leaves it unchanged. For a uniformly
+ * random key that is a 2 ** -32 event per pair of positions, but the fixup
+ * makes it likelier: it derives 8 of every 16 bits from the 8 others, so a
+ * 16-bit aligned word only takes 2 ** 8 values and two windows a whole
+ * number of words apart collide with probability 2 ** -16 instead. Half a
+ * word apart is less affected but still well clear of the random odds, so
+ * cover every distance that is a multiple of 8. What is left after that is
+ * below what a plain random key gives.
+ *
+ * Two windows at a distance that is a multiple of 8 are two windows at the
+ * same offset modulo 8. Caching a whole class would put 253 u32 on the
+ * stack, so cache one class modulo 16 and stream the class 8 bits above it
+ * against it.
+ */
+static bool netdev_rss_key_aliases(const u8 *key, unsigned int bits)
+{
+	u32 windows[NETDEV_RSS_KEY_LEN * BITS_PER_BYTE / 16];
+	unsigned int i, j, n, r;
+
+	for (r = 0; r < 16; r++) {
+		n = 0;
+		for (i = r; i + 32 <= bits; i += 16)
+			windows[n++] = netdev_rss_key_window(key, i);
+
+		for (i = 0; i < n; i++)
+			for (j = i + 1; j < n; j++)
+				if (windows[i] == windows[j])
+					return true;
+
+		if (r >= 8)
+			continue;
+
+		for (i = r + 8; i + 32 <= bits; i += 16) {
+			u32 window = netdev_rss_key_window(key, i);
+
+			for (j = 0; j < n; j++)
+				if (windows[j] == window)
+					return true;
+		}
+	}
+
+	return false;
+}
+
+VISIBLE_IF_KUNIT void netdev_rss_key_init(u8 *key, size_t len)
+{
+	unsigned int lsb, bits = len * BITS_PER_BYTE;
+
+	/* Four keys out of five come out of the fixup free of aliases, so
+	 * drawing another one is both simpler and cheaper than repairing.
+	 */
+	do {
+		get_random_bytes(key, len);
+
+		/* A field ending at bit @lsb uses key bits [.. , @lsb + 31],
+		 * so stop as soon as a 32-bit window no longer fits in the
+		 * key.
+		 */
+		for (lsb = 15; lsb + 32 <= bits; lsb += 16)
+			netdev_rss_key_fixup_field(key, lsb);
+	} while (netdev_rss_key_aliases(key, bits));
+
+	if (key != netdev_rss_key)
+		return;
+
+	/* Pair with smp_rmb() in proc_do_rss_key(). */
+	smp_wmb();
+	WRITE_ONCE(netdev_rss_key_initialized, true);
+}
+EXPORT_SYMBOL_IF_KUNIT(netdev_rss_key_init);
 
 void netdev_rss_key_fill(void *buffer, size_t len)
 {
 	BUG_ON(len > sizeof(netdev_rss_key));
-	net_get_random_once(netdev_rss_key, sizeof(netdev_rss_key));
+	DO_ONCE(netdev_rss_key_init, netdev_rss_key, sizeof(netdev_rss_key));
 	memcpy(buffer, netdev_rss_key, len);
 }
 EXPORT_SYMBOL(netdev_rss_key_fill);
diff --git a/net/ethtool/rss_key_test.c b/net/ethtool/rss_key_test.c
new file mode 100644
index 0000000000000..1a583f2930c5b
--- /dev/null
+++ b/net/ethtool/rss_key_test.c
@@ -0,0 +1,314 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Tests for the RSS key generated by netdev_rss_key_fill().
+ *
+ * The property under test is that flows differing only in the low order bits
+ * of one hashed header field land on distinct RX queues. It is checked here
+ * from the definition of the Toeplitz hash, independently of the way
+ * netdev_rss_key_init() achieves it.
+ */
+
+#include <kunit/test.h>
+#include <linux/module.h>
+#include <linux/random.h>
+#include <linux/sort.h>
+
+#include "common.h"
+
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+
+/* Longest hash input exercised here: an IPv6 header, a UDP header, a PSP
+ * header and the inner TCP ports. See rss_key_test_fields[].
+ */
+#define RSS_KEY_TEST_INPUT_LEN		68
+
+#define RSS_KEY_TEST_KEYS		32
+
+/* Number of queue counts exercised end to end by rss_key_spread_test(), which
+ * hashes 2 ** q inputs for each of them. The algebraic check covers all the
+ * queue counts up to NETDEV_RSS_KEY_QMAX.
+ */
+#define RSS_KEY_TEST_SPREAD_QMAX	6
+
+/* Position of the least significant bit of each field, counting from the most
+ * significant bit of the hash input, and the length of that input. These come
+ * from the definition of the hash, not from the key generator.
+ */
+static const struct rss_key_test_field {
+	const char	*name;
+	unsigned int	lsb;
+	unsigned int	nbits;
+} rss_key_test_fields[] = {
+	{ "IPv4 saddr",		31,	96 },
+	{ "IPv4 daddr",		63,	96 },
+	{ "IPv4 sport",		79,	96 },
+	{ "IPv4 dport",		95,	96 },
+	{ "IPv6 saddr",		127,	288 },
+	{ "IPv6 daddr",		255,	288 },
+	{ "IPv6 sport",		271,	288 },
+	{ "IPv6 dport",		287,	288 },
+	/* Hardware is free to hash an encapsulated header instead, and then
+	 * it reads the key far past the 40 bytes an IPv6 4-tuple needs. These
+	 * offsets are those of PSP transport mode over UDP over IPv6
+	 * (Documentation/networking/psp.rst): 40 bytes of IPv6, 8 of UDP,
+	 * PSP_HDR_SIZE of PSP, then the inner TCP ports. Prepending an
+	 * Ethernet header, or the 4 extra bytes of an encapsulation tag,
+	 * shifts all of this by a whole number of 16-bit units.
+	 */
+	{ "PSP outer IPv6 saddr",	191,	544 },
+	{ "PSP outer IPv6 daddr",	319,	544 },
+	{ "PSP inner sport",		527,	544 },
+	{ "PSP inner dport",		543,	544 },
+};
+
+static bool rss_key_test_bit(const u8 *buf, unsigned int bit)
+{
+	return buf[bit / BITS_PER_BYTE] & (0x80 >> (bit % BITS_PER_BYTE));
+}
+
+static void rss_key_test_assign_bit(u8 *buf, unsigned int bit, bool value)
+{
+	u8 mask = 0x80 >> (bit % BITS_PER_BYTE);
+
+	if (value)
+		buf[bit / BITS_PER_BYTE] |= mask;
+	else
+		buf[bit / BITS_PER_BYTE] &= ~mask;
+}
+
+/* The 32 key bits starting at @bit, which is what input bit @bit contributes
+ * to the hash.
+ */
+static u32 rss_key_test_window(const u8 *key, unsigned int bit)
+{
+	u32 window = 0;
+	unsigned int i;
+
+	for (i = 0; i < 32; i++)
+		window = (window << 1) | rss_key_test_bit(key, bit + i);
+
+	return window;
+}
+
+static u32 rss_key_test_toeplitz(const u8 *key, const u8 *input,
+				 unsigned int nbits)
+{
+	u32 hash = 0;
+	unsigned int i;
+
+	for (i = 0; i < nbits; i++)
+		if (rss_key_test_bit(input, i))
+			hash ^= rss_key_test_window(key, i);
+
+	return hash;
+}
+
+/* Is the map from the q low order bits of the field at @lsb to the q low order
+ * bits of the hash a bijection? Gaussian elimination over GF(2) on the q
+ * windows involved, reduced to their q low order bits.
+ */
+static bool rss_key_test_full_rank(const u8 *key, unsigned int lsb,
+				   unsigned int q)
+{
+	u32 basis[NETDEV_RSS_KEY_QMAX] = {};
+	unsigned int j;
+
+	for (j = 0; j < q; j++) {
+		u32 v = rss_key_test_window(key, lsb - j) & (BIT(q) - 1);
+
+		while (v) {
+			unsigned int b = __ffs(v);
+
+			if (!basis[b]) {
+				basis[b] = v;
+				break;
+			}
+			v ^= basis[b];
+		}
+
+		if (!v)
+			return false;
+	}
+
+	return true;
+}
+
+/* Degenerate keys the rank check must reject, so that a check accepting
+ * everything can not make the other tests pass.
+ */
+static void rss_key_checker_test(struct kunit *test)
+{
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+
+	KUNIT_ASSERT_NOT_NULL(test, key);
+
+	/* All the windows are zero. */
+	KUNIT_EXPECT_FALSE(test, rss_key_test_full_rank(key, 31, 1));
+
+	/* All the windows are equal, which is enough for one queue only. */
+	memset(key, 0xff, NETDEV_RSS_KEY_LEN);
+	KUNIT_EXPECT_TRUE(test, rss_key_test_full_rank(key, 31, 1));
+	KUNIT_EXPECT_FALSE(test, rss_key_test_full_rank(key, 31, 2));
+}
+
+static void rss_key_property_test(struct kunit *test)
+{
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+	unsigned int i, j, q;
+
+	KUNIT_ASSERT_NOT_NULL(test, key);
+
+	for (i = 0; i < RSS_KEY_TEST_KEYS; i++) {
+		netdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);
+
+		for (j = 0; j < ARRAY_SIZE(rss_key_test_fields); j++) {
+			const struct rss_key_test_field *f;
+
+			f = &rss_key_test_fields[j];
+
+			for (q = 1; q <= NETDEV_RSS_KEY_QMAX; q++)
+				KUNIT_ASSERT_TRUE_MSG(test,
+						      rss_key_test_full_rank(key, f->lsb, q),
+						      "%s does not spread over %u queues",
+						      f->name, 1U << q);
+		}
+	}
+}
+
+/* rss_key_test_fields[] can only list the layouts somebody thought of, but
+ * the generator does not get to know what the hardware hashes. Sweep the
+ * whole key instead: the property has to hold at every 16-bit aligned
+ * position, which is where a field of any layout can end.
+ */
+static void rss_key_grid_test(struct kunit *test)
+{
+	unsigned int bits = NETDEV_RSS_KEY_LEN * BITS_PER_BYTE;
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+	unsigned int i, lsb, q;
+
+	KUNIT_ASSERT_NOT_NULL(test, key);
+
+	for (i = 0; i < RSS_KEY_TEST_KEYS; i++) {
+		netdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);
+
+		for (lsb = 15; lsb + 32 <= bits; lsb += 16)
+			for (q = 1; q <= NETDEV_RSS_KEY_QMAX; q++)
+				KUNIT_ASSERT_TRUE_MSG(test,
+						      rss_key_test_full_rank(key, lsb, q),
+						      "field ending at bit %u does not spread over %u queues",
+						      lsb, 1U << q);
+	}
+}
+
+static int rss_key_test_cmp(const void *a, const void *b)
+{
+	u32 x = *(const u32 *)a, y = *(const u32 *)b;
+
+	return x < y ? -1 : x > y;
+}
+
+/* Two input bits contributing the same 32-bit window are indistinguishable
+ * to the hash: flipping both of them leaves it unchanged, so the flows of a
+ * burst differing in exactly those two bits all collide. A uniformly random
+ * key has such a pair with probability 2 ** -11, and the generated key must
+ * not do worse.
+ *
+ * netdev_rss_key_init() redraws on a collision at a distance that is a
+ * multiple of 8, which is where the fixup makes one likely, and leaves every
+ * other distance at the odds of a random key. So assert on what it
+ * guarantees: group the windows by their offset modulo 8 and sort each group
+ * on its own. Sorting all of them together instead would be asserting on the
+ * random odds, and would fail about one run in 26 on a correct kernel.
+ */
+static void rss_key_alias_test(struct kunit *test)
+{
+	unsigned int count = NETDEV_RSS_KEY_LEN * BITS_PER_BYTE - 31;
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+	unsigned int i, j, n, r;
+	u32 *windows;
+
+	windows = kunit_kcalloc(test, count, sizeof(*windows), GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, key);
+	KUNIT_ASSERT_NOT_NULL(test, windows);
+
+	for (i = 0; i < RSS_KEY_TEST_KEYS; i++) {
+		netdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);
+
+		for (r = 0; r < 8; r++) {
+			n = 0;
+			for (j = r; j < count; j += 8)
+				windows[n++] = rss_key_test_window(key, j);
+
+			sort(windows, n, sizeof(*windows),
+			     rss_key_test_cmp, NULL);
+
+			for (j = 1; j < n; j++)
+				KUNIT_ASSERT_NE_MSG(test, windows[j],
+						    windows[j - 1],
+						    "two input bits a multiple of 8 apart read the same key window %08x",
+						    windows[j]);
+		}
+	}
+}
+
+/* Hash the inputs of a burst differing only in the low order bits of one
+ * field, and check that they fill the indirection table evenly.
+ */
+static void rss_key_spread_test(struct kunit *test)
+{
+	u8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);
+	u8 *input = kunit_kzalloc(test, RSS_KEY_TEST_INPUT_LEN, GFP_KERNEL);
+	unsigned int i, j, q;
+
+	KUNIT_ASSERT_NOT_NULL(test, key);
+	KUNIT_ASSERT_NOT_NULL(test, input);
+
+	netdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);
+
+	for (i = 0; i < ARRAY_SIZE(rss_key_test_fields); i++) {
+		const struct rss_key_test_field *f = &rss_key_test_fields[i];
+
+		for (q = 1; q <= RSS_KEY_TEST_SPREAD_QMAX; q++) {
+			u64 seen = 0;
+
+			get_random_bytes(input, RSS_KEY_TEST_INPUT_LEN);
+
+			for (j = 0; j < (1U << q); j++) {
+				unsigned int t, queue;
+				u32 hash;
+
+				for (t = 0; t < q; t++)
+					rss_key_test_assign_bit(input,
+								f->lsb - t,
+								j & BIT(t));
+
+				hash = rss_key_test_toeplitz(key, input,
+							     f->nbits);
+				queue = hash & (BIT(q) - 1);
+
+				KUNIT_ASSERT_FALSE_MSG(test, seen & BIT_ULL(queue),
+						       "%s hits queue %u twice out of %u",
+						       f->name, queue, 1U << q);
+				seen |= BIT_ULL(queue);
+			}
+		}
+	}
+}
+
+static struct kunit_case rss_key_test_cases[] = {
+	KUNIT_CASE(rss_key_checker_test),
+	KUNIT_CASE(rss_key_property_test),
+	KUNIT_CASE(rss_key_grid_test),
+	KUNIT_CASE(rss_key_alias_test),
+	KUNIT_CASE(rss_key_spread_test),
+	{},
+};
+
+static struct kunit_suite rss_key_test_suite = {
+	.name = "ethtool-rss-key",
+	.test_cases = rss_key_test_cases,
+};
+
+kunit_test_suite(rss_key_test_suite);
+
+MODULE_DESCRIPTION("Tests for the RSS key generated by netdev_rss_key_fill()");
+MODULE_LICENSE("GPL");
diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile
index 8aebdc6feb177..9bcf3c1e8caa2 100644
--- a/tools/testing/selftests/drivers/net/hw/Makefile
+++ b/tools/testing/selftests/drivers/net/hw/Makefile
@@ -46,6 +46,7 @@ TEST_PROGS = \
 	rss_drv.py \
 	rss_flow_label.py \
 	rss_input_xfrm.py \
+	rss_key.py \
 	toeplitz.py \
 	tso.py \
 	userns_devmem.py \
diff --git a/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py b/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py
index 81e1d1865cd50..96edd9dfe9e3b 100644
--- a/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py
+++ b/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py
@@ -26,6 +26,8 @@ try:
         fd_read_timeout, ip, rand_port, rand_ports, wait_port_listen, \
         wait_file, ctl_file_write, tool
     from net.lib.py import bpf_map_set, bpf_map_dump, bpf_prog_map_ids
+    from net.lib.py import RSS_KEY_QMAX, rss_key_bit, rss_key_assign_bit, \
+        rss_key_window, rss_key_toeplitz, rss_key_full_rank, rss_key_layout
     from net.lib.py import KsftSkipEx, KsftFailEx, KsftXfailEx
     from net.lib.py import ksft_disruptive, ksft_exit, ksft_pr, ksft_run, \
         ksft_setup, ksft_variants, KsftNamedVariant
@@ -42,6 +44,9 @@ try:
                "fd_read_timeout", "ip", "rand_port", "rand_ports",
                "wait_port_listen", "wait_file", "ctl_file_write", "tool",
                "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids",
+               "RSS_KEY_QMAX", "rss_key_bit", "rss_key_assign_bit",
+               "rss_key_window", "rss_key_toeplitz", "rss_key_full_rank",
+               "rss_key_layout",
                "KsftSkipEx", "KsftFailEx", "KsftXfailEx",
                "ksft_disruptive", "ksft_exit", "ksft_pr", "ksft_run",
                "ksft_setup", "ksft_variants", "KsftNamedVariant",
diff --git a/tools/testing/selftests/drivers/net/hw/rss_key.py b/tools/testing/selftests/drivers/net/hw/rss_key.py
new file mode 100755
index 0000000000000..dc7095f6663cd
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/hw/rss_key.py
@@ -0,0 +1,172 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""
+Check that the RSS key a device actually uses spreads flows over all of the
+entries of its indirection table.
+
+Most drivers take their key from netdev_rss_key_fill(), which generates keys
+having that property, but some bring their own and firmware sometimes
+installs one of its own. This reads back the key the device reports, so it
+covers wherever the key came from. See net/lib/py/rsskey.py for what the
+property is and why a random key is not good enough.
+"""
+
+import random
+
+from lib.py import ksft_run, ksft_exit, ksft_pr
+from lib.py import ksft_eq
+from lib.py import KsftSkipEx
+from lib.py import NetDrvEnv, EthtoolFamily, cmd
+from lib.py import RSS_KEY_QMAX, rss_key_assign_bit, rss_key_toeplitz, \
+    rss_key_full_rank, rss_key_layout
+
+# "define" for the ID of the Toeplitz hash function
+ETH_RSS_HASH_TOP = 1
+
+FLOW_TYPES = ("tcp4", "udp4", "tcp6", "udp6")
+
+# How ethtool -n spells the fields of the hash input.
+FIELD_NAMES = {
+    "IP SA": "s",
+    "IP DA": "d",
+    "L3 proto": "t",
+    "L4 bytes 0 & 1 [TCP/UDP src port]": "f",
+    "L4 bytes 2 & 3 [TCP/UDP dst port]": "n",
+    "IPv6 Flow Label": "l",
+}
+
+
+def _get_rss(cfg):
+    """The key and indirection table of @cfg's device, or a skip."""
+    rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}})
+
+    hkey = rss.get("hkey")
+    if not hkey or not any(hkey):
+        raise KsftSkipEx(f"{cfg.ifname} does not report an RSS key")
+
+    if rss.get("hfunc") != ETH_RSS_HASH_TOP:
+        raise KsftSkipEx(f"{cfg.ifname} does not use the Toeplitz hash")
+
+    if rss.get("input-xfrm"):
+        raise KsftSkipEx(f"{cfg.ifname} transforms the hash input")
+
+    indir = rss.get("indir")
+    if not indir:
+        raise KsftSkipEx(f"{cfg.ifname} does not report an indirection table")
+
+    if len(indir) & (len(indir) - 1):
+        raise KsftSkipEx(f"{cfg.ifname} has {len(indir)} indirection table "
+                         "entries, which is not a power of two")
+
+    return bytes(hkey), indir
+
+
+def _get_layouts(cfg):
+    """The hash input layouts in use, mapped to the flow types sharing them."""
+    layouts = {}
+
+    for fl_type in FLOW_TYPES:
+        proc = cmd(f"ethtool -n {cfg.ifname} rx-flow-hash {fl_type}",
+                   fail=False)
+        if proc.ret:
+            continue
+
+        fields = ""
+        for line in proc.stdout.split("\n")[1:-2]:
+            # if this raises we probably need to add more keys to FIELD_NAMES
+            fields += FIELD_NAMES[line]
+
+        layout, nbits = rss_key_layout(fields, fl_type.endswith("6"))
+        if layout is None:
+            ksft_pr(f"{fl_type}: not checked, hashes fields we can not place "
+                    f"({fields})")
+            continue
+
+        layouts.setdefault((tuple(layout), nbits), []).append(fl_type)
+
+    if not layouts:
+        raise KsftSkipEx("no flow type with a hash input we can describe")
+
+    return layouts
+
+
+def test_rss_key_rank(cfg) -> None:
+    """The key has to be non singular for the size of the table."""
+    hkey, indir = _get_rss(cfg)
+    q = min((len(indir) - 1).bit_length(), RSS_KEY_QMAX)
+    degenerate = []
+
+    if not q:
+        raise KsftSkipEx("the indirection table has a single entry")
+
+    for (layout, _), fl_types in _get_layouts(cfg).items():
+        for name, lsb in layout:
+            if lsb + 32 > len(hkey) * 8:
+                ksft_pr(f"{name}: not checked, the key is {len(hkey)} bytes")
+                continue
+
+            if not rss_key_full_rank(hkey, lsb, q):
+                degenerate.append(f"{'/'.join(fl_types)} {name}")
+
+    for bad in degenerate:
+        ksft_pr(f"degenerate: {bad}")
+
+    ksft_eq(len(degenerate), 0,
+            f"the key of {cfg.ifname} does not spread flows over the "
+            f"{1 << q} entries of its indirection table")
+
+
+def test_rss_key_spread(cfg) -> None:
+    """Hash bursts differing in one field only, and place them in the table."""
+    hkey, indir = _get_rss(cfg)
+    q = (len(indir) - 1).bit_length()
+    collisions = []
+
+    if q > RSS_KEY_QMAX:
+        raise KsftSkipEx(f"{len(indir)} indirection table entries is more "
+                         "than the kernel guarantees")
+    if not q:
+        raise KsftSkipEx("the indirection table has a single entry")
+
+    for (layout, nbits), fl_types in _get_layouts(cfg).items():
+        # Unlike the rank check, this hashes the whole input, so it reads
+        # the key up to 31 bits past its last bit rather than past the last
+        # bit of one field.
+        if nbits + 31 > len(hkey) * 8:
+            ksft_pr(f"{'/'.join(fl_types)}: not checked, the key is "
+                    f"{len(hkey)} bytes")
+            continue
+
+        for name, lsb in layout:
+            inp = bytearray(random.randbytes(nbits // 8))
+            entries = set()
+            for value in range(1 << q):
+                for bit in range(q):
+                    rss_key_assign_bit(inp, lsb - bit, value & (1 << bit))
+                hash_ = rss_key_toeplitz(hkey, inp, nbits)
+                entries.add(hash_ & (len(indir) - 1))
+
+            if len(entries) != 1 << q:
+                collisions.append(f"{'/'.join(fl_types)} {name} reaches "
+                                  f"{len(entries)} of the {1 << q} entries")
+
+    for bad in collisions:
+        ksft_pr(bad)
+
+    ksft_eq(len(collisions), 0,
+            f"flows differing in one field only do not fill the "
+            f"indirection table of {cfg.ifname}")
+
+
+def main() -> None:
+    """ Ksft boiler plate main """
+
+    with NetDrvEnv(__file__, nsim_test=False) as cfg:
+        cfg.ethnl = EthtoolFamily()
+        ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg, ))
+    ksft_exit()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 3ee3378f8b26e..cba6084914af5 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -67,6 +67,7 @@ TEST_PROGS := \
 	nat6to4.sh \
 	ndisc_unsolicited_na_test.sh \
 	netdev-l2addr.sh \
+	netdev_rss_key.py \
 	netdevice.sh \
 	netns-name.sh \
 	netns-sysctl.sh \
diff --git a/tools/testing/selftests/net/lib/py/__init__.py b/tools/testing/selftests/net/lib/py/__init__.py
index 71df5880b356a..7648ab6c2adae 100644
--- a/tools/testing/selftests/net/lib/py/__init__.py
+++ b/tools/testing/selftests/net/lib/py/__init__.py
@@ -16,6 +16,8 @@ from .utils import CmdExitFailure, fd_read_timeout, cmd, bkg, defer, \
     bpftool, ip, ethtool, bpftrace, rand_port, rand_ports, wait_port_listen, \
     ctl_file_write, wait_file, tool, tc
 from .bpf import bpf_map_set, bpf_map_dump, bpf_prog_map_ids
+from .rsskey import RSS_KEY_QMAX, rss_key_bit, rss_key_assign_bit, \
+    rss_key_window, rss_key_toeplitz, rss_key_full_rank, rss_key_layout
 from .ynl import NlError, NlctrlFamily, YnlFamily, \
     EthtoolFamily, NetdevFamily, RtnlFamily, RtnlAddrFamily, RtnlRouteFamily
 from .ynl import NetshaperFamily, DevlinkFamily, PSPFamily, Netlink
@@ -31,6 +33,9 @@ __all__ = ["KSRC",
            "bpftool", "ip", "ethtool", "bpftrace", "rand_port", "rand_ports",
            "wait_port_listen", "ctl_file_write", "wait_file", "tool", "tc",
            "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids",
+           "RSS_KEY_QMAX", "rss_key_bit", "rss_key_assign_bit",
+           "rss_key_window", "rss_key_toeplitz", "rss_key_full_rank",
+           "rss_key_layout",
            "NetdevSim", "NetdevSimDev",
            "NetshaperFamily", "DevlinkFamily", "PSPFamily", "NlError",
            "YnlFamily", "EthtoolFamily", "NetdevFamily", "RtnlFamily",
diff --git a/tools/testing/selftests/net/lib/py/rsskey.py b/tools/testing/selftests/net/lib/py/rsskey.py
new file mode 100644
index 0000000000000..4451eb80fb457
--- /dev/null
+++ b/tools/testing/selftests/net/lib/py/rsskey.py
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: GPL-2.0
+
+"""
+Helpers to check the quality of an RSS key.
+
+The Toeplitz hash is linear over GF(2): the hash is the XOR of the 32 bit key
+windows selected by the set bits of the input, and hardware indexes the
+indirection table with the low order bits of the hash. The windows belonging
+to the q lowest bits of a header field therefore form a Toeplitz matrix, and
+when that matrix is singular the flows of a burst differing only in those
+bits, consecutive ephemeral ports typically, can not reach all of the 2 ** q
+entries of the table. A key drawn uniformly at random is singular for a given
+field and a given q with probability 1/2.
+
+netdev_rss_key_fill() generates keys that are non singular for every field of
+the hash input and every q up to RSS_KEY_QMAX.
+"""
+
+# Matches NETDEV_RSS_KEY_QMAX, that is up to 256 entries of the table.
+RSS_KEY_QMAX = 8
+
+
+def rss_key_bit(buf, bit):
+    """Bit @bit of @buf, counting from the most significant bit of byte 0."""
+    return (buf[bit // 8] >> (7 - bit % 8)) & 1
+
+
+def rss_key_assign_bit(buf, bit, value):
+    mask = 0x80 >> (bit % 8)
+
+    if value:
+        buf[bit // 8] |= mask
+    else:
+        buf[bit // 8] &= ~mask
+
+
+def rss_key_window(key, bit):
+    """The 32 key bits starting at @bit, what input bit @bit contributes."""
+    value = 0
+
+    for i in range(32):
+        value = (value << 1) | rss_key_bit(key, bit + i)
+
+    return value
+
+
+def rss_key_toeplitz(key, inp, nbits):
+    """The Toeplitz hash of the @nbits long input @inp under @key."""
+    value = 0
+
+    for i in range(nbits):
+        if rss_key_bit(inp, i):
+            value ^= rss_key_window(key, i)
+
+    return value
+
+
+def rss_key_full_rank(key, lsb, q):
+    """Do the q low order bits of the field at @lsb reach all 2 ** q entries?
+
+    Gaussian elimination over GF(2) on the q windows involved, reduced to
+    their q low order bits, which are the ones indexing the table.
+    """
+    basis = {}
+
+    for j in range(q):
+        vector = rss_key_window(key, lsb - j) & ((1 << q) - 1)
+
+        while vector:
+            low = vector & -vector
+            if low not in basis:
+                basis[low] = vector
+                break
+            vector ^= basis[low]
+
+        if not vector:
+            return False
+
+    return True
+
+
+def rss_key_layout(fields, ipv6):
+    """Describe the hash input built from @fields, as ethtool -n reports it.
+
+    @fields is the flow hash configuration, "sdfn" for a 4-tuple or "sd" for
+    a 2-tuple. Returns the list of (name, position of the least significant
+    bit) and the length of the input in bits, or None if the layout involves
+    something this does not know how to place.
+    """
+    addr_bits = 128 if ipv6 else 32
+    known = (("s", "saddr", addr_bits),
+             ("d", "daddr", addr_bits),
+             ("f", "sport", 16),
+             ("n", "dport", 16))
+
+    if set(fields) - {flag for flag, _, _ in known}:
+        return None, 0
+
+    layout = []
+    nbits = 0
+
+    for flag, name, width in known:
+        if flag not in fields:
+            continue
+        nbits += width
+        layout.append((name, nbits - 1))
+
+    return layout, nbits
diff --git a/tools/testing/selftests/net/netdev_rss_key.py b/tools/testing/selftests/net/netdev_rss_key.py
new file mode 100755
index 0000000000000..37be2ebea6f7c
--- /dev/null
+++ b/tools/testing/selftests/net/netdev_rss_key.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""
+Check the quality of the host RSS key, /proc/sys/net/core/netdev_rss_key.
+
+This is the key netdev_rss_key_fill() hands to the drivers. It has to be non
+singular for every field of the hash input and every queue count up to
+2 ** RSS_KEY_QMAX, see lib/py/rsskey.py for what that means and why it
+matters. Unlike the KUnit tests of the generator, this checks the key the
+running kernel has actually handed out.
+
+The key is generated lazily, the first time a driver asks for it, so this
+test skips until a driver has done so. Any NIC calling netdev_rss_key_fill()
+is enough; in a virtual machine, virtio_net does it from
+virtnet_init_default_rss() once RSS has been negotiated.
+
+Checking what a given NIC really uses is a different question, since a
+driver may bring its own key. See drivers/net/hw/rss_key.py for that.
+"""
+
+from lib.py import ksft_run, ksft_exit, ksft_pr
+from lib.py import ksft_eq, ksft_ge
+from lib.py import KsftSkipEx
+from lib.py import RSS_KEY_QMAX, rss_key_full_rank, rss_key_layout
+
+KEY_PATH = "/proc/sys/net/core/netdev_rss_key"
+
+# Shortest key able to hash an IPv6 4-tuple.
+MIN_KEY_LEN = 40
+
+
+def _read_key():
+    """Return the host RSS key, skipping if it has not been generated."""
+    try:
+        with open(KEY_PATH, "r", encoding="ascii") as fp:
+            text = fp.read().strip()
+    except FileNotFoundError as exc:
+        raise KsftSkipEx(f"{KEY_PATH} is not available") from exc
+
+    key = bytes(int(byte, 16) for byte in text.split(":"))
+
+    if not any(key):
+        raise KsftSkipEx("the host RSS key has not been generated yet, "
+                         "no driver has called netdev_rss_key_fill()")
+
+    return key
+
+
+def check_length() -> None:
+    key = _read_key()
+
+    ksft_pr(f"host RSS key is {len(key)} bytes")
+    ksft_ge(len(key), MIN_KEY_LEN, "key too short to hash an IPv6 4-tuple")
+
+
+def check_spread() -> None:
+    key = _read_key()
+    degenerate = []
+
+    for ipv6 in (False, True):
+        layout, _ = rss_key_layout("sdfn", ipv6)
+        family = "IPv6" if ipv6 else "IPv4"
+
+        for name, lsb in layout:
+            if lsb + 32 > len(key) * 8:
+                continue
+
+            for q in range(1, RSS_KEY_QMAX + 1):
+                if not rss_key_full_rank(key, lsb, q):
+                    degenerate.append(f"{family} {name} over {1 << q} queues")
+
+    for bad in degenerate:
+        ksft_pr(f"degenerate: {bad}")
+
+    ksft_eq(len(degenerate), 0,
+            "the host RSS key does not spread flows over all the queues")
+
+
+def check_grid() -> None:
+    """Sweep the whole key, not only the fields of the usual layouts.
+
+    netdev_rss_key_fill() does not get to know what the hardware hashes, so
+    it gives the property at every 16-bit aligned position of the key. A NIC
+    hashing an encapsulated header reads the key well past the first 40
+    bytes, and has to find the same guarantee there.
+    """
+    key = _read_key()
+    bits = len(key) * 8
+    positions = 0
+    degenerate = []
+
+    for lsb in range(15, bits - 31, 16):
+        positions += 1
+
+        for q in range(1, RSS_KEY_QMAX + 1):
+            if not rss_key_full_rank(key, lsb, q):
+                degenerate.append(f"field ending at bit {lsb} "
+                                  f"over {1 << q} queues")
+
+    ksft_pr(f"checked {positions} positions of the {len(key)} byte key")
+
+    for bad in degenerate[:8]:
+        ksft_pr(f"degenerate: {bad}")
+
+    ksft_eq(len(degenerate), 0,
+            "the host RSS key does not spread flows over all the queues "
+            "at every 16-bit aligned position")
+
+
+def main() -> None:
+    ksft_run(globs=globals(), case_pfx={"check_"})
+    ksft_exit()
+
+
+if __name__ == "__main__":
+    main()

55/3 2026/09/23 18:12 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 16500
							output: 22
							thoughts: 1182
						

Thoughts:
**Analyzing the RSS Key Initialization Patch**

Okay, let's dive into this patch and decide if it warrants a targeted KMSAN fuzzing session. First, I need to understand the changes. Let's see... the title says it's updating `netdev_rss_key_fill()` and adding tests and docs for Toeplitz hash RSS key generation. Alright, let's get into the specifics.

Reading through the patch, it seems the key change is in `net/core/sysctl_net_core.c`.  Specifically, the `proc_do_rss_key()` function. Before, it directly read from `netdev_rss_key[i]`. Now, it checks a boolean flag, `netdev_rss_key_initialized`. If the flag isn't set, it outputs 0. If it is set, it outputs the actual key. Looking at `net/ethtool/ioctl.c`, I see `netdev_rss_key` is a global variable initialized to zero (in BSS). The code also defines `netdev_rss_key_initialized` and a function, `netdev_rss_key_init()`, that uses `get_random_bytes()` to initialize the key and then sets `netdev_rss_key_initialized` to `true`. This initialization is protected with memory barriers. The `netdev_rss_key_fill()` function copies the initialized key to a buffer.

Now, let's look at `netdev_rss_key_aliases()`. It appears to calculate some windows of the RSS key for potential aliasing. The code checks for aliasing using an array named `windows`, of size `NETDEV_RSS_KEY_LEN * BITS_PER_BYTE / 16`. That division seems right, but is there an integer overflow possibility there? Let's check `NETDEV_RSS_KEY_LEN` and see what that resolves to. I'll search for its definition.



56/3 2026/09/23 18:13 tool grepper
0m Args:
{
  "Expression": "NETDEV_RSS_KEY_LEN"
}

Results:
{
  "Output": "drivers/net/ethernet/intel/idpf/idpf_virtchnl.c=3342=int idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q)\n--\ndrivers/net/ethernet/intel/idpf/idpf_virtchnl.c-3372-\ndrivers/net/ethernet/intel/idpf/idpf_virtchnl.c:3373:\trss_data-\u003erss_key_size = min_t(u16, NETDEV_RSS_KEY_LEN,\ndrivers/net/ethernet/intel/idpf/idpf_virtchnl.c-3374-\t\t\t\t       le16_to_cpu(vport_msg-\u003erss_key_size));\n--\ndrivers/net/virtio_net.c=384=struct virtnet_info {\n--\ndrivers/net/virtio_net.c-480-\tTRAILING_OVERLAP(struct virtio_net_rss_config_trailer, rss_trailer, hash_key_data,\ndrivers/net/virtio_net.c:481:\t\tu8 rss_hash_key_data[NETDEV_RSS_KEY_LEN];\ndrivers/net/virtio_net.c-482-\t);\n--\ndrivers/net/virtio_net.c=6772=static int virtnet_probe(struct virtio_device *vdev)\n--\ndrivers/net/virtio_net.c-6913-\ndrivers/net/virtio_net.c:6914:\t\tvi-\u003erss_key_size = min_t(u16, key_sz, NETDEV_RSS_KEY_LEN);\ndrivers/net/virtio_net.c-6915-\t\tif (key_sz \u003e vi-\u003erss_key_size)\n--\ninclude/linux/netdevice.h=5322=void netdev_lower_state_changed(struct net_device *lower_dev,\n--\ninclude/linux/netdevice.h-5324-\ninclude/linux/netdevice.h:5325:#define NETDEV_RSS_KEY_LEN 256\ninclude/linux/netdevice.h:5326:extern u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly;\ninclude/linux/netdevice.h-5327-void netdev_rss_key_fill(void *buffer, size_t len);\n--\nnet/core/sysctl_net_core.c=335=static int proc_do_rss_key(const struct ctl_table *table, int write,\n--\nnet/core/sysctl_net_core.c-337-{\nnet/core/sysctl_net_core.c:338:\tchar buf[NETDEV_RSS_KEY_LEN * 3];\nnet/core/sysctl_net_core.c-339-\tstruct ctl_table fake_table;\n--\nnet/core/sysctl_net_core.c-346-\nnet/core/sysctl_net_core.c:347:\tfor (int i = 0; i \u003c NETDEV_RSS_KEY_LEN; i++) {\nnet/core/sysctl_net_core.c-348-\t\tpos = hex_byte_pack(pos, initialized ? netdev_rss_key[i] : 0);\n--\nnet/ethtool/ioctl.c=1292=static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,\n--\nnet/ethtool/ioctl.c-1308-\nnet/ethtool/ioctl.c:1309:u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly;\nnet/ethtool/ioctl.c-1310-bool netdev_rss_key_initialized __read_mostly;\n--\nnet/ethtool/ioctl.c=1417=static bool netdev_rss_key_aliases(const u8 *key, unsigned int bits)\nnet/ethtool/ioctl.c-1418-{\nnet/ethtool/ioctl.c:1419:\tu32 windows[NETDEV_RSS_KEY_LEN * BITS_PER_BYTE / 16];\nnet/ethtool/ioctl.c-1420-\tunsigned int i, j, n, r;\n--\nnet/ethtool/rss_key_test.c=138=static void rss_key_checker_test(struct kunit *test)\nnet/ethtool/rss_key_test.c-139-{\nnet/ethtool/rss_key_test.c:140:\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\nnet/ethtool/rss_key_test.c-141-\n--\nnet/ethtool/rss_key_test.c-147-\t/* All the windows are equal, which is enough for one queue only. */\nnet/ethtool/rss_key_test.c:148:\tmemset(key, 0xff, NETDEV_RSS_KEY_LEN);\nnet/ethtool/rss_key_test.c-149-\tKUNIT_EXPECT_TRUE(test, rss_key_test_full_rank(key, 31, 1));\n--\nnet/ethtool/rss_key_test.c=153=static void rss_key_property_test(struct kunit *test)\nnet/ethtool/rss_key_test.c-154-{\nnet/ethtool/rss_key_test.c:155:\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\nnet/ethtool/rss_key_test.c-156-\tunsigned int i, j, q;\n--\nnet/ethtool/rss_key_test.c-160-\tfor (i = 0; i \u003c RSS_KEY_TEST_KEYS; i++) {\nnet/ethtool/rss_key_test.c:161:\t\tnetdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);\nnet/ethtool/rss_key_test.c-162-\n--\nnet/ethtool/rss_key_test.c=182=static void rss_key_grid_test(struct kunit *test)\nnet/ethtool/rss_key_test.c-183-{\nnet/ethtool/rss_key_test.c:184:\tunsigned int bits = NETDEV_RSS_KEY_LEN * BITS_PER_BYTE;\nnet/ethtool/rss_key_test.c:185:\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\nnet/ethtool/rss_key_test.c-186-\tunsigned int i, lsb, q;\n--\nnet/ethtool/rss_key_test.c-190-\tfor (i = 0; i \u003c RSS_KEY_TEST_KEYS; i++) {\nnet/ethtool/rss_key_test.c:191:\t\tnetdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);\nnet/ethtool/rss_key_test.c-192-\n--\nnet/ethtool/rss_key_test.c=222=static void rss_key_alias_test(struct kunit *test)\nnet/ethtool/rss_key_test.c-223-{\nnet/ethtool/rss_key_test.c:224:\tunsigned int count = NETDEV_RSS_KEY_LEN * BITS_PER_BYTE - 31;\nnet/ethtool/rss_key_test.c:225:\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\nnet/ethtool/rss_key_test.c-226-\tunsigned int i, j, n, r;\n--\nnet/ethtool/rss_key_test.c-233-\tfor (i = 0; i \u003c RSS_KEY_TEST_KEYS; i++) {\nnet/ethtool/rss_key_test.c:234:\t\tnetdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);\nnet/ethtool/rss_key_test.c-235-\n--\nnet/ethtool/rss_key_test.c=256=static void rss_key_spread_test(struct kunit *test)\nnet/ethtool/rss_key_test.c-257-{\nnet/ethtool/rss_key_test.c:258:\tu8 *key = kunit_kzalloc(test, NETDEV_RSS_KEY_LEN, GFP_KERNEL);\nnet/ethtool/rss_key_test.c-259-\tu8 *input = kunit_kzalloc(test, RSS_KEY_TEST_INPUT_LEN, GFP_KERNEL);\n--\nnet/ethtool/rss_key_test.c-264-\nnet/ethtool/rss_key_test.c:265:\tnetdev_rss_key_init(key, NETDEV_RSS_KEY_LEN);\nnet/ethtool/rss_key_test.c-266-\n"
}

57/3 2026/09/23 18:13 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 20479
							output: 40
							thoughts: 2303
						

Thoughts:
**Deep Dive into RSS Key Management**

Okay, let's break this down systematically. My initial thought process revolves around ensuring data integrity and preventing potential out-of-bounds reads within the RSS key processing logic. `NETDEV_RSS_KEY_LEN` is defined as 256. This means the RSS key itself is 256 bytes. From here, there is a calculation of `NETDEV_RSS_KEY_LEN * BITS_PER_BYTE / 16`, which evaluates to 128. This restricts the value of 'n' to a maximum of 128 elements.

Now, let's look at `netdev_rss_key_aliases()`. It's pretty straightforward. We have a stack-allocated `windows` array, and the loops iterate up to `n`, but never beyond. The key here is to verify that any data access within these loops remains within the bounds of the `key` buffer. No reads occur past `windows`' bounds and that the elements are written before they are read.

Focusing on `netdev_rss_key_window()`, a crucial aspect is the reading of 32 bits from the key buffer. The code uses `get_unaligned_be32(key + byte)`. My immediate concern is ensuring that the `byte` offset combined with the potential additional byte access due to the `shift` operation doesn't lead to out-of-bounds memory access. The condition `bit + 32 <= bits` is essential.

After analyzing the potential maximum values, I have confirmed that the access to `key[byte + 4]` is always within bounds if `bit + 32 <= bits`. The maximum value for bit is `bits - 32`.

I then investigate the `netdev_rss_key_fixup_field()` function, and how the `lsb` parameter interacts with this calculation. The concern is the range of values that `lsb + 31 - t` can take. The analysis confirms that it's within the proper bounds. There isn't any uninitialized data when considering the d array.

Finally, `proc_do_rss_key` needs verification too. I need to be sure the data it reads and writes is valid and within bounds. Specifically, the read from `netdev_rss_key[i]`, and that it reads and writes initialized data from the `netdev_rss_key` array.

Overall, it seems the code is well-structured, but the checks serve to confirm the assumptions and ensure safe memory access.



58/3 2026/09/23 18:13 tool read-file
0m Args:
{
  "File": "net/core/sysctl_net_core.c",
  "FirstLine": 330,
  "LineCount": 40
}

Results:
{
  "Contents": " 330:\t\tmutex_unlock(\u0026dev_weight_mutex);\n 331:\t\n 332:\t\treturn ret;\n 333:\t}\n 334:\t\n 335:\tstatic int proc_do_rss_key(const struct ctl_table *table, int write,\n 336:\t\t\t\t   void *buffer, size_t *lenp, loff_t *ppos)\n 337:\t{\n 338:\t\tchar buf[NETDEV_RSS_KEY_LEN * 3];\n 339:\t\tstruct ctl_table fake_table;\n 340:\t\tchar *pos = buf;\n 341:\t\tbool initialized;\n 342:\t\n 343:\t\tinitialized = READ_ONCE(netdev_rss_key_initialized);\n 344:\t\t/* Pair with smp_wmb() in netdev_rss_key_fill(). */\n 345:\t\tsmp_rmb();\n 346:\t\n 347:\t\tfor (int i = 0; i \u003c NETDEV_RSS_KEY_LEN; i++) {\n 348:\t\t\tpos = hex_byte_pack(pos, initialized ? netdev_rss_key[i] : 0);\n 349:\t\t\t*pos++ = ':';\n 350:\t\t}\n 351:\t\t*(--pos) = 0;\n 352:\t\n 353:\t\tfake_table.data = buf;\n 354:\t\tfake_table.maxlen = sizeof(buf);\n 355:\t\treturn proc_dostring(\u0026fake_table, write, buffer, lenp, ppos);\n 356:\t}\n 357:\t\n 358:\tstatic int proc_do_skb_defer_max(const struct ctl_table *table, int write,\n 359:\t\t\t void *buffer, size_t *lenp, loff_t *ppos)\n 360:\t{\n 361:\t\tstatic DEFINE_MUTEX(skb_defer_max_mutex);\n 362:\t\tint ret, oval, nval;\n 363:\t\n 364:\t\tmutex_lock(\u0026skb_defer_max_mutex);\n 365:\t\n 366:\t\toval = !net_hotdata.sysctl_skb_defer_max;\n 367:\t\tret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);\n 368:\t\tnval = !net_hotdata.sysctl_skb_defer_max;\n 369:\t\n"
}

59/3 2026/09/23 18:13 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 24041
							output: 20
							thoughts: 368
						

Thoughts:
**Analyzing the `proc_do_rss_key` Function**

Okay, let's dive into this code. My initial thought is to examine the use of `fake_table` within `proc_do_rss_key`. I need to confirm whether `fake_table` was fully initialized before this point, or if there's any potential for an uninitialized state. Looking at the code snippet, I'm noting the declaration and assignment:

```c
struct ctl_table fake_table;
fake_table.data = buf;
fake_table.maxlen = sizeof(buf);
return proc_dostring(&fake_table, write, buffer, lenp, ppos);
```

Hmm, the assignment seems straightforward. But wait, this patch *doesn't* actually modify the `fake_table` structure itself! It looks like the patch only touches the code that reads `netdev_rss_key`, which is a different part of the overall flow. Specifically, it changes the initialization logic using `READ_ONCE`, `smp_rmb`, and the conditional read based on `netdev_rss_key_initialized`.

So, the patch *didn't* introduce or change the `fake_table` definition at all. Now I need to confirm that `proc_dostring` doesn't read any uninitialized values from `fake_table`. Looking at the `proc_dostring` call, it only seems to be using `.data` and `.maxlen`. Just to be absolutely sure, I'll quickly check the implementation of `proc_dostring` to be certain it doesn't do anything else with the `ctl_table` that could be problematic.



60/3 2026/09/23 18:13 tool grepper
0m Args:
{
  "Expression": "proc_dostring\\("
}

Results:
{
  "Output": "drivers/cdrom/cdrom.c=3496=static int cdrom_sysctl_info(const struct ctl_table *ctl, int write,\n--\ndrivers/cdrom/cdrom.c-3572-\tmutex_unlock(\u0026cdrom_mutex);\ndrivers/cdrom/cdrom.c:3573:\treturn proc_dostring(ctl, write, buffer, lenp, ppos);\ndrivers/cdrom/cdrom.c-3574-done:\n--\ndrivers/char/random.c=1623=static int proc_do_uuid(const struct ctl_table *table, int write, void *buf,\n--\ndrivers/char/random.c-1649-\tsnprintf(uuid_string, sizeof(uuid_string), \"%pU\", uuid);\ndrivers/char/random.c:1650:\treturn proc_dostring(\u0026fake_table, 0, buf, lenp, ppos);\ndrivers/char/random.c-1651-}\n--\nfs/coredump.c=1459=static int proc_dostring_coredump(const struct ctl_table *table, int write,\n--\nfs/coredump.c-1466-\tif (!write)\nfs/coredump.c:1467:\t\treturn proc_dostring(table, write, buffer, lenp, ppos);\nfs/coredump.c-1468-\n--\nfs/coredump.c-1470-\nfs/coredump.c:1471:\terror = proc_dostring(table, write, buffer, lenp, ppos);\nfs/coredump.c-1472-\tif (error)\n--\nfs/proc/proc_sysctl.c=1298=static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)\n--\nfs/proc/proc_sysctl.c-1358- *\nfs/proc/proc_sysctl.c:1359: * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),\nfs/proc/proc_sysctl.c-1360- * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),\n--\ninclude/linux/sysctl.h=77=typedef int proc_handler(const struct ctl_table *ctl, int dir, void *buf,\n--\ninclude/linux/sysctl.h-80-/* proc_handler functions */\ninclude/linux/sysctl.h:81:int proc_dostring(const struct ctl_table *ctl, int dir, void *buf, size_t *lenp,\ninclude/linux/sysctl.h-82-\t\t  loff_t *ppos);\n--\nkernel/printk/printk.c=202=int devkmsg_sysctl_set_loglvl(const struct ctl_table *table, int write,\n--\nkernel/printk/printk.c-216-\nkernel/printk/printk.c:217:\terr = proc_dostring(table, write, buffer, lenp, ppos);\nkernel/printk/printk.c-218-\tif (err)\n--\nkernel/seccomp.c=2390=static int read_actions_logged(const struct ctl_table *ro_table, void *buffer,\n--\nkernel/seccomp.c-2404-\ttable.maxlen = sizeof(names);\nkernel/seccomp.c:2405:\treturn proc_dostring(\u0026table, 0, buffer, lenp, ppos);\nkernel/seccomp.c-2406-}\n--\nkernel/seccomp.c=2408=static int write_actions_logged(const struct ctl_table *ro_table, void *buffer,\n--\nkernel/seccomp.c-2422-\ttable.maxlen = sizeof(names);\nkernel/seccomp.c:2423:\tret = proc_dostring(\u0026table, 1, buffer, lenp, ppos);\nkernel/seccomp.c-2424-\tif (ret)\n--\nkernel/sysctl.c=155=static bool proc_first_pos_non_zero_ignore(loff_t *ppos,\n--\nkernel/sysctl.c-188- */\nkernel/sysctl.c:189:int proc_dostring(const struct ctl_table *table, int dir,\nkernel/sysctl.c-190-\t\t  void *buffer, size_t *lenp, loff_t *ppos)\n--\nkernel/sysctl.c=1138=int proc_do_large_bitmap(const struct ctl_table *table, int dir,\n--\nkernel/sysctl.c-1269-\nkernel/sysctl.c:1270:int proc_dostring(const struct ctl_table *table, int dir,\nkernel/sysctl.c-1271-\t\t  void *buffer, size_t *lenp, loff_t *ppos)\n--\nkernel/utsname_sysctl.c=33=static int proc_do_uts_string(const struct ctl_table *table, int write,\n--\nkernel/utsname_sysctl.c-43-\t/*\nkernel/utsname_sysctl.c:44:\t * Buffer the value in tmp_data so that proc_dostring() can be called\nkernel/utsname_sysctl.c-45-\t * without holding any locks.\n--\nkernel/utsname_sysctl.c-51-\tup_read(\u0026uts_sem);\nkernel/utsname_sysctl.c:52:\tr = proc_dostring(\u0026uts_table, write, buffer, lenp, ppos);\nkernel/utsname_sysctl.c-53-\n--\nlib/sys_info.c=53=static int sys_info_write_handler(const struct ctl_table *table,\n--\nlib/sys_info.c-59-\nlib/sys_info.c:60:\tret = proc_dostring(table, 1, buffer, lenp, ppos);\nlib/sys_info.c-61-\tif (ret)\n--\nlib/sys_info.c=72=static int sys_info_read_handler(const struct ctl_table *table,\n--\nlib/sys_info.c-91-\nlib/sys_info.c:92:\treturn proc_dostring(table, 0, buffer, lenp, ppos);\nlib/sys_info.c-93-}\n--\nmm/page_alloc.c=5789=static int numa_zonelist_order_handler(const struct ctl_table *table, int write,\n--\nmm/page_alloc.c-5793-\t\treturn __parse_numa_zonelist_order(buffer);\nmm/page_alloc.c:5794:\treturn proc_dostring(table, write, buffer, length, ppos);\nmm/page_alloc.c-5795-}\n--\nnet/core/sysctl_net_core.c=298=static int set_default_qdisc(const struct ctl_table *table, int write,\n--\nnet/core/sysctl_net_core.c-309-\nnet/core/sysctl_net_core.c:310:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/core/sysctl_net_core.c-311-\tif (write \u0026\u0026 ret == 0)\n--\nnet/core/sysctl_net_core.c=335=static int proc_do_rss_key(const struct ctl_table *table, int write,\n--\nnet/core/sysctl_net_core.c-354-\tfake_table.maxlen = sizeof(buf);\nnet/core/sysctl_net_core.c:355:\treturn proc_dostring(\u0026fake_table, write, buffer, lenp, ppos);\nnet/core/sysctl_net_core.c-356-}\n--\nnet/ipv4/sysctl_net_ipv4.c=220=static int proc_tcp_congestion_control(const struct ctl_table *ctl, int write,\n--\nnet/ipv4/sysctl_net_ipv4.c-233-\nnet/ipv4/sysctl_net_ipv4.c:234:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/ipv4/sysctl_net_ipv4.c-235-\tif (write \u0026\u0026 ret == 0)\n--\nnet/ipv4/sysctl_net_ipv4.c=240=static int proc_tcp_available_congestion_control(const struct ctl_table *ctl,\n--\nnet/ipv4/sysctl_net_ipv4.c-250-\ttcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);\nnet/ipv4/sysctl_net_ipv4.c:251:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/ipv4/sysctl_net_ipv4.c-252-\tkfree(tbl.data);\n--\nnet/ipv4/sysctl_net_ipv4.c=256=static int proc_allowed_congestion_control(const struct ctl_table *ctl,\n--\nnet/ipv4/sysctl_net_ipv4.c-267-\ttcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);\nnet/ipv4/sysctl_net_ipv4.c:268:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/ipv4/sysctl_net_ipv4.c-269-\tif (write \u0026\u0026 ret == 0)\n--\nnet/ipv4/sysctl_net_ipv4.c=293=static int proc_tcp_fastopen_key(const struct ctl_table *table, int write,\n--\nnet/ipv4/sysctl_net_ipv4.c-336-\nnet/ipv4/sysctl_net_ipv4.c:337:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/ipv4/sysctl_net_ipv4.c-338-\n--\nnet/ipv4/sysctl_net_ipv4.c=379=static int proc_tcp_available_ulp(const struct ctl_table *ctl,\n--\nnet/ipv4/sysctl_net_ipv4.c-389-\ttcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);\nnet/ipv4/sysctl_net_ipv4.c:390:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/ipv4/sysctl_net_ipv4.c-391-\tkfree(tbl.data);\n--\nnet/ipv6/addrconf.c=6597=static int addrconf_sysctl_stable_secret(const struct ctl_table *ctl, int write,\n--\nnet/ipv6/addrconf.c-6627-\nnet/ipv6/addrconf.c:6628:\terr = proc_dostring(\u0026lctl, write, buffer, lenp, ppos);\nnet/ipv6/addrconf.c-6629-\tif (err || !write)\n--\nnet/mptcp/ctrl.c=137=static int proc_scheduler(const struct ctl_table *ctl, int write,\n--\nnet/mptcp/ctrl.c-149-\nnet/mptcp/ctrl.c:150:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/mptcp/ctrl.c-151-\tif (write \u0026\u0026 ret == 0)\n--\nnet/mptcp/ctrl.c=157=static int proc_available_schedulers(const struct ctl_table *ctl,\n--\nnet/mptcp/ctrl.c-168-\tmptcp_get_available_schedulers(tbl.data, MPTCP_SCHED_BUF_MAX);\nnet/mptcp/ctrl.c:169:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/mptcp/ctrl.c-170-\tkfree(tbl.data);\n--\nnet/mptcp/ctrl.c=207=static int proc_path_manager(const struct ctl_table *ctl, int write,\n--\nnet/mptcp/ctrl.c-222-\nnet/mptcp/ctrl.c:223:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/mptcp/ctrl.c-224-\tif (write \u0026\u0026 ret == 0) {\n--\nnet/mptcp/ctrl.c=263=static int proc_available_path_managers(const struct ctl_table *ctl,\n--\nnet/mptcp/ctrl.c-274-\tmptcp_pm_get_available(tbl.data, MPTCP_PM_BUF_MAX);\nnet/mptcp/ctrl.c:275:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/mptcp/ctrl.c-276-\tkfree(tbl.data);\n--\nnet/netfilter/nf_log.c=427=static struct ctl_table nf_log_sysctl_ftable[] = {\n--\nnet/netfilter/nf_log.c-436-\nnet/netfilter/nf_log.c:437:static int nf_log_proc_dostring(const struct ctl_table *table, int write,\nnet/netfilter/nf_log.c-438-\t\t\t void *buffer, size_t *lenp, loff_t *ppos)\n--\nnet/netfilter/nf_log.c-448-\nnet/netfilter/nf_log.c:449:\t\t/* proc_dostring() can append to existing strings, so we need to\nnet/netfilter/nf_log.c-450-\t\t * initialize it as an empty string.\n--\nnet/netfilter/nf_log.c-453-\t\ttmp.data = buf;\nnet/netfilter/nf_log.c:454:\t\tr = proc_dostring(\u0026tmp, write, buffer, lenp, ppos);\nnet/netfilter/nf_log.c-455-\t\tif (r)\n--\nnet/netfilter/nf_log.c-480-\t\tmutex_unlock(\u0026nf_log_mutex);\nnet/netfilter/nf_log.c:481:\t\tr = proc_dostring(\u0026tmp, write, buffer, lenp, ppos);\nnet/netfilter/nf_log.c-482-\t}\n--\nnet/sctp/sysctl.c=387=static int proc_sctp_do_hmac_alg(const struct ctl_table *ctl, int write,\n--\nnet/sctp/sysctl.c-400-\t\ttbl.maxlen = sizeof(tmp) - 1;\nnet/sctp/sysctl.c:401:\t\tret = proc_dostring(\u0026tbl, 1, buffer, lenp, ppos);\nnet/sctp/sysctl.c-402-\t\tif (ret)\n--\nnet/sctp/sysctl.c-418-\ttbl.maxlen = strlen(tbl.data);\nnet/sctp/sysctl.c:419:\treturn proc_dostring(\u0026tbl, 0, buffer, lenp, ppos);\nnet/sctp/sysctl.c-420-}\n--\nnet/smc/smc_sysctl.c=70=static int proc_smc_hs_ctrl(const struct ctl_table *ctl, int write,\n--\nnet/smc/smc_sysctl.c-89-\nnet/smc/smc_sysctl.c:90:\tret = proc_dostring(\u0026tbl, write, buffer, lenp, ppos);\nnet/smc/smc_sysctl.c-91-\tif (ret)\n--\nnet/vmw_vsock/af_vsock.c-171-/* 6 chars for \"global\", 1 for null-terminator, and 1 more for '\\n'.\nnet/vmw_vsock/af_vsock.c:172: * The newline is added by proc_dostring() for read operations.\nnet/vmw_vsock/af_vsock.c-173- */\n--\nnet/vmw_vsock/af_vsock.c=2815=static int __vsock_net_mode_string(const struct ctl_table *table, int write,\n--\nnet/vmw_vsock/af_vsock.c-2851-\nnet/vmw_vsock/af_vsock.c:2852:\tret = proc_dostring(\u0026tmp, write, buffer, lenp, ppos);\nnet/vmw_vsock/af_vsock.c-2853-\tif (ret || !write)\n--\ntools/testing/selftests/splice/short_splice_read.sh=122=expect_success \"proc_handler: proc_dointvec_minmax() splice\" test_splice /proc/sys/fs/nr_open\ntools/testing/selftests/splice/short_splice_read.sh:123:expect_success \"proc_handler: proc_dostring() splice\" test_splice /proc/sys/kernel/modprobe\ntools/testing/selftests/splice/short_splice_read.sh-124-expect_success \"proc_handler: special read splice\" test_splice /proc/sys/kernel/version\n--\ntools/testing/selftests/sysctl/sysctl.sh=883=list_tests()\n--\ntools/testing/selftests/sysctl/sysctl.sh-891-\techo \"0001 x $(get_test_count 0001) - tests proc_dointvec_minmax()\"\ntools/testing/selftests/sysctl/sysctl.sh:892:\techo \"0002 x $(get_test_count 0002) - tests proc_dostring()\"\ntools/testing/selftests/sysctl/sysctl.sh-893-\techo \"0003 x $(get_test_count 0003) - tests proc_dointvec()\"\n"
}

61/3 2026/09/23 18:13 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 29460
							output: 22
							thoughts: 2140
						

Thoughts:
**Analyzing Potential KMSAN Issues in RSS Key Handling**

Okay, let's break down this code and think through potential KMSAN issues. I'm focusing on whether this patch introduces any risks related to uninitialized memory being exposed to userspace or used in conditional logic. The `proc_do_rss_key` function is the key area, specifically how it handles the `netdev_rss_key`.

First, the code in `proc_do_rss_key` initializes a local buffer `buf` of size `NETDEV_RSS_KEY_LEN * 3` (768 bytes). This looks like a string buffer for the hex representation. Inside the loop, it iterates `NETDEV_RSS_KEY_LEN` (256) times, writing to `buf`. Each iteration writes two hex characters plus a colon. So, each iteration writes 3 bytes, for a total of 768 bytes written. Finally, a null terminator is added. Crucially, *every byte* of `buf` is explicitly written before it's used. This means there's no risk of reading uninitialized stack data and passing it to userspace.

The `netdev_rss_key_init` function is the interesting one. It initializes the `netdev_rss_key`. It now uses `DO_ONCE` for initialization, and it includes a loop and `netdev_rss_key_aliases` which causes it to modify `netdev_rss_key` in place. The code now introduces a `netdev_rss_key_initialized` flag, protected by memory barriers. The flag is used in `proc_do_rss_key` to avoid reading from the key while it's being populated asynchronously. If the flag isn't set, it simply prints zeros. This prevents a race condition where the partially initialized key could be leaked to userspace. This change *prevents* the exposure of uninitialized data, rather than introducing it.

The KUnit tests are relevant too, so let's check them. Examining `net/ethtool/rss_key_test.c`, all the RSS key tests allocate memory using `kunit_kzalloc` or `kunit_kcalloc`, and they either initialize the key explicitly or rely on the zero-initialization from `kzalloc`. This ensures there's no reliance on uninitialized memory within the tests themselves. All the structures being tested are fully zeroed or initialized.

Based on the KMSAN guidelines, the patch doesn't:
1. Introduce or modify kernel structures sent to user space where fields might not be initialized.
2. Introduce conditional logic that depends on potentially uninitialized variables or struct fields (it *prevents* the exposure of uninitialized memory).
3. Allocate or initialize complex data structures where uninitialized fields could be read later in reachable code paths.
4. Introduce a risk of uninitialized bytes of existing buffers.

In short, this patch *addresses* the potential for uninitialized memory usage, by using the `netdev_rss_key_initialized` flag and zeroing `buf` explicitly, and ensuring the key is fully initialized before being read. The KMSAN flag shouldn't be set to true.



62/3 2026/09/23 18:13 tool grepper
0m Args:
{
  "Expression": "netdev_rss_key_fill"
}

Results:
{
  "Output": "Documentation/admin-guide/sysctl/net.rst=319=provide ethtool -x support yet.\n--\nDocumentation/admin-guide/sysctl/net.rst-325-\nDocumentation/admin-guide/sysctl/net.rst:326:File contains all nul bytes if no driver ever called netdev_rss_key_fill()\nDocumentation/admin-guide/sysctl/net.rst-327-function.\n--\nDocumentation/networking/scaling.rst=55=picking nearly consecutive ephemeral ports then lands on a fraction of the\nDocumentation/networking/scaling.rst:56:queues while the others stay idle. The netdev_rss_key_fill() helper draws\nDocumentation/networking/scaling.rst-57-a random key that is free of this defect; drivers should use it rather\n--\ndrivers/infiniband/hw/mana/qp.c=8=static int mana_ib_cfg_vport_steering(struct mana_ib_dev *dev,\n--\ndrivers/infiniband/hw/mana/qp.c-67-\telse\ndrivers/infiniband/hw/mana/qp.c:68:\t\tnetdev_rss_key_fill(req-\u003ehashkey, MANA_HASH_KEY_SIZE);\ndrivers/infiniband/hw/mana/qp.c-69-\n--\ndrivers/net/ethernet/amazon/ena/ena_com.c=1046=static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev)\n--\ndrivers/net/ethernet/amazon/ena/ena_com.c-1050-\ndrivers/net/ethernet/amazon/ena/ena_com.c:1051:\tnetdev_rss_key_fill(\u0026hash_key-\u003ekey, sizeof(hash_key-\u003ekey));\ndrivers/net/ethernet/amazon/ena/ena_com.c-1052-\t/* The key buffer is stored in the device in an array of\n--\ndrivers/net/ethernet/amd/xgbe/xgbe-main.c=152=int xgbe_config_netdev(struct xgbe_prv_data *pdata)\n--\ndrivers/net/ethernet/amd/xgbe/xgbe-main.c-214-\t/* Initialize RSS hash key */\ndrivers/net/ethernet/amd/xgbe/xgbe-main.c:215:\tnetdev_rss_key_fill(pdata-\u003erss_key, sizeof(pdata-\u003erss_key));\ndrivers/net/ethernet/amd/xgbe/xgbe-main.c-216-\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c=2080=int bnx2x_rss(struct bnx2x *bp, struct bnx2x_rss_config_obj *rss_obj,\n--\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c-2127-\t\t/* RSS keys */\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c:2128:\t\tnetdev_rss_key_fill(params.rss_key, T_ETH_RSS_KEY * 4);\ndrivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c-2129-\t\t__set_bit(BNX2X_RSS_SET_SRCH, \u0026params.rss_flags);\n--\ndrivers/net/ethernet/broadcom/tg3.c=9944=static int tg3_reset_hw(struct tg3 *tp, bool reset_phy)\n--\ndrivers/net/ethernet/broadcom/tg3.c-10689-\ndrivers/net/ethernet/broadcom/tg3.c:10690:\t\tnetdev_rss_key_fill(rss_key, 10 * sizeof(u32));\ndrivers/net/ethernet/broadcom/tg3.c-10691-\n--\ndrivers/net/ethernet/brocade/bna/bnad.c=2027=bnad_init_rx_config(struct bnad *bnad, struct bna_rx_config *rx_config)\n--\ndrivers/net/ethernet/brocade/bna/bnad.c-2042-\t\t\t\tbnad-\u003enum_rxp_per_rx - 1;\ndrivers/net/ethernet/brocade/bna/bnad.c:2043:\t\tnetdev_rss_key_fill(rx_config-\u003erss_config.toeplitz_hash_key,\ndrivers/net/ethernet/brocade/bna/bnad.c-2044-\t\t\tsizeof(rx_config-\u003erss_config.toeplitz_hash_key));\n--\ndrivers/net/ethernet/cavium/thunder/nicvf_main.c=370=static int nicvf_rss_init(struct nicvf *nic)\n--\ndrivers/net/ethernet/cavium/thunder/nicvf_main.c-384-\ndrivers/net/ethernet/cavium/thunder/nicvf_main.c:385:\tnetdev_rss_key_fill(rss-\u003ekey, RSS_HASH_KEY_SIZE * sizeof(u64));\ndrivers/net/ethernet/cavium/thunder/nicvf_main.c-386-\tnicvf_set_rss_key(nic);\n--\ndrivers/net/ethernet/cisco/enic/enic_main.c=2087=static int enic_set_rsskey(struct enic *enic)\ndrivers/net/ethernet/cisco/enic/enic_main.c-2088-{\ndrivers/net/ethernet/cisco/enic/enic_main.c:2089:\tnetdev_rss_key_fill(enic-\u003erss_key, ENIC_RSS_LEN);\ndrivers/net/ethernet/cisco/enic/enic_main.c-2090-\n--\ndrivers/net/ethernet/emulex/benet/be_main.c=3685=static int be_rx_qs_create(struct be_adapter *adapter)\n--\ndrivers/net/ethernet/emulex/benet/be_main.c-3731-\ndrivers/net/ethernet/emulex/benet/be_main.c:3732:\t\tnetdev_rss_key_fill(rss_key, RSS_HASH_KEY_LEN);\ndrivers/net/ethernet/emulex/benet/be_main.c-3733-\t\trc = be_cmd_rss_config(adapter, rss-\u003ersstable, rss-\u003erss_flags,\n--\ndrivers/net/ethernet/fungible/funeth/funeth_main.c=1420=static int fun_init_rss(struct net_device *dev)\n--\ndrivers/net/ethernet/fungible/funeth/funeth_main.c-1434-\tfp-\u003ehash_algo = FUN_ETH_RSS_ALG_TOEPLITZ;\ndrivers/net/ethernet/fungible/funeth/funeth_main.c:1435:\tnetdev_rss_key_fill(fp-\u003erss_key, sizeof(fp-\u003erss_key));\ndrivers/net/ethernet/fungible/funeth/funeth_main.c-1436-\tfun_reset_rss_indir(dev, dev-\u003ereal_num_rx_queues);\n--\ndrivers/net/ethernet/google/gve/gve_main.c=1825=int gve_init_rss_config(struct gve_priv *priv, u16 num_queues)\n--\ndrivers/net/ethernet/google/gve/gve_main.c-1837-\ndrivers/net/ethernet/google/gve/gve_main.c:1838:\tnetdev_rss_key_fill(rss_config-\u003ehash_key, priv-\u003erss_key_size);\ndrivers/net/ethernet/google/gve/gve_main.c-1839-\n--\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c=299=static void hns_ppe_init_hw(struct hns_ppe_cb *ppe_cb)\n--\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c-306-\t/* get default RSS key */\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c:307:\tnetdev_rss_key_fill(ppe_cb-\u003erss_key, HNS_PPEV2_RSS_KEY_SIZE);\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c-308-\n--\ndrivers/net/ethernet/huawei/hinic/hinic_main.c=304=static int hinic_rss_init(struct hinic_dev *nic_dev)\n--\ndrivers/net/ethernet/huawei/hinic/hinic_main.c-314-\ndrivers/net/ethernet/huawei/hinic/hinic_main.c:315:\tnetdev_rss_key_fill(default_rss_key, sizeof(default_rss_key));\ndrivers/net/ethernet/huawei/hinic/hinic_main.c-316-\tfor (i = 0; i \u003c HINIC_RSS_INDIR_SIZE; i++)\n--\ndrivers/net/ethernet/huawei/hinic3/hinic3_rss.c=72=static int alloc_rss_resource(struct net_device *netdev)\n--\ndrivers/net/ethernet/huawei/hinic3/hinic3_rss.c-81-\ndrivers/net/ethernet/huawei/hinic3/hinic3_rss.c:82:\tnetdev_rss_key_fill(nic_dev-\u003erss_hkey, L2NIC_RSS_KEY_SIZE);\ndrivers/net/ethernet/huawei/hinic3/hinic3_rss.c-83-\n--\ndrivers/net/ethernet/intel/e1000e/netdev.c=3455=static void e1000e_setup_rss_hash(struct e1000_adapter *adapter)\n--\ndrivers/net/ethernet/intel/e1000e/netdev.c-3461-\ndrivers/net/ethernet/intel/e1000e/netdev.c:3462:\tnetdev_rss_key_fill(rss_key, sizeof(rss_key));\ndrivers/net/ethernet/intel/e1000e/netdev.c-3463-\tfor (i = 0; i \u003c 10; i++)\n--\ndrivers/net/ethernet/intel/fm10k/fm10k_pci.c=1967=static int fm10k_sw_init(struct fm10k_intfc *interface,\n--\ndrivers/net/ethernet/intel/fm10k/fm10k_pci.c-2068-\ndrivers/net/ethernet/intel/fm10k/fm10k_pci.c:2069:\tnetdev_rss_key_fill(rss_key, sizeof(rss_key));\ndrivers/net/ethernet/intel/fm10k/fm10k_pci.c-2070-\tmemcpy(interface-\u003erssrk, rss_key, sizeof(rss_key));\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c=1901=static int i40e_vsi_config_rss(struct i40e_vsi *vsi)\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c-1928-\telse\ndrivers/net/ethernet/intel/i40e/i40e_main.c:1929:\t\tnetdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);\ndrivers/net/ethernet/intel/i40e/i40e_main.c-1930-\tret = i40e_config_rss_aq(vsi, seed, lut, vsi-\u003erss_table_size);\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c=6190=static int i40e_vsi_reconfig_rss(struct i40e_vsi *vsi, u16 rss_size)\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c-6218-\telse\ndrivers/net/ethernet/intel/i40e/i40e_main.c:6219:\t\tnetdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);\ndrivers/net/ethernet/intel/i40e/i40e_main.c-6220-\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c=12472=static int i40e_pf_config_rss(struct i40e_pf *pf)\n--\ndrivers/net/ethernet/intel/i40e/i40e_main.c-12527-\telse\ndrivers/net/ethernet/intel/i40e/i40e_main.c:12528:\t\tnetdev_rss_key_fill((void *)seed, I40E_HKEY_ARRAY_SIZE);\ndrivers/net/ethernet/intel/i40e/i40e_main.c-12529-\tret = i40e_config_rss(vsi, seed, lut, vsi-\u003erss_table_size);\n--\ndrivers/net/ethernet/intel/iavf/iavf_main.c=1738=static int iavf_init_rss(struct iavf_adapter *adapter)\n--\ndrivers/net/ethernet/intel/iavf/iavf_main.c-1755-\tiavf_fill_rss_lut(adapter);\ndrivers/net/ethernet/intel/iavf/iavf_main.c:1756:\tnetdev_rss_key_fill((void *)adapter-\u003erss_key, adapter-\u003erss_key_size);\ndrivers/net/ethernet/intel/iavf/iavf_main.c-1757-\n--\ndrivers/net/ethernet/intel/ice/ice_lib.c=1499=int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi)\n--\ndrivers/net/ethernet/intel/ice/ice_lib.c-1550-\telse\ndrivers/net/ethernet/intel/ice/ice_lib.c:1551:\t\tnetdev_rss_key_fill((void *)key, ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE);\ndrivers/net/ethernet/intel/ice/ice_lib.c-1552-\n--\ndrivers/net/ethernet/intel/idpf/idpf_lib.c=1246=static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,\n--\ndrivers/net/ethernet/intel/idpf/idpf_lib.c-1320-\t/* Initialize default RSS key */\ndrivers/net/ethernet/intel/idpf/idpf_lib.c:1321:\tnetdev_rss_key_fill((void *)rss_data-\u003erss_key, rss_data-\u003erss_key_size);\ndrivers/net/ethernet/intel/idpf/idpf_lib.c-1322-\n--\ndrivers/net/ethernet/intel/igb/igb_main.c=4043=static int igb_sw_init(struct igb_adapter *adapter)\n--\ndrivers/net/ethernet/intel/igb/igb_main.c-4051-\t/* init RSS key */\ndrivers/net/ethernet/intel/igb/igb_main.c:4052:\tnetdev_rss_key_fill(adapter-\u003erss_key, sizeof(adapter-\u003erss_key));\ndrivers/net/ethernet/intel/igb/igb_main.c-4053-\n--\ndrivers/net/ethernet/intel/igc/igc_main.c=5041=static int igc_sw_init(struct igc_adapter *adapter)\n--\ndrivers/net/ethernet/intel/igc/igc_main.c-5049-\t/* init RSS key */\ndrivers/net/ethernet/intel/igc/igc_main.c:5050:\tnetdev_rss_key_fill(adapter-\u003erss_key, sizeof(adapter-\u003erss_key));\ndrivers/net/ethernet/intel/igc/igc_main.c-5051-\n--\ndrivers/net/ethernet/intel/ixgbe/ixgbe_main.c=4228=static inline int ixgbe_init_rss_key(struct ixgbe_adapter *adapter)\n--\ndrivers/net/ethernet/intel/ixgbe/ixgbe_main.c-4236-\ndrivers/net/ethernet/intel/ixgbe/ixgbe_main.c:4237:\t\tnetdev_rss_key_fill(rss_key, IXGBE_RSS_KEY_SIZE);\ndrivers/net/ethernet/intel/ixgbe/ixgbe_main.c-4238-\t\tadapter-\u003erss_key = rss_key;\n--\ndrivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c=1879=static inline int ixgbevf_init_rss_key(struct ixgbevf_adapter *adapter)\n--\ndrivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c-1887-\ndrivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:1888:\t\tnetdev_rss_key_fill(rss_key, IXGBEVF_RSS_HASH_KEY_SIZE);\ndrivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c-1889-\t\tadapter-\u003erss_key = rss_key;\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c=392=int otx2_rss_init(struct otx2_nic *pfvf)\n--\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c-400-\tif (!rss-\u003eenable)\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c:401:\t\tnetdev_rss_key_fill(rss-\u003ekey, sizeof(rss-\u003ekey));\ndrivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c-402-\totx2_set_rss_key(pfvf);\n--\ndrivers/net/ethernet/marvell/sky2.c=1282=static void rx_set_rss(struct net_device *dev, netdev_features_t features)\n--\ndrivers/net/ethernet/marvell/sky2.c-1297-\ndrivers/net/ethernet/marvell/sky2.c:1298:\t\tnetdev_rss_key_fill(rss_key, sizeof(rss_key));\ndrivers/net/ethernet/marvell/sky2.c-1299-\t\tfor (i = 0; i \u003c nkeys; i++)\n--\ndrivers/net/ethernet/mellanox/mlx4/en_netdev.c=3161=int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,\n--\ndrivers/net/ethernet/mellanox/mlx4/en_netdev.c-3209-\tpriv-\u003etx_work_limit = MLX4_EN_DEFAULT_TX_WORK;\ndrivers/net/ethernet/mellanox/mlx4/en_netdev.c:3210:\tnetdev_rss_key_fill(priv-\u003erss_key, sizeof(priv-\u003erss_key));\ndrivers/net/ethernet/mellanox/mlx4/en_netdev.c-3211-\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en/rss.c=185=static void mlx5e_rss_params_init(struct mlx5e_rss *rss)\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en/rss.c-190-\trss-\u003ehash.hfunc = ETH_RSS_HASH_TOP;\ndrivers/net/ethernet/mellanox/mlx5/core/en/rss.c:191:\tnetdev_rss_key_fill(rss-\u003ehash.toeplitz_hash_key,\ndrivers/net/ethernet/mellanox/mlx5/core/en/rss.c-192-\t\t\t    sizeof(rss-\u003ehash.toeplitz_hash_key));\n--\ndrivers/net/ethernet/microsoft/mana/mana_en.c=3807=static int mana_probe_port(struct mana_context *ac, int port_idx,\n--\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3864-\ndrivers/net/ethernet/microsoft/mana/mana_en.c:3865:\tnetdev_rss_key_fill(apc-\u003ehashkey, MANA_HASH_KEY_SIZE);\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3866-\n--\ndrivers/net/ethernet/netronome/nfp/nfp_net_common.c=2618=static void nfp_net_rss_init(struct nfp_net *nn)\n--\ndrivers/net/ethernet/netronome/nfp/nfp_net_common.c-2637-\ndrivers/net/ethernet/netronome/nfp/nfp_net_common.c:2638:\tnetdev_rss_key_fill(nn-\u003erss_key, nfp_net_rss_key_sz(nn));\ndrivers/net/ethernet/netronome/nfp/nfp_net_common.c-2639-\n--\ndrivers/net/ethernet/pensando/ionic/ionic_lif.c=3235=int ionic_lif_alloc(struct ionic *ionic)\n--\ndrivers/net/ethernet/pensando/ionic/ionic_lif.c-3348-\t}\ndrivers/net/ethernet/pensando/ionic/ionic_lif.c:3349:\tnetdev_rss_key_fill(lif-\u003erss_hash_key, IONIC_RSS_HASH_KEY_SIZE);\ndrivers/net/ethernet/pensando/ionic/ionic_lif.c-3350-\n--\ndrivers/net/ethernet/qlogic/qede/qede_filter.c=564=void qede_fill_rss_params(struct qede_dev *edev,\n--\ndrivers/net/ethernet/qlogic/qede/qede_filter.c-602-\tif (!(edev-\u003erss_params_inited \u0026 QEDE_RSS_KEY_INITED)) {\ndrivers/net/ethernet/qlogic/qede/qede_filter.c:603:\t\tnetdev_rss_key_fill(edev-\u003erss_key, sizeof(edev-\u003erss_key));\ndrivers/net/ethernet/qlogic/qede/qede_filter.c-604-\t\tedev-\u003erss_params_inited |= QEDE_RSS_KEY_INITED;\n--\ndrivers/net/ethernet/sfc/ef100_netdev.c=423=int ef100_probe_netdev(struct efx_probe_data *probe_data)\n--\ndrivers/net/ethernet/sfc/ef100_netdev.c-474-\ndrivers/net/ethernet/sfc/ef100_netdev.c:475:\tnetdev_rss_key_fill(efx-\u003erss_context.rx_hash_key,\ndrivers/net/ethernet/sfc/ef100_netdev.c-476-\t\t\t    sizeof(efx-\u003erss_context.rx_hash_key));\n--\ndrivers/net/ethernet/sfc/efx.c=259=static int efx_probe_nic(struct efx_nic *efx)\n--\ndrivers/net/ethernet/sfc/efx.c-301-\tif (efx-\u003en_channels \u003e 1)\ndrivers/net/ethernet/sfc/efx.c:302:\t\tnetdev_rss_key_fill(efx-\u003erss_context.rx_hash_key,\ndrivers/net/ethernet/sfc/efx.c-303-\t\t\t\t    sizeof(efx-\u003erss_context.rx_hash_key));\n--\ndrivers/net/ethernet/sfc/ethtool_common.c=1219=int efx_ethtool_create_rxfh_context(struct net_device *net_dev,\n--\ndrivers/net/ethernet/sfc/ethtool_common.c-1238-\tif (!rxfh-\u003ekey)\ndrivers/net/ethernet/sfc/ethtool_common.c:1239:\t\tnetdev_rss_key_fill(ethtool_rxfh_context_key(ctx),\ndrivers/net/ethernet/sfc/ethtool_common.c-1240-\t\t\t\t    ctx-\u003ekey_size);\n--\ndrivers/net/ethernet/sfc/falcon/efx.c=1607=static int ef4_probe_nic(struct ef4_nic *efx)\n--\ndrivers/net/ethernet/sfc/falcon/efx.c-1647-\tif (efx-\u003en_channels \u003e 1)\ndrivers/net/ethernet/sfc/falcon/efx.c:1648:\t\tnetdev_rss_key_fill(\u0026efx-\u003erx_hash_key,\ndrivers/net/ethernet/sfc/falcon/efx.c-1649-\t\t\t\t    sizeof(efx-\u003erx_hash_key));\n--\ndrivers/net/ethernet/sfc/siena/efx.c=267=static int efx_probe_nic(struct efx_nic *efx)\n--\ndrivers/net/ethernet/sfc/siena/efx.c-309-\tif (efx-\u003en_channels \u003e 1)\ndrivers/net/ethernet/sfc/siena/efx.c:310:\t\tnetdev_rss_key_fill(efx-\u003erss_context.rx_hash_key,\ndrivers/net/ethernet/sfc/siena/efx.c-311-\t\t\t\t    sizeof(efx-\u003erss_context.rx_hash_key));\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c=7875=static int __stmmac_dvr_probe(struct device *device,\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c-8070-\trxq = priv-\u003eplat-\u003erx_queues_to_use;\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c:8071:\tnetdev_rss_key_fill(priv-\u003erss.key, sizeof(priv-\u003erss.key));\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c-8072-\tfor (i = 0; i \u003c ARRAY_SIZE(priv-\u003erss.table); i++)\n--\ndrivers/net/ethernet/synopsys/dwc-xlgmac-common.c=65=static int xlgmac_init(struct xlgmac_pdata *pdata)\n--\ndrivers/net/ethernet/synopsys/dwc-xlgmac-common.c-151-\t/* Initialize RSS hash key and lookup table */\ndrivers/net/ethernet/synopsys/dwc-xlgmac-common.c:152:\tnetdev_rss_key_fill(pdata-\u003erss_key, sizeof(pdata-\u003erss_key));\ndrivers/net/ethernet/synopsys/dwc-xlgmac-common.c-153-\n--\ndrivers/net/ethernet/wangxun/libwx/wx_hw.c=2456=static int wx_init_rss_key(struct wx *wx)\n--\ndrivers/net/ethernet/wangxun/libwx/wx_hw.c-2464-\ndrivers/net/ethernet/wangxun/libwx/wx_hw.c:2465:\t\tnetdev_rss_key_fill(rss_key, WX_RSS_KEY_SIZE);\ndrivers/net/ethernet/wangxun/libwx/wx_hw.c-2466-\t\twx-\u003erss_key = rss_key;\n--\ndrivers/net/ethernet/wangxun/libwx/wx_vf_lib.c=208=void wx_setup_vfmrqc_vf(struct wx *wx)\n--\ndrivers/net/ethernet/wangxun/libwx/wx_vf_lib.c-214-\t/* Fill out hash function seeds */\ndrivers/net/ethernet/wangxun/libwx/wx_vf_lib.c:215:\tnetdev_rss_key_fill(wx-\u003erss_key, WX_RSS_KEY_SIZE);\ndrivers/net/ethernet/wangxun/libwx/wx_vf_lib.c-216-\tfor (i = 0; i \u003c WX_RSS_KEY_SIZE / 4; i++)\n--\ndrivers/net/virtio_net.c=4251=static void virtnet_init_default_rss(struct virtnet_info *vi)\n--\ndrivers/net/virtio_net.c-4262-\ndrivers/net/virtio_net.c:4263:\tnetdev_rss_key_fill(vi-\u003erss_hash_key_data, vi-\u003erss_key_size);\ndrivers/net/virtio_net.c-4264-}\n--\ndrivers/net/vmxnet3/vmxnet3_drv.c=2899=vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)\n--\ndrivers/net/vmxnet3/vmxnet3_drv.c-3012-\t\trssConf-\u003eindTableSize = VMXNET3_RSS_IND_TABLE_SIZE;\ndrivers/net/vmxnet3/vmxnet3_drv.c:3013:\t\tnetdev_rss_key_fill(rssConf-\u003ehashKey, sizeof(rssConf-\u003ehashKey));\ndrivers/net/vmxnet3/vmxnet3_drv.c-3014-\n--\ndrivers/net/wireless/intel/iwlwifi/mld/fw.c=35=static int iwl_mld_send_rss_cfg_cmd(struct iwl_mld *mld)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/fw.c-52-\t\t\t1 + (i % (mld-\u003etrans-\u003einfo.num_rxqs - 1));\ndrivers/net/wireless/intel/iwlwifi/mld/fw.c:53:\tnetdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));\ndrivers/net/wireless/intel/iwlwifi/mld/fw.c-54-\n--\ndrivers/net/wireless/intel/iwlwifi/mvm/debugfs.c=1214=static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm,\n--\ndrivers/net/wireless/intel/iwlwifi/mvm/debugfs.c-1247-\ndrivers/net/wireless/intel/iwlwifi/mvm/debugfs.c:1248:\tnetdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));\ndrivers/net/wireless/intel/iwlwifi/mvm/debugfs.c-1249-\n--\ndrivers/net/wireless/intel/iwlwifi/mvm/fw.c=47=static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm)\n--\ndrivers/net/wireless/intel/iwlwifi/mvm/fw.c-66-\t\t\t1 + (i % (mvm-\u003etrans-\u003einfo.num_rxqs - 1));\ndrivers/net/wireless/intel/iwlwifi/mvm/fw.c:67:\tnetdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));\ndrivers/net/wireless/intel/iwlwifi/mvm/fw.c-68-\n--\ninclude/linux/netdevice.h=5326=extern u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly;\ninclude/linux/netdevice.h:5327:void netdev_rss_key_fill(void *buffer, size_t len);\ninclude/linux/netdevice.h-5328-\n--\nnet/Kconfig=543=config ETHTOOL_RSS_KEY_KUNIT_TEST\n--\nnet/Kconfig-547-\thelp\nnet/Kconfig:548:\t  KUnit tests checking the RSS key that netdev_rss_key_fill() hands\nnet/Kconfig-549-\t  to the drivers: flows differing only in the low order bits of one\n--\nnet/core/sysctl_net_core.c=335=static int proc_do_rss_key(const struct ctl_table *table, int write,\n--\nnet/core/sysctl_net_core.c-343-\tinitialized = READ_ONCE(netdev_rss_key_initialized);\nnet/core/sysctl_net_core.c:344:\t/* Pair with smp_wmb() in netdev_rss_key_fill(). */\nnet/core/sysctl_net_core.c-345-\tsmp_rmb();\n--\nnet/ethtool/common.h-17-\nnet/ethtool/common.h:18:/* netdev_rss_key_fill() guarantees that flows differing only in the low order\nnet/ethtool/common.h-19- * bits of one hashed header field spread over all the RX queues, for any queue\n--\nnet/ethtool/ioctl.c=1472=EXPORT_SYMBOL_IF_KUNIT(netdev_rss_key_init);\nnet/ethtool/ioctl.c-1473-\nnet/ethtool/ioctl.c:1474:void netdev_rss_key_fill(void *buffer, size_t len)\nnet/ethtool/ioctl.c-1475-{\n--\nnet/ethtool/ioctl.c-1479-}\nnet/ethtool/ioctl.c:1480:EXPORT_SYMBOL(netdev_rss_key_fill);\nnet/ethtool/ioctl.c-1481-\n--\nnet/ethtool/rss_key_test.c-1-// SPDX-License-Identifier: GPL-2.0-only\nnet/ethtool/rss_key_test.c:2:/* Tests for the RSS key generated by netdev_rss_key_fill().\nnet/ethtool/rss_key_test.c-3- *\n--\nnet/ethtool/rss_key_test.c=311=kunit_test_suite(rss_key_test_suite);\nnet/ethtool/rss_key_test.c-312-\nnet/ethtool/rss_key_test.c:313:MODULE_DESCRIPTION(\"Tests for the RSS key generated by netdev_rss_key_fill()\");\nnet/ethtool/rss_key_test.c-314-MODULE_LICENSE(\"GPL\");\n--\ntools/testing/selftests/drivers/net/hw/rss_key.py=6=entries of its indirection table.\ntools/testing/selftests/drivers/net/hw/rss_key.py-7-\ntools/testing/selftests/drivers/net/hw/rss_key.py:8:Most drivers take their key from netdev_rss_key_fill(), which generates keys\ntools/testing/selftests/drivers/net/hw/rss_key.py-9-having that property, but some bring their own and firmware sometimes\n--\ntools/testing/selftests/net/lib/py/rsskey.py=13=field and a given q with probability 1/2.\ntools/testing/selftests/net/lib/py/rsskey.py-14-\ntools/testing/selftests/net/lib/py/rsskey.py:15:netdev_rss_key_fill() generates keys that are non singular for every field of\ntools/testing/selftests/net/lib/py/rsskey.py-16-the hash input and every q up to RSS_KEY_QMAX.\n--\ntools/testing/selftests/net/netdev_rss_key.py=5=Check the quality of the host RSS key, /proc/sys/net/core/netdev_rss_key.\ntools/testing/selftests/net/netdev_rss_key.py-6-\ntools/testing/selftests/net/netdev_rss_key.py:7:This is the key netdev_rss_key_fill() hands to the drivers. It has to be non\ntools/testing/selftests/net/netdev_rss_key.py-8-singular for every field of the hash input and every queue count up to\n--\ntools/testing/selftests/net/netdev_rss_key.py=13=The key is generated lazily, the first time a driver asks for it, so this\ntools/testing/selftests/net/netdev_rss_key.py:14:test skips until a driver has done so. Any NIC calling netdev_rss_key_fill()\ntools/testing/selftests/net/netdev_rss_key.py-15-is enough; in a virtual machine, virtio_net does it from\n--\ntools/testing/selftests/net/netdev_rss_key.py=33=def _read_key():\n--\ntools/testing/selftests/net/netdev_rss_key.py-44-        raise KsftSkipEx(\"the host RSS key has not been generated yet, \"\ntools/testing/selftests/net/netdev_rss_key.py:45:                         \"no driver has called netdev_rss_key_fill()\")\ntools/testing/selftests/net/netdev_rss_key.py-46-\n--\ntools/testing/selftests/net/netdev_rss_key.py=80=def check_grid() -\u003e None:\n--\ntools/testing/selftests/net/netdev_rss_key.py-82-\ntools/testing/selftests/net/netdev_rss_key.py:83:    netdev_rss_key_fill() does not get to know what the hardware hashes, so\ntools/testing/selftests/net/netdev_rss_key.py-84-    it gives the property at every 16-bit aligned position of the key. A NIC\n"
}

63/3 2026/09/23 18:14 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 42124
							output: 35
							thoughts: 1808
						

Thoughts:
**Analyzing Potential Uninitialized Memory Reads in RSS Key Handling**

Okay, let's break this down systematically. I'm looking at the `netdev_rss_key_fill` function and its related functions, specifically with an eye towards potential uninitialized memory reads. My focus is on where data might be used before it's been properly set.

First, `netdev_rss_key_fill` itself. It takes a `buffer` and `len`. It calls `DO_ONCE` on `netdev_rss_key_init`. The function copies `len` bytes from `netdev_rss_key` to `buffer`. The `netdev_rss_key` is initialized by `netdev_rss_key_init`.

Inside `netdev_rss_key_init`, the `get_random_bytes` function initializes the entire 256-byte `netdev_rss_key` with random data. Then, some fields are fixed, and alias checks are performed. The critical point is that all 256 bytes are fully initialized before `memcpy` copies them to the provided `buffer`.

My first thought was, is it possible for `netdev_rss_key_init` to read uninitialized memory? No, because it starts by calling `get_random_bytes(key, len)`. The `key` (which is `netdev_rss_key`) is fully initialized by this call.

Next, I examined the `netdev_rss_key_aliases` function. I was concerned about the `windows` array, which is local to the function. It is initialized in a loop. The key check is that `windows[i]` is always initialized before it's read. The counter `n` is incremented after writing `windows[n++]`. Also, the maximum size of `n` is computed: `(len * 8 - 32 - r) / 16 + 1`. This never exceeds the array bound.

I turned my attention to the KUnit test `rss_key_test.c`. Given that KUnit uses zero-initialized memory allocation via `kunit_kzalloc` or `kunit_kcalloc`, I'm confident that the memory used in those tests is safe. The input is allocated via `kunit_kzalloc`, and filled with random data so this confirms what I thought.

Finally, I got to the `proc_do_rss_key` function in `sysctl_net_core.c`. This is where I got a bit of a scare initially. The introduction of `struct ctl_table fake_table;` on the stack seemed concerning. *However*, on closer inspection of the original code, the structure was *already* present, even before the patch. The patch didn't introduce it. Furthermore, it's just used to pass data to `proc_dostring` and it's initialized with the buffer and size, so I don't see any risk there. The code constructs a string representation of `netdev_rss_key`, which may or may not be initialized depending on `netdev_rss_key_initialized`. It appears that the code is safe and there are no instances of reading uninitialized memory.



64/3 2026/09/23 18:14 tool read-file
0m Args:
{
  "File": "kernel/sysctl.c",
  "FirstLine": 1270,
  "LineCount": 40
}

Results:
{
  "Contents": "1270:\tint proc_dostring(const struct ctl_table *table, int dir,\n1271:\t\t\t  void *buffer, size_t *lenp, loff_t *ppos)\n1272:\t{\n1273:\t\treturn -ENOSYS;\n1274:\t}\n1275:\t\n1276:\tint proc_dobool(const struct ctl_table *table, int dir,\n1277:\t\t\tvoid *buffer, size_t *lenp, loff_t *ppos)\n1278:\t{\n1279:\t\treturn -ENOSYS;\n1280:\t}\n1281:\t\n1282:\tint proc_dointvec(const struct ctl_table *table, int dir,\n1283:\t\t\t  void *buffer, size_t *lenp, loff_t *ppos)\n1284:\t{\n1285:\t\treturn -ENOSYS;\n1286:\t}\n1287:\t\n1288:\tint proc_douintvec(const struct ctl_table *table, int dir,\n1289:\t\t\t  void *buffer, size_t *lenp, loff_t *ppos)\n1290:\t{\n1291:\t\treturn -ENOSYS;\n1292:\t}\n1293:\t\n1294:\tint proc_dointvec_minmax(const struct ctl_table *table, int dir,\n1295:\t\t\t    void *buffer, size_t *lenp, loff_t *ppos)\n1296:\t{\n1297:\t\treturn -ENOSYS;\n1298:\t}\n1299:\t\n1300:\tint proc_douintvec_minmax(const struct ctl_table *table, int dir,\n1301:\t\t\t\t  void *buffer, size_t *lenp, loff_t *ppos)\n1302:\t{\n1303:\t\treturn -ENOSYS;\n1304:\t}\n1305:\t\n1306:\tint proc_douintvec_conv(const struct ctl_table *table, int write, void *buffer,\n1307:\t\t\t\tsize_t *lenp, loff_t *ppos,\n1308:\t\t\t\tint (*conv)(bool *negp, ulong *lvalp, uint *valp,\n1309:\t\t\t\t\t    int write, const struct ctl_table *table))\n"
}

65/3 2026/09/23 18:14 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 45312
							output: 34
							thoughts: 28
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:

**Diving into the `proc_dostring` Implementation**

Alright, let's get down to brass tacks. I need to understand the specifics of how `proc_dostring` is implemented. I know it handles string-based sysctl entries, and I've got a handle on the general flow, but I need to see the *actual* code. Let's head straight to the source. Specifically, I want to zero in on line 189 within `kernel/sysctl.c`. That's likely where the core logic of `proc_dostring` is defined, or at least where the relevant portion of the function is located. That's the part I need to scrutinize to really grok how it functions. I'll probably be looking for how it handles reads, writes, error conditions, string length limitations, and any potential security implications that might arise. Let's see what gems are hidden in there.



66/3 2026/09/23 18:14 tool read-file
0m Args:
{
  "File": "kernel/sysctl.c",
  "FirstLine": 185,
  "LineCount": 40
}

Results:
{
  "Contents": " 185:\t * not large enough.\n 186:\t *\n 187:\t * Returns: %0 on success.\n 188:\t */\n 189:\tint proc_dostring(const struct ctl_table *table, int dir,\n 190:\t\t\t  void *buffer, size_t *lenp, loff_t *ppos)\n 191:\t{\n 192:\t\tif (SYSCTL_USER_TO_KERN(dir))\n 193:\t\t\tproc_first_pos_non_zero_ignore(ppos, table);\n 194:\t\n 195:\t\treturn _proc_do_string(table-\u003edata, table-\u003emaxlen, dir, buffer, lenp,\n 196:\t\t\t\tppos);\n 197:\t}\n 198:\t\n 199:\tstatic void proc_skip_spaces(char **buf, size_t *size)\n 200:\t{\n 201:\t\twhile (*size) {\n 202:\t\t\tif (!isspace(**buf))\n 203:\t\t\t\tbreak;\n 204:\t\t\t(*size)--;\n 205:\t\t\t(*buf)++;\n 206:\t\t}\n 207:\t}\n 208:\t\n 209:\tstatic void proc_skip_char(char **buf, size_t *size, const char v)\n 210:\t{\n 211:\t\twhile (*size) {\n 212:\t\t\tif (**buf != v)\n 213:\t\t\t\tbreak;\n 214:\t\t\t(*size)--;\n 215:\t\t\t(*buf)++;\n 216:\t\t}\n 217:\t}\n 218:\t\n 219:\t/**\n 220:\t * strtoul_lenient - parse an ASCII formatted integer from a buffer and only\n 221:\t *                   fail on overflow\n 222:\t *\n 223:\t * @cp: kernel buffer containing the string to parse\n 224:\t * @endp: pointer to store the trailing characters\n"
}

67/3 2026/09/23 18:14 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 46141
							output: 381
							thoughts: 1091
						

Thoughts:
**Analyzing the Patch for Uninitialized Memory Risks**

Okay, let's break this down. My initial focus was on `proc_dostring`, but after a quick check, it's clear the relevant fields, `table->data` and `table->maxlen`, are already initialized and untouched by this patch. So, my attention needs to shift to the broader scope.

I'm seeing a lot of activity related to RSS key generation, specifically in `net/ethtool/ioctl.c`. I need to meticulously examine this section. I will check for any memory access issues in the provided routines:

1.  `netdev_rss_key_bit`: Simple bit-level access within an initialized key. Safe.
2.  `netdev_rss_key_assign_bit`: Reads and modifies within the key's allocated memory. Also safe.
3.  `netdev_rss_key_fixup_field`: Okay, this one warrants closer attention. I see a stack array `d[]` that is completely initialized through multiple loops, and then the final loop correctly writes this memory back. No risks there.
4.  `netdev_rss_key_window`: Accessing a "window" of the key. Key memory is initialized via `get_random_bytes` so this access is safe.
5.  `netdev_rss_key_aliases`: Uses the stack array `windows[]`, but writes to each element before reading it. No issues.
6.  `netdev_rss_key_init`: Initializes the entire key buffer with `get_random_bytes` and sets `netdev_rss_key_initialized` using `smp_wmb()`. Good. This ensures the key is initialized before use.
7.  `netdev_rss_key_fill`: Copies from `netdev_rss_key`, which is now confirmed as initialized, to `buffer`. Safe.

So, I'm going through all the key routines, double-checking, and I'm concluding that *every* buffer and variable involved is fully initialized before use.

Specifically:

*   `netdev_rss_key` gets initialized with `get_random_bytes`.
*   The stack array `d` in `netdev_rss_key_fixup_field` is fully populated.
*   The stack array `windows` in `netdev_rss_key_aliases` is written before read up to `n`.
*   The stack buffer `buf` in `proc_do_rss_key` is fully overwritten with formatted hex characters and terminated.
*   `netdev_rss_key_initialized` makes sure there is no read of the memory before the initialization happens through sysctl.
*   No padding leaks or partial copies.
*   No conditional branches depending on uninitialized variables.

Therefore, I'm confident that this patch *does not* introduce any new uninitialized memory risks. Any memory safety issues that might exist (like out-of-bounds array access or buffer overruns) would be caught by KASAN or a standard debugger, but not KMSAN.

So, the `NeedsKMSAN` flag is false here. I'm ready to write my final response.



68/3 2026/09/23 18:14 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch series enhances the Toeplitz RSS key generation in netdev_rss_key_fill() to ensure non-singularity and avoid collisions across receive queues, adds associated sysctl synchronization, and introduces KUnit and selftests.\n\nAnalysis of uninitialized memory and information leak risks:\n1. All buffers and arrays introduced or modified are properly initialized:\n   - In `netdev_rss_key_init()`, `get_random_bytes()` initializes the entire key buffer before any fixup operations are performed.\n   - The stack array `d` in `netdev_rss_key_fixup_field()` is completely populated in an initial loop prior to any reads.\n   - In `netdev_rss_key_aliases()`, stack array `windows` is populated sequentially up to `n`, and only elements in range `[0, n)` are subsequently read.\n   - In `proc_do_rss_key()`, the output string buffer `buf` is completely written with hex bytes and a null terminator before being passed to `proc_dostring()`. Furthermore, an explicit `netdev_rss_key_initialized` barrier prevents reading `netdev_rss_key` prior to initialization.\n   - The KUnit tests use zero-initialized memory allocations (`kunit_kzalloc` / `kunit_kcalloc`).\n2. No kernel structures with padding or uninitialized fields are exposed or copied to user space.\n3. No conditional branches or control flow decisions rely on uninitialized values.\n\nAny potential bounds or overflow issues would be covered by standard KASAN/UBSAN builds. A dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Results:
{
  "KMSANReasoning": "The patch series enhances the Toeplitz RSS key generation in netdev_rss_key_fill() to ensure non-singularity and avoid collisions across receive queues, adds associated sysctl synchronization, and introduces KUnit and selftests.\n\nAnalysis of uninitialized memory and information leak risks:\n1. All buffers and arrays introduced or modified are properly initialized:\n   - In `netdev_rss_key_init()`, `get_random_bytes()` initializes the entire key buffer before any fixup operations are performed.\n   - The stack array `d` in `netdev_rss_key_fixup_field()` is completely populated in an initial loop prior to any reads.\n   - In `netdev_rss_key_aliases()`, stack array `windows` is populated sequentially up to `n`, and only elements in range `[0, n)` are subsequently read.\n   - In `proc_do_rss_key()`, the output string buffer `buf` is completely written with hex bytes and a null terminator before being passed to `proc_dostring()`. Furthermore, an explicit `netdev_rss_key_initialized` barrier prevents reading `netdev_rss_key` prior to initialization.\n   - The KUnit tests use zero-initialized memory allocations (`kunit_kzalloc` / `kunit_kcalloc`).\n2. No kernel structures with padding or uninitialized fields are exposed or copied to user space.\n3. No conditional branches or control flow decisions rely on uninitialized values.\n\nAny potential bounds or overflow issues would be covered by standard KASAN/UBSAN builds. A dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)