handshake: Fix sign of key_serial_t fields
authorChuck Lever <chuck.lever@oracle.com>
Thu, 21 Sep 2023 13:08:07 +0000 (09:08 -0400)
committerJakub Kicinski <kuba@kernel.org>
Mon, 2 Oct 2023 19:34:21 +0000 (12:34 -0700)
key_serial_t fields are signed integers. Use nla_get/put_s32 for
those to avoid implicit signed conversion in the netlink protocol.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/169530167716.8905.645746457741372879.stgit@oracle-102.nfsv4bat.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/netlink/specs/handshake.yaml
net/handshake/tlshd.c
tools/net/ynl/generated/handshake-user.h

index a49b46b80e1650385e17d6c5ab382dd0f5f67301..b934cc513e3d6f3d99e3bdf2bfb70612ff0fe8c6 100644 (file)
@@ -34,10 +34,10 @@ attribute-sets:
     attributes:
       -
         name: cert
-        type: u32
+        type: s32
       -
         name: privkey
-        type: u32
+        type: s32
   -
     name: accept
     attributes:
index 7ac80201aa1fc29857cc631add551cf8743e8e89..d697f68c598c981244fb3e5f51176aeffe08f93b 100644 (file)
@@ -173,9 +173,9 @@ static int tls_handshake_put_certificate(struct sk_buff *msg,
        if (!entry_attr)
                return -EMSGSIZE;
 
-       if (nla_put_u32(msg, HANDSHAKE_A_X509_CERT,
+       if (nla_put_s32(msg, HANDSHAKE_A_X509_CERT,
                        treq->th_certificate) ||
-           nla_put_u32(msg, HANDSHAKE_A_X509_PRIVKEY,
+           nla_put_s32(msg, HANDSHAKE_A_X509_PRIVKEY,
                        treq->th_privkey)) {
                nla_nest_cancel(msg, entry_attr);
                return -EMSGSIZE;
index f8e481fa9e09b20188cee77274476692f4fc4662..2b34acc608dea51b72c18980190e2c4f59a50102 100644 (file)
@@ -28,8 +28,8 @@ struct handshake_x509 {
                __u32 privkey:1;
        } _present;
 
-       __u32 cert;
-       __u32 privkey;
+       __s32 cert;
+       __s32 privkey;
 };
 
 /* ============== HANDSHAKE_CMD_ACCEPT ============== */