summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2026-09-09 13:35:31 -0700
committerJakub Kicinski <kuba@kernel.org>2026-09-09 13:35:31 -0700
commit3677055a7969b0a6a3f47a6eecb1ecfc444b96bb (patch)
treed6b2d528686e2aa541aaaaa43110ee9543a040cc
parent3929f55da21fb76d931f464c71d2fd27762ef7d8 (diff)
parenta995686117646acb094981c04a6215cef4a329f0 (diff)
downloadlinux-next-3677055a7969b0a6a3f47a6eecb1ecfc444b96bb.tar.gz
linux-next-3677055a7969b0a6a3f47a6eecb1ecfc444b96bb.zip
Merge branch 'netdevsim-fix-ipsec-debugfs-byte-order'
Andrei Gherzan says: ==================== netdevsim: fix IPsec debugfs byte order The netdevsim IPsec debugfs file (used by selftests/net/rtnetlink.sh's ipsec_offload subtest) prints the SA salt and key in host CPU byte order instead of network byte order, because nsim_sa.key[]/salt are typed as plain u32 and printed directly with "%08x". This makes the reported values differ between little-endian and big-endian hosts for the same underlying key material, and breaks the selftest on big-endian (e.g. s390x), which hardcodes the little-endian output. A driver-side fix was proposed in 2022 but stalled in review: keeping the fields as plain u32 meant sparse could not validate the added ntohl()/be32_to_cpu() conversions. https://lore.kernel.org/20220308135106.890270-1-kleber.souza@canonical.com ==================== Link: https://patch.msgid.link/20260908140325.13367-1-andrei.gherzan@canonical.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--drivers/net/netdevsim/ipsec.c10
-rw-r--r--drivers/net/netdevsim/netdevsim.h4
-rwxr-xr-xtools/testing/selftests/net/rtnetlink.sh8
3 files changed, 11 insertions, 11 deletions
diff --git a/drivers/net/netdevsim/ipsec.c b/drivers/net/netdevsim/ipsec.c
index 36a1be4923d6..5722837bcda3 100644
--- a/drivers/net/netdevsim/ipsec.c
+++ b/drivers/net/netdevsim/ipsec.c
@@ -50,11 +50,11 @@ static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,
p += scnprintf(p, bufsize - (p - buf),
"sa[%i] spi=0x%08x proto=0x%x salt=0x%08x crypt=%d\n",
i, be32_to_cpu(sap->xs->id.spi),
- sap->xs->id.proto, sap->salt, sap->crypt);
+ sap->xs->id.proto, be32_to_cpu(sap->salt), sap->crypt);
p += scnprintf(p, bufsize - (p - buf),
"sa[%i] key=0x%08x %08x %08x %08x\n",
- i, sap->key[0], sap->key[1],
- sap->key[2], sap->key[3]);
+ i, be32_to_cpu(sap->key[0]), be32_to_cpu(sap->key[1]),
+ be32_to_cpu(sap->key[2]), be32_to_cpu(sap->key[3]));
}
len = simple_read_from_buffer(buffer, count, ppos, buf, p - buf);
@@ -87,7 +87,7 @@ static int nsim_ipsec_find_empty_idx(struct nsim_ipsec *ipsec)
static int nsim_ipsec_parse_proto_keys(struct net_device *dev,
struct xfrm_state *xs,
- u32 *mykey, u32 *mysalt)
+ __be32 *mykey, __be32 *mysalt)
{
const char aes_gcm_name[] = "rfc4106(gcm(aes))";
unsigned char *key_data;
@@ -117,7 +117,7 @@ static int nsim_ipsec_parse_proto_keys(struct net_device *dev,
/* 160 accounts for 16 byte key and 4 byte salt */
if (key_len > NSIM_IPSEC_AUTH_BITS) {
- *mysalt = ((u32 *)key_data)[4];
+ *mysalt = ((__be32 *)key_data)[4];
} else if (key_len == NSIM_IPSEC_AUTH_BITS) {
*mysalt = 0;
} else {
diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h
index 181b6baaba7a..eb9d684e3bcc 100644
--- a/drivers/net/netdevsim/netdevsim.h
+++ b/drivers/net/netdevsim/netdevsim.h
@@ -42,8 +42,8 @@
struct nsim_sa {
struct xfrm_state *xs;
__be32 ipaddr[4];
- u32 key[4];
- u32 salt;
+ __be32 key[4];
+ __be32 salt;
bool used;
bool crypt;
bool rx;
diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index ace3a99023ed..4843d474538f 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -932,11 +932,11 @@ kci_test_ipsec_offload()
run_cmd diff $sysfsf - << EOF
SA count=2 tx=3
sa[0] tx ipaddr=$dstip
-sa[0] spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1
-sa[0] key=0x34333231 38373635 32313039 36353433
+sa[0] spi=0x00000009 proto=0x32 salt=0x64636261 crypt=1
+sa[0] key=0x31323334 35363738 39303132 33343536
sa[1] rx ipaddr=$srcip
-sa[1] spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1
-sa[1] key=0x34333231 38373635 32313039 36353433
+sa[1] spi=0x00000009 proto=0x32 salt=0x64636261 crypt=1
+sa[1] key=0x31323334 35363738 39303132 33343536
EOF
if [ $? -ne 0 ] ; then
end_test "FAIL: ipsec_offload incorrect driver data"