All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guido Trentalancia <guido@trentalancia.net>
To: selinux@tycho.nsa.gov
Subject: Re: [PATCH] libsemanage: remove lock files
Date: Mon, 24 Apr 2017 19:51:27 +0200	[thread overview]
Message-ID: <100DD2AB-228E-47B5-8058-C9F030AEA665@trentalancia.net> (raw)
In-Reply-To: <f5651c20-f14f-bd42-be2f-947294de28c9@gmail.com>

Yes, we already discussed this possibile race condition. 

Usually there is only one system administrator operating on the semanage store, nevertheless it's worth having a robust locking mechanism...

This patch either needs further work to avoid using flock() and instead using a simpler file lock mechanism with the added benefit of having a cleaner filesystem without confusing stale files around or we just drop the patch given it is not essential to keep things working. 

Regards, 

Guido 

On the 24th of April 2017 14:08:22 CEST, Alan Jenkins <alan.christopher.jenkins@gmail.com> wrote:
>*expands thread
>
>Sorry, I see this has already been addressed.
>
>
>On 24/04/17 13:06, Alan Jenkins wrote:
>> On 20/04/17 15:38, Guido Trentalancia wrote:
>>> Remove semanage read and transaction lock files upon releasing
>>> them.
>>
>> What prevents this sequence?
>>
>> A release lock
>>  B acquire lock
>> A unlink lock file
>>   C create lock file
>>   C acquire lock
>>
>>> Signed-off-by: Guido Trentalancia 
>>> <guido-D1bseh+SzQhuxeB9wqlrNw@public.gmane.org>
>>> ---
>>>   src/semanage_store.c |    2 ++
>>>   1 file changed, 2 insertions(+)
>>>
>>> diff -pruN a/src/semanage_store.c b/src/semanage_store.c
>>> --- a/src/semanage_store.c    2016-10-14 17:31:26.000000000 +0200
>>> +++ b/src/semanage_store.c    2017-04-03 09:32:24.093627962 +0200
>>> @@ -1904,6 +1904,7 @@ void semanage_release_trans_lock(semanag
>>>           close(sh->u.direct.translock_file_fd);
>>>           sh->u.direct.translock_file_fd = -1;
>>>       }
>>> +    unlink(semanage_files[SEMANAGE_TRANS_LOCK]);
>>>       errno = errsv;
>>>   }
>>>   @@ -1917,6 +1918,7 @@ void semanage_release_active_lock(semana
>>>           close(sh->u.direct.activelock_file_fd);
>>>           sh->u.direct.activelock_file_fd = -1;
>>>       }
>>> +    unlink(semanage_files[SEMANAGE_READ_LOCK]);
>>>       errno = errsv;
>>>   }
>>
>>
>>

  reply	other threads:[~2017-04-24 17:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20 14:38 [PATCH] libsemanage: remove lock files Guido Trentalancia
2017-04-20 15:44 ` Stephen Smalley
2017-04-20 15:45   ` Guido Trentalancia
2017-04-20 15:56     ` Stephen Smalley
2017-04-20 15:56       ` Guido Trentalancia
2017-04-20 16:08         ` Stephen Smalley
2017-04-20 16:09       ` Guido Trentalancia
2017-04-24 12:06 ` Alan Jenkins
2017-04-24 12:08   ` Alan Jenkins
2017-04-24 17:51     ` Guido Trentalancia [this message]
2017-04-24 18:38       ` Guido Trentalancia
2017-04-25  6:30         ` Russell Coker
2017-04-25 20:06           ` [PATCH v2] " Guido Trentalancia
2017-04-25 20:35             ` [PATCH v3] " Guido Trentalancia
2017-04-26 12:03               ` Jason Zaman
2017-04-26 12:56                 ` Stephen Smalley
2017-04-26 18:13                   ` Guido Trentalancia
2017-04-26 18:25                     ` Stephen Smalley
2017-04-26  0:31             ` [PATCH v2] " Russell Coker

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=100DD2AB-228E-47B5-8058-C9F030AEA665@trentalancia.net \
    --to=guido@trentalancia.net \
    --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.