Skip to content

Commit 6ed3d14

Browse files
Florian Westphaljgunthorpe
authored andcommitted
RDMA/core: Prefer NLA_NUL_STRING
These attributes are evaluated as c-string (passed to strcmp), but NLA_STRING doesn't check for the presence of a \0 terminator. Either this needs to switch to nla_strcmp() and needs to adjust printf fmt specifier to not use plain %s, or this needs to use NLA_NUL_STRING. As the code has been this way for long time, it seems to me that userspace does include the terminating nul, even tough its not enforced so far, and thus NLA_NUL_STRING use is the simpler solution. Fixes: 30dc5e6 ("RDMA/core: Add support for iWARP Port Mapper user space service") Link: https://patch.msgid.link/r/20260330122742.13315-1-fw@strlen.de Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 973403c commit 6ed3d14

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/infiniband/core/iwpm_msg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,9 @@ int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client)
365365
/* netlink attribute policy for the received response to register pid request */
366366
static const struct nla_policy resp_reg_policy[IWPM_NLA_RREG_PID_MAX] = {
367367
[IWPM_NLA_RREG_PID_SEQ] = { .type = NLA_U32 },
368-
[IWPM_NLA_RREG_IBDEV_NAME] = { .type = NLA_STRING,
368+
[IWPM_NLA_RREG_IBDEV_NAME] = { .type = NLA_NUL_STRING,
369369
.len = IWPM_DEVNAME_SIZE - 1 },
370-
[IWPM_NLA_RREG_ULIB_NAME] = { .type = NLA_STRING,
370+
[IWPM_NLA_RREG_ULIB_NAME] = { .type = NLA_NUL_STRING,
371371
.len = IWPM_ULIBNAME_SIZE - 1 },
372372
[IWPM_NLA_RREG_ULIB_VER] = { .type = NLA_U16 },
373373
[IWPM_NLA_RREG_PID_ERR] = { .type = NLA_U16 }
@@ -677,7 +677,7 @@ int iwpm_remote_info_cb(struct sk_buff *skb, struct netlink_callback *cb)
677677

678678
/* netlink attribute policy for the received request for mapping info */
679679
static const struct nla_policy resp_mapinfo_policy[IWPM_NLA_MAPINFO_REQ_MAX] = {
680-
[IWPM_NLA_MAPINFO_ULIB_NAME] = { .type = NLA_STRING,
680+
[IWPM_NLA_MAPINFO_ULIB_NAME] = { .type = NLA_NUL_STRING,
681681
.len = IWPM_ULIBNAME_SIZE - 1 },
682682
[IWPM_NLA_MAPINFO_ULIB_VER] = { .type = NLA_U16 }
683683
};

0 commit comments

Comments
 (0)