Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: corrections for security_secid_to_secctx returns

security_secid_to_secctx() returns the size of the new context,
whereas previous versions provided that via a pointer parameter.
Correct the type of the value returned in nfqnl_get_sk_secctx()
and the check for error in netlbl_unlhsh_add(). Add an error
check.

Fixes: 2d470c778120 ("lsm: replace context+len with lsm_context")
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>

authored by

Casey Schaufler and committed by
Paul Moore
3b44cd09 b00083ae

+10 -8
+3 -3
net/netlabel/netlabel_unlabeled.c
··· 437 437 unlhsh_add_return: 438 438 rcu_read_unlock(); 439 439 if (audit_buf != NULL) { 440 - if (security_secid_to_secctx(secid, &ctx) == 0) { 440 + if (security_secid_to_secctx(secid, &ctx) >= 0) { 441 441 audit_log_format(audit_buf, " sec_obj=%s", ctx.context); 442 442 security_release_secctx(&ctx); 443 443 } ··· 490 490 addr->s_addr, mask->s_addr); 491 491 dev_put(dev); 492 492 if (entry != NULL && 493 - security_secid_to_secctx(entry->secid, &ctx) == 0) { 493 + security_secid_to_secctx(entry->secid, &ctx) >= 0) { 494 494 audit_log_format(audit_buf, " sec_obj=%s", ctx.context); 495 495 security_release_secctx(&ctx); 496 496 } ··· 548 548 addr, mask); 549 549 dev_put(dev); 550 550 if (entry != NULL && 551 - security_secid_to_secctx(entry->secid, &ctx) == 0) { 551 + security_secid_to_secctx(entry->secid, &ctx) >= 0) { 552 552 audit_log_format(audit_buf, " sec_obj=%s", ctx.context); 553 553 security_release_secctx(&ctx); 554 554 }