Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1233101 > unrolled thread
| Started by | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| First post | 2015-09-26 00:40 +0200 |
| Last post | 2015-09-29 20:10 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/5] selinux: minor cleanup suggestions Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-26 00:40 +0200
[PATCH 4/5] selinux: use kstrdup() in security_get_bools() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-26 00:40 +0200
Re: [PATCH 4/5] selinux: use kstrdup() in security_get_bools() Paul Moore <paul@paul-moore.com> - 2015-09-30 18:50 +0200
Re: [PATCH 0/5] selinux: minor cleanup suggestions Stephen Smalley <sds@tycho.nsa.gov> - 2015-09-29 20:10 +0200
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2015-09-26 00:40 +0200 |
| Subject | [PATCH 0/5] selinux: minor cleanup suggestions |
| Message-ID | <qcJON-6x2-3@gated-at.bofh.it> |
A few random things I stumbled on. While I'm pretty sure of the change in 1/5, I'm also confused, because the doc for the reverse security_sid_to_context state that @scontext_len is set to "the length of the string", which one would normally interpret as being what strlen() would give (i.e., without the \0). However, security_sid_to_context_core clearly includes the \0 in the return value, and I think callers rely on that. Rasmus Villemoes (5): selinux: introduce security_context_str_to_sid selinux: remove pointless cast in selinux_inode_setsecurity() selinux: use kmemdup in security_sid_to_context_core() selinux: use kstrdup() in security_get_bools() selinux: use sprintf return value security/selinux/hooks.c | 14 +++++--------- security/selinux/include/security.h | 2 ++ security/selinux/selinuxfs.c | 26 +++++++++----------------- security/selinux/ss/services.c | 22 +++++++++------------- 4 files changed, 25 insertions(+), 39 deletions(-) -- 2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2015-09-26 00:40 +0200 |
| Subject | [PATCH 4/5] selinux: use kstrdup() in security_get_bools() |
| Message-ID | <qcJOP-6x2-31@gated-at.bofh.it> |
| In reply to | #1233101 |
This is much simpler.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
security/selinux/ss/services.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 994c824a34c6..aa2bdcb20848 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2609,18 +2609,12 @@ int security_get_bools(int *len, char ***names, int **values)
goto err;
for (i = 0; i < *len; i++) {
- size_t name_len;
-
(*values)[i] = policydb.bool_val_to_struct[i]->state;
- name_len = strlen(sym_name(&policydb, SYM_BOOLS, i)) + 1;
rc = -ENOMEM;
- (*names)[i] = kmalloc(sizeof(char) * name_len, GFP_ATOMIC);
+ (*names)[i] = kstrdup(sym_name(&policydb, SYM_BOOLS, i), GFP_ATOMIC);
if (!(*names)[i])
goto err;
-
- strncpy((*names)[i], sym_name(&policydb, SYM_BOOLS, i), name_len);
- (*names)[i][name_len - 1] = 0;
}
rc = 0;
out:
--
2.1.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Paul Moore <paul@paul-moore.com> |
|---|---|
| Date | 2015-09-30 18:50 +0200 |
| Subject | Re: [PATCH 4/5] selinux: use kstrdup() in security_get_bools() |
| Message-ID | <qesJR-2eW-33@gated-at.bofh.it> |
| In reply to | #1233102 |
On Saturday, September 26, 2015 12:34:18 AM Rasmus Villemoes wrote:
> This is much simpler.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> security/selinux/ss/services.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
Applied.
> diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
> index 994c824a34c6..aa2bdcb20848 100644
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -2609,18 +2609,12 @@ int security_get_bools(int *len, char ***names, int
> **values) goto err;
>
> for (i = 0; i < *len; i++) {
> - size_t name_len;
> -
> (*values)[i] = policydb.bool_val_to_struct[i]->state;
> - name_len = strlen(sym_name(&policydb, SYM_BOOLS, i)) + 1;
>
> rc = -ENOMEM;
> - (*names)[i] = kmalloc(sizeof(char) * name_len, GFP_ATOMIC);
> + (*names)[i] = kstrdup(sym_name(&policydb, SYM_BOOLS, i), GFP_ATOMIC);
> if (!(*names)[i])
> goto err;
> -
> - strncpy((*names)[i], sym_name(&policydb, SYM_BOOLS, i), name_len);
> - (*names)[i][name_len - 1] = 0;
> }
> rc = 0;
> out:
--
paul moore
www.paul-moore.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stephen Smalley <sds@tycho.nsa.gov> |
|---|---|
| Date | 2015-09-29 20:10 +0200 |
| Message-ID | <qe7vJ-5CQ-25@gated-at.bofh.it> |
| In reply to | #1233101 |
On 09/25/2015 06:34 PM, Rasmus Villemoes wrote: > A few random things I stumbled on. > > While I'm pretty sure of the change in 1/5, I'm also confused, because > the doc for the reverse security_sid_to_context state that > @scontext_len is set to "the length of the string", which one would > normally interpret as being what strlen() would give (i.e., without > the \0). However, security_sid_to_context_core clearly includes the \0 > in the return value, and I think callers rely on that. It is historical; originally security_context_to_sid() required @scontext to be NUL-terminated and @scontext_len to include the NUL byte in the length, and security_sid_to_context() returned a NUL-terminated @scontext and included the NUL byte in the returned length. However, when we switched SELinux to using xattrs rather than its own persistent label mapping, security_context_to_sid() was changed to accept contexts that did not already include the NUL because setfattr did not consider the NUL to be part of the attribute value for strings. So presently it accepts either form, although we prefer them to be NUL-terminated and canonicalize them to that form before returning to userspace. > > Rasmus Villemoes (5): > selinux: introduce security_context_str_to_sid > selinux: remove pointless cast in selinux_inode_setsecurity() > selinux: use kmemdup in security_sid_to_context_core() > selinux: use kstrdup() in security_get_bools() > selinux: use sprintf return value > > security/selinux/hooks.c | 14 +++++--------- > security/selinux/include/security.h | 2 ++ > security/selinux/selinuxfs.c | 26 +++++++++----------------- > security/selinux/ss/services.c | 22 +++++++++------------- > 4 files changed, 25 insertions(+), 39 deletions(-) > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web