Skip to contentSkip to conversation

LSM: Fix type of id parameter in kernel_post_load_data prototype

PATCH In review Nathan Chancellor 2 participants 2 messages Oct 6, 2020 – Oct 7, 2020 Security (LSM)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 LSM: Fix type of id parameter in kernel_post_load_data prototype

Clang warns:

security/security.c:1716:59: warning: implicit conversion from enumeration type 'enum kernel_load_data_id' to different enumeration type 'enum kernel_read_file_id' [-Wenum-conversion]
ret = call_int_hook(kernel_post_load_data, 0, buf, size, id,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
security/security.c:715:22: note: expanded from macro 'call_int_hook'

                        RC = P->hook.FUNC(__VA_ARGS__);         \
                             ~            ^~~~~~~~~~~

1 warning generated.

There is a mismatch between the id parameter type in security_kernel_post_load_data and the function pointer prototype that is created by the LSM_HOOK macro in the security_list_options union. Fix the type in the LSM_HOOK macro as 'enum kernel_load_data_id' is what is expected.

Fixes b64fcae74b6d ("LSM: Introduce kernel_post_load_data() hook")
---
 include/linux/lsm_hook_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/lsm_hook_defs.h +1 -1
index d67cb3502310..32a940117e7a 100644
@@ -186,7 +186,7 @@ LSM_HOOK(int, 0, kernel_create_files_as, struct cred *new, struct inode *inode)
 LSM_HOOK(int, 0, kernel_module_request, char *kmod_name)
 LSM_HOOK(int, 0, kernel_load_data, enum kernel_load_data_id id, bool contents)
 LSM_HOOK(int, 0, kernel_post_load_data, char *buf, loff_t size,
-	 enum kernel_read_file_id id, char *description)
+	 enum kernel_load_data_id id, char *description)
 LSM_HOOK(int, 0, kernel_read_file, struct file *file,
 	 enum kernel_read_file_id id, bool contents)
 LSM_HOOK(int, 0, kernel_post_read_file, struct file *file, char *buf,

base-commit: dba8648dcab90564b8a11c952c06a9e1153506fb

Signature · 1 line
2.29.0.rc0
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines · Nathan Chancellor

Clang warns:

security/security.c:1716:59: warning: implicit conversion from enumeration type 'enum kernel_load_data_id' to different enumeration type 'enum kernel_read_file_id' [-Wenum-conversion]
ret = call_int_hook(kernel_post_load_data, 0, buf, size, id,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
security/security.c:715:22: note: expanded from macro 'call_int_hook'

                        RC = P->hook.FUNC(__VA_ARGS__);         \
                             ~            ^~~~~~~~~~~

1 warning generated.

There is a mismatch between the id parameter type in security_kernel_post_load_data and the function pointer prototype that is created by the LSM_HOOK macro in the security_list_options union. Fix the type in the LSM_HOOK macro as 'enum kernel_load_data_id' is what is expected.

Quoted 3 lines
Fixes b64fcae74b6d ("LSM: Introduce kernel_post_load_data() hook")

Ah yes; thank you! Greg, can you add this to your tree?

-Kees

Quoted 22 lines
---
 include/linux/lsm_hook_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/lsm_hook_defs.h +1 -1
index d67cb3502310..32a940117e7a 100644
@@ -186,7 +186,7 @@ LSM_HOOK(int, 0, kernel_create_files_as, struct cred *new, struct inode *inode)
 LSM_HOOK(int, 0, kernel_module_request, char *kmod_name)
 LSM_HOOK(int, 0, kernel_load_data, enum kernel_load_data_id id, bool contents)
 LSM_HOOK(int, 0, kernel_post_load_data, char *buf, loff_t size,
-	 enum kernel_read_file_id id, char *description)
+	 enum kernel_load_data_id id, char *description)
 LSM_HOOK(int, 0, kernel_read_file, struct file *file,
 	 enum kernel_read_file_id id, bool contents)
 LSM_HOOK(int, 0, kernel_post_read_file, struct file *file, char *buf,

base-commit: dba8648dcab90564b8a11c952c06a9e1153506fb

Signature · 1 line
2.29.0.rc0
Signature · 1 line
Kees Cook