libselinux: handle null SID's in sidput / sidget
PATCH 1/1 libselinux: handle null SID's in sidput / sidget
This patch makes it possible to sidput a userspace AVC SID in cleanup code when the SID may never have been initialized.
---
avc_internal.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
src/avc_internal.h +0 -0
@@ -18,12 +18,12 @@
/* SID reference counter manipulation */ static inline int sid_inc_refcnt(security_id_t sid) {
- return sid->refcnt = (sid->refcnt > 0) ? sid->refcnt + 1 : 0;
+ return sid->refcnt = (sid && sid->refcnt > 0) ? sid->refcnt + 1 : 0;
}
static inline int sid_dec_refcnt(security_id_t sid) {
- return sid->refcnt = (sid->refcnt > 0) ? sid->refcnt - 1 : 0;
+ return sid->refcnt = (sid && sid->refcnt > 0) ? sid->refcnt - 1 : 0;
}
/* callback pointers */
Signature · 8 lines
Eamon Walsh <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
PATCH 1/1 libselinux: handle null SID's in sidput (revised)
This patch makes it possible to sidput a userspace AVC SID in cleanup code when the SID may never have been initialized.
This version drops the check in sidget and avoids taking the AVC lock on a null SID (and fixes a null-pointer dereference).
---
avc.c | 2 ++
1 file changed, 2 insertions(+)
src/avc.c +0 -0
@@ -272,6 +272,8 @@
int sidput(security_id_t sid)
{
int rc;
+ if (!sid)
+ return 0;
avc_get_lock(avc_lock);
rc = sid_dec_refcnt(sid);
avc_release_lock(avc_lock);--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.