diff options
author | Casey Schaufler <casey@schaufler-ca.com> | 2024-10-24 00:21:55 +0300 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2024-12-04 22:42:31 +0300 |
commit | 2d470c778120d3cdb8d8ab250329ca85f49f12b1 (patch) | |
tree | 9796bb2460bd31563d4993b32f47fec7c80fad86 /security/selinux/hooks.c | |
parent | 6fba89813ccf333d2bc4d5caea04cd5f3c39eb50 (diff) | |
download | linux-2d470c778120d3cdb8d8ab250329ca85f49f12b1.tar.xz |
lsm: replace context+len with lsm_context
Replace the (secctx,seclen) pointer pair with a single
lsm_context pointer to allow return of the LSM identifier
along with the context and context length. This allows
security_release_secctx() to know how to release the
context. Callers have been modified to use or save the
returned data from the new structure.
security_secid_to_secctx() and security_lsmproc_to_secctx()
will now return the length value on success instead of 0.
Cc: netdev@vger.kernel.org
Cc: audit@vger.kernel.org
Cc: netfilter-devel@vger.kernel.org
Cc: Todd Kjos <tkjos@google.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
[PM: subject tweak, kdoc fix, signedness fix from Dan Carpenter]
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index aabc724f4d44..ddc24db7c0b2 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -6640,15 +6640,28 @@ static int selinux_ismaclabel(const char *name) return (strcmp(name, XATTR_SELINUX_SUFFIX) == 0); } -static int selinux_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) +static int selinux_secid_to_secctx(u32 secid, struct lsm_context *cp) { - return security_sid_to_context(secid, secdata, seclen); + u32 seclen; + int ret; + + if (cp) { + cp->id = LSM_ID_SELINUX; + ret = security_sid_to_context(secid, &cp->context, &cp->len); + if (ret < 0) + return ret; + return cp->len; + } + ret = security_sid_to_context(secid, NULL, &seclen); + if (ret < 0) + return ret; + return seclen; } -static int selinux_lsmprop_to_secctx(struct lsm_prop *prop, char **secdata, - u32 *seclen) +static int selinux_lsmprop_to_secctx(struct lsm_prop *prop, + struct lsm_context *cp) { - return selinux_secid_to_secctx(prop->selinux.secid, secdata, seclen); + return selinux_secid_to_secctx(prop->selinux.secid, cp); } static int selinux_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid) |