All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] move genhomedircon call out of transaction
@ 2005-11-14 22:09 Chad Sellers
  2005-11-14 23:02 ` Ivan Gyurdiev
  2005-11-15 13:23 ` Stephen Smalley
  0 siblings, 2 replies; 7+ messages in thread
From: Chad Sellers @ 2005-11-14 22:09 UTC (permalink / raw)
  To: 'Daniel J Walsh'; +Cc: selinux-dev, Stephen Smalley, selinux

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

Attached is a patch that moves the genhomedircon patch out of the libsemanage 
transaction.  This is necessary since genhomedircon now uses libsemanage, and 
enters a transaction itself.

Chad

-- 
----------------------
Chad Sellers
Tresys Technology, LLC
csellers@tresys.com
(410)290-1411 x117
http://www.tresys.com

[-- Attachment #2: genhomedircon-outside-trans.diff --]
[-- Type: text/x-diff, Size: 895 bytes --]

Index: libsemanage/src/semanage_store.c
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux-usr/libsemanage/src/semanage_store.c,v
retrieving revision 1.21
diff -u -r1.21 semanage_store.c
--- libsemanage/src/semanage_store.c	9 Nov 2005 14:52:55 -0000	1.21
+++ libsemanage/src/semanage_store.c	14 Nov 2005 21:43:09 -0000
@@ -950,11 +950,6 @@
 		goto cleanup;
 	}
 
-	if ((r = semanage_exec_prog(sh, sh->conf->genhomedircon, sh->conf->store_path, "")) != 0) {
-		ERR(sh, "genhomedircon returned error code %d.", r);
-		goto cleanup;
-	}
-
 	retval = 0;
 cleanup:
 	free(storepath);
@@ -1070,6 +1065,12 @@
 		goto cleanup;
 	}
 
+	if ((retval = semanage_exec_prog(sh, sh->conf->genhomedircon, sh->conf->store_path, "")) != 0) {
+		ERR(sh, "genhomedircon returned error code %d.", retval);
+		goto cleanup;
+	}
+
+
 cleanup:
 	return retval;
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] move genhomedircon call out of transaction
  2005-11-14 22:09 [PATCH] move genhomedircon call out of transaction Chad Sellers
@ 2005-11-14 23:02 ` Ivan Gyurdiev
  2005-11-14 23:07   ` Ivan Gyurdiev
  2005-11-15  1:10   ` Chad Sellers
  2005-11-15 13:23 ` Stephen Smalley
  1 sibling, 2 replies; 7+ messages in thread
From: Ivan Gyurdiev @ 2005-11-14 23:02 UTC (permalink / raw)
  To: Chad Sellers
  Cc: 'Daniel J Walsh', selinux-dev, Stephen Smalley, selinux

Chad Sellers wrote:
> Attached is a patch that moves the genhomedircon patch out of the libsemanage 
> transaction.  This is necessary since genhomedircon now uses libsemanage, and 
> enters a transaction itself.
>   
I don't think genhomedircon enters a transaction... nor should it - it's 
a read-only operation with respect to the objects that we manage 
(currently). I could be wrong, but I can't find where it enters a 
transaction in the patch.

Also, even if it did enter transaction, exiting and re-entering 
"immediatly" would create a race condition.



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] move genhomedircon call out of transaction
  2005-11-14 23:02 ` Ivan Gyurdiev
@ 2005-11-14 23:07   ` Ivan Gyurdiev
  2005-11-15  1:10   ` Chad Sellers
  1 sibling, 0 replies; 7+ messages in thread
From: Ivan Gyurdiev @ 2005-11-14 23:07 UTC (permalink / raw)
  To: Ivan Gyurdiev
  Cc: Chad Sellers, 'Daniel J Walsh', selinux-dev,
	Stephen Smalley, selinux


>> Attached is a patch that moves the genhomedircon patch out of the 
>> libsemanage transaction.  This is necessary since genhomedircon now 
>> uses libsemanage, and enters a transaction itself.
>>   
> I don't think genhomedircon enters a transaction... nor should it - 
> it's a read-only operation with respect to the objects that we manage 
> (currently). I could be wrong, but I can't find where it enters a 
> transaction in the patch.
Note: calling multiple semanage query functions outside a transaction is 
a bad idea, because a policy is object is created and destroyed per call 
(while it is cached when in-transaction). However, here only the list() 
function is called (once?), so that seems fine. The active lock guards 
against modification during list().


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] move genhomedircon call out of transaction
  2005-11-14 23:02 ` Ivan Gyurdiev
  2005-11-14 23:07   ` Ivan Gyurdiev
@ 2005-11-15  1:10   ` Chad Sellers
  2005-11-15  3:22     ` Ivan Gyurdiev
  1 sibling, 1 reply; 7+ messages in thread
From: Chad Sellers @ 2005-11-15  1:10 UTC (permalink / raw)
  To: Ivan Gyurdiev
  Cc: 'Daniel J Walsh', selinux-dev, Stephen Smalley, selinux

On 11/14/05 6:02 PM, "Ivan Gyurdiev" <ivg2@cornell.edu> wrote:

> Chad Sellers wrote:
>> Attached is a patch that moves the genhomedircon patch out of the libsemanage
>> transaction.  This is necessary since genhomedircon now uses libsemanage, and
>> enters a transaction itself.
>>   
> I don't think genhomedircon enters a transaction... nor should it - it's
> a read-only operation with respect to the objects that we manage
> (currently). I could be wrong, but I can't find where it enters a
> transaction in the patch.
Yep it does.  It calls semanage_user_list(), which calls dbase_list(), which
calls enter_ro(), which gets the lock.

> 
> Also, even if it did enter transaction, exiting and re-entering
> "immediatly" would create a race condition.
Could you expand on this race condition?  genhomedircon is only reading from
libsemanage to generate file_contexts.homedir.  What race condition are you
worried about?

> 
> 

----------------------
Chad Sellers
Tresys Technology, LLC
csellers@tresys.com
(410)290-1411 x117
http://www.tresys.com




--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] move genhomedircon call out of transaction
  2005-11-15  1:10   ` Chad Sellers
@ 2005-11-15  3:22     ` Ivan Gyurdiev
  2005-11-15  4:02       ` Ivan Gyurdiev
  0 siblings, 1 reply; 7+ messages in thread
From: Ivan Gyurdiev @ 2005-11-15  3:22 UTC (permalink / raw)
  To: Chad Sellers
  Cc: 'Daniel J Walsh', selinux-dev, Stephen Smalley, selinux


>>> Attached is a patch that moves the genhomedircon patch out of the libsemanage
>>> transaction.  This is necessary since genhomedircon now uses libsemanage, and
>>> enters a transaction itself.
>>>   
>>>       
>> I don't think genhomedircon enters a transaction... nor should it - it's
>> a read-only operation with respect to the objects that we manage
>> (currently). I could be wrong, but I can't find where it enters a
>> transaction in the patch.
>>     
> Yep it does.  It calls semanage_user_list(), which calls dbase_list(), which
> calls enter_ro(), which gets the lock.
>   
I see the problem now - you confused me, because that's the active lock, 
not the transaction lock. It is not entering a transaction - it's 
guarding against a concurrent commit, but you *are* doing a concurrent 
commit, and calling genhomedircon as part of it.
>> Also, even if it did enter transaction, exiting and re-entering
>> "immediatly" would create a race condition.
>>     
> Could you expand on this race condition?  genhomedircon is only reading from
> libsemanage to generate file_contexts.homedir.  What race condition are you
> worried about?
>   
Well... any time you're releasing a lock, and you want to re-acquire it 
before changes are made - that's a potential race condition. I guess in 
this case you don't care if changes are made in the meantime, so there 
is no race condition.

On the other hand, genhomedir called outside libsemanage has a race in 
itself, because changes can be introduced between the time you call 
user_list, and seuser_list. It seems you're moving the place it's called 
to the end of install_sandbox (hard to tell without -p flag), so if it's 
called within libsemanage, that won't be a problem (active lock 
released, transaction lock still held, concurrent commit not possible).


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] move genhomedircon call out of transaction
  2005-11-15  3:22     ` Ivan Gyurdiev
@ 2005-11-15  4:02       ` Ivan Gyurdiev
  0 siblings, 0 replies; 7+ messages in thread
From: Ivan Gyurdiev @ 2005-11-15  4:02 UTC (permalink / raw)
  To: Ivan Gyurdiev
  Cc: Chad Sellers, 'Daniel J Walsh', selinux-dev,
	Stephen Smalley, selinux

>
> On the other hand, genhomedir called outside libsemanage has a race in 
> itself, because changes can be introduced between the time you call 
> user_list, and seuser_list. It seems you're moving the place it's 
> called to the end of install_sandbox (hard to tell without -p flag), 
> so if it's called within libsemanage, that won't be a problem (active 
> lock released, transaction lock still held, concurrent commit not 
> possible).

Really, genhomedircon should be using a transaction, which is both safer 
(avoids race), and faster (requires only 1 policydb_read, as opposed to 
2). However, I don't know how you'd call it within the original 
transaction...

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] move genhomedircon call out of transaction
  2005-11-14 22:09 [PATCH] move genhomedircon call out of transaction Chad Sellers
  2005-11-14 23:02 ` Ivan Gyurdiev
@ 2005-11-15 13:23 ` Stephen Smalley
  1 sibling, 0 replies; 7+ messages in thread
From: Stephen Smalley @ 2005-11-15 13:23 UTC (permalink / raw)
  To: Chad Sellers; +Cc: 'Daniel J Walsh', selinux-dev, selinux

On Mon, 2005-11-14 at 17:09 -0500, Chad Sellers wrote:
> Attached is a patch that moves the genhomedircon patch out of the libsemanage 
> transaction.  This is necessary since genhomedircon now uses libsemanage, and 
> enters a transaction itself.

Thanks, merged as of libsemanage 1.3.54.

-- 
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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-11-15 13:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-14 22:09 [PATCH] move genhomedircon call out of transaction Chad Sellers
2005-11-14 23:02 ` Ivan Gyurdiev
2005-11-14 23:07   ` Ivan Gyurdiev
2005-11-15  1:10   ` Chad Sellers
2005-11-15  3:22     ` Ivan Gyurdiev
2005-11-15  4:02       ` Ivan Gyurdiev
2005-11-15 13:23 ` Stephen Smalley

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.