All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Tang <jtang@tresys.com>
To: selinux@tycho.nsa.gov
Subject: corrected sidtab locking patch
Date: Fri, 26 Aug 2005 13:14:10 -0400	[thread overview]
Message-ID: <1125076450.5306.20.camel@localhost.localdomain> (raw)
In-Reply-To: <430F4824.4090802@tresys.com>

[-- Attachment #1: Type: text/plain, Size: 327 bytes --]

The following patch allows a program to enable locking in
libsepol/sidtab.c.  By default sidtab.c does not lock the sidtab when
adding and removing entries; this causes problems for multi-threaded
programs using it.  Programs may set up function pointers to perform
locking as they see fit.


-- 
Jason Tang / jtang@tresys.com

[-- Attachment #2: patch-locking --]
[-- Type: text/x-patch, Size: 1812 bytes --]

diff -purN nsa/selinux-usr/libsepol/include/sepol/sidtab.h nsa-selinux-usr/libsepol/include/sepol/sidtab.h
--- nsa/selinux-usr/libsepol/include/sepol/sidtab.h	2005-07-13 15:42:37.000000000 -0400
+++ nsa-selinux-usr/libsepol/include/sepol/sidtab.h	2005-08-24 17:40:19.000000000 -0400
@@ -72,6 +72,11 @@ extern void sepol_sidtab_set(sidtab_t *d
 
 extern void sepol_sidtab_shutdown(sidtab_t *s);
 
+typedef void (* sepol_sidtab_lock_func)(sidtab_t *);
+extern void sepol_sidtab_set_init_func(sepol_sidtab_lock_func func);
+extern void sepol_sidtab_set_lock_func(sepol_sidtab_lock_func func);
+extern void sepol_sidtab_set_unlock_func(sepol_sidtab_lock_func func);
+
 #endif	/* _SIDTAB_H_ */
 
 /* FLASK */
diff -purN nsa/selinux-usr/libsepol/src/sidtab.c nsa-selinux-usr/libsepol/src/sidtab.c
--- nsa/selinux-usr/libsepol/src/sidtab.c	2005-05-13 15:53:31.000000000 -0400
+++ nsa-selinux-usr/libsepol/src/sidtab.c	2005-08-24 17:28:06.000000000 -0400
@@ -23,6 +23,14 @@
 #define SIDTAB_LOCK(s) 
 #define SIDTAB_UNLOCK(s)
 
+static void do_no_lock_func(sidtab_t *s __attribute__((unused))) {
+        /* as the name suggests, this function does not do anything */
+}
+
+static sepol_sidtab_lock_func INIT_SIDTAB_LOCK = do_no_lock_func;
+static sepol_sidtab_lock_func SIDTAB_LOCK = do_no_lock_func;
+static sepol_sidtab_lock_func SIDTAB_UNLOCK = do_no_lock_func;
+
 int sepol_sidtab_init(sidtab_t *s) 
 {
 	int i;
@@ -334,5 +342,17 @@ void sepol_sidtab_shutdown(sidtab_t *s)
 	SIDTAB_UNLOCK(s);
 }
 
+void sepol_sidtab_set_init_func(sepol_sidtab_lock_func func) {
+        INIT_SIDTAB_LOCK = func;
+}
+
+void sepol_sidtab_set_lock_func(sepol_sidtab_lock_func func) {
+        SIDTAB_LOCK = func;
+}
+
+void sepol_sidtab_set_unlock_func(sepol_sidtab_lock_func func) {
+        SIDTAB_UNLOCK = func;
+}
+
 /* FLASK */
 

       reply	other threads:[~2005-08-26 17:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1125074025.5306.9.camel@localhost.localdomain>
     [not found] ` <430F4824.4090802@tresys.com>
2005-08-26 17:14   ` Jason Tang [this message]
2005-08-26 17:38     ` corrected sidtab locking patch Stephen Smalley
2005-08-26 18:12       ` Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1125076450.5306.20.camel@localhost.localdomain \
    --to=jtang@tresys.com \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.