<feed xmlns='http://www.w3.org/2005/Atom'>
<title>libcg.git/src, branch review/daemon-exec</title>
<subtitle>Unnamed repository; edit this file to name it for gitweb.</subtitle>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/'/>
<entry>
<title>Hi,</title>
<updated>2009-05-26T13:10:04+00:00</updated>
<author>
<name>Jan Safranek</name>
<email>jsafrane@redhat.com</email>
</author>
<published>2009-05-26T13:10:04+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=5d4c157d29b7dba3081dd274a4c9d0eaa5bac63e'/>
<id>5d4c157d29b7dba3081dd274a4c9d0eaa5bac63e</id>
<content type='text'>
A process name is changed when execve(2), so a new rule based on
process name should be applied when execve(2) happens.
Then this patch adds an EXEC event to the event handler.

TODO:
=====
* The cgroup directory, which is specified by `cgexec` command, is
  ignored because this patch adds an EXEC event to the event handler.
  This problem should be fixed.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A process name is changed when execve(2), so a new rule based on
process name should be applied when execve(2) happens.
Then this patch adds an EXEC event to the event handler.

TODO:
=====
* The cgroup directory, which is specified by `cgexec` command, is
  ignored because this patch adds an EXEC event to the event handler.
  This problem should be fixed.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Hi,</title>
<updated>2009-05-26T13:09:03+00:00</updated>
<author>
<name>Jan Safranek</name>
<email>jsafrane@redhat.com</email>
</author>
<published>2009-05-26T13:09:03+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=37f11368ff2aca9ff736bd569ca58f48623c200b'/>
<id>37f11368ff2aca9ff736bd569ca58f48623c200b</id>
<content type='text'>
This patch adds the key "process name" to find a matching rule.

By this patch, cgroup_change_cgroup_uid_gid_flags() gets a process
name by the parameter "pid" internally and uses it to find a matching
rule.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds the key "process name" to find a matching rule.

By this patch, cgroup_change_cgroup_uid_gid_flags() gets a process
name by the parameter "pid" internally and uses it to find a matching
rule.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Hi,</title>
<updated>2009-05-26T13:08:59+00:00</updated>
<author>
<name>Jan Safranek</name>
<email>jsafrane@redhat.com</email>
</author>
<published>2009-05-26T13:08:59+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=9d3b7b6c8b8855e6bd63aecb9872ef7022394d4f'/>
<id>9d3b7b6c8b8855e6bd63aecb9872ef7022394d4f</id>
<content type='text'>
This patch adds the parser of process name in /etc/cgrules.conf.

A new rule based on process name is as the following, and the process
name is stored into the member "procname" in struct cgroup_rule.
  &lt;user&gt;:&lt;process name&gt;  &lt;controllers&gt;   &lt;destination&gt;


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds the parser of process name in /etc/cgrules.conf.

A new rule based on process name is as the following, and the process
name is stored into the member "procname" in struct cgroup_rule.
  &lt;user&gt;:&lt;process name&gt;  &lt;controllers&gt;   &lt;destination&gt;


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Hi,</title>
<updated>2009-05-26T13:08:43+00:00</updated>
<author>
<name>Jan Safranek</name>
<email>jsafrane@redhat.com</email>
</author>
<published>2009-05-26T13:08:43+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=14a7cff3d55ee45762b7911fb0266e63ab99bc69'/>
<id>14a7cff3d55ee45762b7911fb0266e63ab99bc69</id>
<content type='text'>
There are some similar functions for getting process's data (uid,
gid) from /proc/&lt;pid&gt;/status file, so this patch integrates these
functions into one cgroup_get_procdata_from_status().
In addition, cgroup_get_procdata_from_status() can get also a
process name from /proc/&lt;pid&gt;/status file.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are some similar functions for getting process's data (uid,
gid) from /proc/&lt;pid&gt;/status file, so this patch integrates these
functions into one cgroup_get_procdata_from_status().
In addition, cgroup_get_procdata_from_status() can get also a
process name from /proc/&lt;pid&gt;/status file.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Hi,</title>
<updated>2009-05-26T12:52:42+00:00</updated>
<author>
<name>Jan Safranek</name>
<email>jsafrane@redhat.com</email>
</author>
<published>2009-05-26T12:52:42+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=fa3fa8fdb076b5f1f315e38fd3e2656f32669a3f'/>
<id>fa3fa8fdb076b5f1f315e38fd3e2656f32669a3f</id>
<content type='text'>
To add the member "procname" to struct cgroup_rule by later patch, this
patch renames the member "name" to "username" for the clarification.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To add the member "procname" to struct cgroup_rule by later patch, this
patch renames the member "name" to "username" for the clarification.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Hi,</title>
<updated>2009-05-26T12:52:42+00:00</updated>
<author>
<name>Jan Safranek</name>
<email>jsafrane@redhat.com</email>
</author>
<published>2009-05-26T12:52:42+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=83ed907a1d449e8f43db580e7cd0b7542c8ed97e'/>
<id>83ed907a1d449e8f43db580e7cd0b7542c8ed97e</id>
<content type='text'>
The loop in cgroup_parse_rules() is a little long now, and it is not
easy to read the loop.
Then, This patch shortens the loop for the readability.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The loop in cgroup_parse_rules() is a little long now, and it is not
easy to read the loop.
Then, This patch shortens the loop for the readability.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Hi,</title>
<updated>2009-05-26T12:52:42+00:00</updated>
<author>
<name>Jan Safranek</name>
<email>jsafrane@redhat.com</email>
</author>
<published>2009-05-26T12:52:42+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=84da02ebfc7fbc2862ca238d00a53548b2e0b2b1'/>
<id>84da02ebfc7fbc2862ca238d00a53548b2e0b2b1</id>
<content type='text'>
By using sizeof() in memset(), we will not need to care of the buffer
size.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
By using sizeof() in memset(), we will not need to care of the buffer
size.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix the deadlock of rl_lock.</title>
<updated>2009-05-22T09:16:22+00:00</updated>
<author>
<name>Ken'ichi Ohmichi</name>
<email>oomichi@mxs.nes.nec.co.jp</email>
</author>
<published>2009-05-19T00:19:29+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=0241c6f1df5068c006f756005c8e7faa63058c27'/>
<id>0241c6f1df5068c006f756005c8e7faa63058c27</id>
<content type='text'>
Hi,

Changelog of v2:
  - Add the description of the problematic call sequence.
  - There is not any change in the code.

[PATCH-v2] Fix the deadlock of rl_lock.

For avoiding the deadlock, protect cdgroup_change_cgroup_uid_gid_flags()
by blocking SIGUSR2 signal.

The problematic call sequence is the following:
----------------------------------------------------------------------
* CGRULESENGD DAEMON *
  &lt;&lt; cgre_flash_rules() is the signal handler for SIGUSR2 signal &gt;&gt;
  cgre_create_netlink_socket_process_msg()
    &lt;&lt; Receive a UID/GID event packet &gt;&gt;
    cgre_handle_msg()
      cgre_process_event()
        cgroup_change_cgroup_uid_gid_flags()
          cgroup_find_matching_rule_uid_gid()
            pthread_rwlock_wrlock(&amp;rl_lock);  &lt;&lt; Get the lock of rl_lock &gt;&gt;
            &lt;&lt; Receive a SIGUSR2 signal, and switch to cgre_flash_rules() &gt;&gt;
  cgre_flash_rules()
    cgroup_reload_cached_rules()
      cgroup_parse_rules()
        pthread_rwlock_wrlock(&amp;rl_lock);  &lt;&lt; deadlock ! &gt;&gt;
----------------------------------------------------------------------

A cgrulesengd daemon needs a lock of rl_lock for referring configuration
buffer. On the other way, the daemon reloads configuration file when
receiving SIGUSR2 signal, and it needs the same lock in cgroup_parse_rules().
So cgroup_change_cgroup_uid_gid_flags() should be protected from SIGUSR2
signal for avoiding the deadlock.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
Signed-off-by: Dhaval Giani &lt;dhaval@linux.vnet.ibm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Hi,

Changelog of v2:
  - Add the description of the problematic call sequence.
  - There is not any change in the code.

[PATCH-v2] Fix the deadlock of rl_lock.

For avoiding the deadlock, protect cdgroup_change_cgroup_uid_gid_flags()
by blocking SIGUSR2 signal.

The problematic call sequence is the following:
----------------------------------------------------------------------
* CGRULESENGD DAEMON *
  &lt;&lt; cgre_flash_rules() is the signal handler for SIGUSR2 signal &gt;&gt;
  cgre_create_netlink_socket_process_msg()
    &lt;&lt; Receive a UID/GID event packet &gt;&gt;
    cgre_handle_msg()
      cgre_process_event()
        cgroup_change_cgroup_uid_gid_flags()
          cgroup_find_matching_rule_uid_gid()
            pthread_rwlock_wrlock(&amp;rl_lock);  &lt;&lt; Get the lock of rl_lock &gt;&gt;
            &lt;&lt; Receive a SIGUSR2 signal, and switch to cgre_flash_rules() &gt;&gt;
  cgre_flash_rules()
    cgroup_reload_cached_rules()
      cgroup_parse_rules()
        pthread_rwlock_wrlock(&amp;rl_lock);  &lt;&lt; deadlock ! &gt;&gt;
----------------------------------------------------------------------

A cgrulesengd daemon needs a lock of rl_lock for referring configuration
buffer. On the other way, the daemon reloads configuration file when
receiving SIGUSR2 signal, and it needs the same lock in cgroup_parse_rules().
So cgroup_change_cgroup_uid_gid_flags() should be protected from SIGUSR2
signal for avoiding the deadlock.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
Signed-off-by: Dhaval Giani &lt;dhaval@linux.vnet.ibm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix the deadlock of vsyslog() call.</title>
<updated>2009-05-22T09:16:21+00:00</updated>
<author>
<name>Ken'ichi Ohmichi</name>
<email>oomichi@mxs.nes.nec.co.jp</email>
</author>
<published>2009-05-15T08:30:24+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=70111cd03653c3ceab9d907c14fa35e5881b2735'/>
<id>70111cd03653c3ceab9d907c14fa35e5881b2735</id>
<content type='text'>
Hi,

I found the deadlock problem that a cgrulesengd daemon stalls if
service "cgred" is reloaded while many UID events happen.
The following is the gdb output by attaching the stalling daemon:

 (gdb) bt
 #0  0x0000003b298dd918 in __lll_mutex_lock_wait () from /lib64/libc.so.6
 #1  0x0000003b298ce847 in _L_lock_646 () from /lib64/libc.so.6
 #2  0x0000003b298ce2da in __vsyslog_chk () from /lib64/libc.so.6
 #3  0x0000000000401533 in flog (level=5, format=0x402778 "Reloading rules configuration.") at cgrule sengd.c:130
 #4  0x00000000004015d1 in cgre_flash_rules (signum=&lt;value optimized out&gt;) at cgrulesengd.c:644
 #5  &lt;signal handler called&gt;
 #6  0x0000003b298d27b5 in send () from /lib64/libc.so.6
 #7  0x0000003b298ce3a0 in __vsyslog_chk () from /lib64/libc.so.6
 #8  0x0000000000401533 in flog (level=4, format=0x402b82 "Failed to open %s") at cgrulesengd.c:130
 #9  0x0000000000401cc7 in cgre_process_event (ev=0x7fff8ad11cc4, type=4) at cgrulesengd.c:161
 #10 0x0000000000401fd5 in cgre_create_netlink_socket_process_msg () at cgrulesengd.c:486
 #11 0x00000000004023ca in main (argc=1, argv=&lt;value optimized out&gt;) at cgrulesengd.c:878
 (gdb)

We can see __vsyslog_chk() is called twice, because the daemon
recieved a SIGUSR2 signal in __vsyslog_chk(). In __vsyslog_chk(),
"syslog_lock" is locked by __libc_lock_lock(syslog_lock).
So I think vsyslog() should be protected by blocking the signal,
and this patch fixes the problem by doing it.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
Signed-off-by: Dhaval Giani &lt;dhaval@linux.vnet.ibm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Hi,

I found the deadlock problem that a cgrulesengd daemon stalls if
service "cgred" is reloaded while many UID events happen.
The following is the gdb output by attaching the stalling daemon:

 (gdb) bt
 #0  0x0000003b298dd918 in __lll_mutex_lock_wait () from /lib64/libc.so.6
 #1  0x0000003b298ce847 in _L_lock_646 () from /lib64/libc.so.6
 #2  0x0000003b298ce2da in __vsyslog_chk () from /lib64/libc.so.6
 #3  0x0000000000401533 in flog (level=5, format=0x402778 "Reloading rules configuration.") at cgrule sengd.c:130
 #4  0x00000000004015d1 in cgre_flash_rules (signum=&lt;value optimized out&gt;) at cgrulesengd.c:644
 #5  &lt;signal handler called&gt;
 #6  0x0000003b298d27b5 in send () from /lib64/libc.so.6
 #7  0x0000003b298ce3a0 in __vsyslog_chk () from /lib64/libc.so.6
 #8  0x0000000000401533 in flog (level=4, format=0x402b82 "Failed to open %s") at cgrulesengd.c:130
 #9  0x0000000000401cc7 in cgre_process_event (ev=0x7fff8ad11cc4, type=4) at cgrulesengd.c:161
 #10 0x0000000000401fd5 in cgre_create_netlink_socket_process_msg () at cgrulesengd.c:486
 #11 0x00000000004023ca in main (argc=1, argv=&lt;value optimized out&gt;) at cgrulesengd.c:878
 (gdb)

We can see __vsyslog_chk() is called twice, because the daemon
recieved a SIGUSR2 signal in __vsyslog_chk(). In __vsyslog_chk(),
"syslog_lock" is locked by __libc_lock_lock(syslog_lock).
So I think vsyslog() should be protected by blocking the signal,
and this patch fixes the problem by doing it.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
Signed-off-by: Dhaval Giani &lt;dhaval@linux.vnet.ibm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Cleanup the infinite loop of cgrulesengddaemon.</title>
<updated>2009-05-19T03:05:22+00:00</updated>
<author>
<name>Ken'ichi Ohmichi</name>
<email>oomichi@mxs.nes.nec.co.jp</email>
</author>
<published>2009-05-07T04:08:40+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/jsafrane/public_git/libcg.git/commit/?id=781e12c79e97f76799af8c557c6e96c508e645df'/>
<id>781e12c79e97f76799af8c557c6e96c508e645df</id>
<content type='text'>
Hi,

This patch clarifies the infinite loop.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
Acked-by: Balbir Singh &lt;balbir@linux.vnet.ibm.com&gt;
Acked-by: Dhaval Giani &lt;dhaval@linux.vnet.ibm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Hi,

This patch clarifies the infinite loop.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi &lt;oomichi@mxs.nes.nec.co.jp&gt;
Acked-by: Balbir Singh &lt;balbir@linux.vnet.ibm.com&gt;
Acked-by: Dhaval Giani &lt;dhaval@linux.vnet.ibm.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
