提交 869cbeef 编写于 作者: O Ondrej Mosnacek 提交者: Paul Moore

lsm_audit,selinux: pass IB device name by reference

While trying to address a Coverity warning that the dev_name string
might end up unterminated when strcpy'ing it in
selinux_ib_endport_manage_subnet(), I realized that it is possible (and
simpler) to just pass the dev_name pointer directly, rather than copying
the string to a buffer.

The ibendport variable goes out of scope at the end of the function
anyway, so the lifetime of the dev_name pointer will never be shorter
than that of ibendport, thus we can safely just pass the dev_name
pointer and be done with it.
Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
Acked-by: NRichard Guy Briggs <rgb@redhat.com>
Signed-off-by: NPaul Moore <paul@paul-moore.com>
上级 fd781f45
...@@ -53,7 +53,7 @@ struct lsm_ibpkey_audit { ...@@ -53,7 +53,7 @@ struct lsm_ibpkey_audit {
}; };
struct lsm_ibendport_audit { struct lsm_ibendport_audit {
char dev_name[IB_DEVICE_NAME_MAX]; const char *dev_name;
u8 port; u8 port;
}; };
......
...@@ -6850,7 +6850,7 @@ static int selinux_ib_endport_manage_subnet(void *ib_sec, const char *dev_name, ...@@ -6850,7 +6850,7 @@ static int selinux_ib_endport_manage_subnet(void *ib_sec, const char *dev_name,
return err; return err;
ad.type = LSM_AUDIT_DATA_IBENDPORT; ad.type = LSM_AUDIT_DATA_IBENDPORT;
strncpy(ibendport.dev_name, dev_name, sizeof(ibendport.dev_name)); ibendport.dev_name = dev_name;
ibendport.port = port_num; ibendport.port = port_num;
ad.u.ibendport = &ibendport; ad.u.ibendport = &ibendport;
return avc_has_perm(&selinux_state, return avc_has_perm(&selinux_state,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册