From d1c5947ec6789b7d72cd7365f4e37ec326dbd9b6 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Tue, 11 Jun 2019 21:48:15 +0800 Subject: [PATCH 1/2] security: Make capability_hooks static Fix sparse warning: security/commoncap.c:1347:27: warning: symbol 'capability_hooks' was not declared. Should it be static? Reported-by: Hulk Robot Signed-off-by: YueHaibing Signed-off-by: James Morris --- security/commoncap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/commoncap.c b/security/commoncap.c index c477fb673701..afd9679ca866 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -1344,7 +1344,7 @@ int cap_mmap_file(struct file *file, unsigned long reqprot, #ifdef CONFIG_SECURITY -struct security_hook_list capability_hooks[] __lsm_ro_after_init = { +static struct security_hook_list capability_hooks[] __lsm_ro_after_init = { LSM_HOOK_INIT(capable, cap_capable), LSM_HOOK_INIT(settime, cap_settime), LSM_HOOK_INIT(ptrace_access_check, cap_ptrace_access_check), From c5eaab1d131d0a6272df7d55a971a67400d63f56 Mon Sep 17 00:00:00 2001 From: Carmeli Tamir Date: Sat, 6 Jul 2019 11:07:38 -0400 Subject: [PATCH 2/2] security/commoncap: Use xattr security prefix len Using the existing defined XATTR_SECURITY_PREFIX_LEN instead of sizeof(XATTR_SECURITY_PREFIX) - 1. Pretty simple cleanup. Signed-off-by: Carmeli Tamir Signed-off-by: James Morris --- security/commoncap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/commoncap.c b/security/commoncap.c index afd9679ca866..1156178a0c52 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -920,7 +920,7 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name, /* Ignore non-security xattrs */ if (strncmp(name, XATTR_SECURITY_PREFIX, - sizeof(XATTR_SECURITY_PREFIX) - 1) != 0) + XATTR_SECURITY_PREFIX_LEN) != 0) return 0; /* @@ -952,7 +952,7 @@ int cap_inode_removexattr(struct dentry *dentry, const char *name) /* Ignore non-security xattrs */ if (strncmp(name, XATTR_SECURITY_PREFIX, - sizeof(XATTR_SECURITY_PREFIX) - 1) != 0) + XATTR_SECURITY_PREFIX_LEN) != 0) return 0; if (strcmp(name, XATTR_NAME_CAPS) == 0) {