Skip to contentSkip to conversation

libselinux: save errno value in avc_has_perm()

PATCH In review Eamon Walsh 2 participants 2 messages Feb 22, 2008 – Feb 25, 2008 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: save errno value in avc_has_perm()

The errno value set by avc_has_perm_noaudit() is being lost somewhere in the bowels of avc_audit(). This patch saves it off so it doesn't get lost.

---

libselinux/src/avc.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
src/avc.c +0 -0
Index: libselinux/src/avc.c
===================================================================
@@ -874,10 +874,12 @@

struct avc_entry_ref *aeref, void *auditdata)

{
	struct av_decision avd = { 0, 0, 0, 0, 0 };

- int rc;
+ int errsave, rc;

	rc = avc_has_perm_noaudit(ssid, tsid, tclass, requested, aeref, &avd);
+	errsave = errno;
	avc_audit(ssid, tsid, tclass, requested, &avd, rc, auditdata);
+	errno = errsave;
	return rc;
}
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.
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Eamon Walsh

The errno value set by avc_has_perm_noaudit() is being lost somewhere in the bowels of avc_audit(). This patch saves it off so it doesn't get lost.

Merge at will.

Seems suitable for the stable branch too.

Quoted 25 lines

---

 libselinux/src/avc.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: libselinux/src/avc.c
===================================================================

src/avc.c +3 -1
@@ -874,10 +874,12 @@
 		 struct avc_entry_ref *aeref, void *auditdata)
 {
 	struct av_decision avd = { 0, 0, 0, 0, 0 };
-	int rc;
+	int errsave, rc;
 
 	rc = avc_has_perm_noaudit(ssid, tsid, tclass, requested, aeref, &avd);
+	errsave = errno;
 	avc_audit(ssid, tsid, tclass, requested, &avd, rc, auditdata);
+	errno = errsave;
 	return rc;
 }
 
Signature · 8 lines
Stephen Smalley
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.