<div dir="auto"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Replying to myself:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Apparently, the callers are expected to manually perform the UNLOCK later.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I've added a comment in the code for future reference.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Y.</div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 1, 2018 at 8:53 PM Yaniv Kaul <<a href="mailto:ykaul@redhat.com" target="_blank" rel="noreferrer">ykaul@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I'm looking at the code and I'm not sure if there's a missing UNLOCK there (location marked in bold red) for cache->gc_lock :</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default"><div class="gmail_default"><font face="arial, helvetica, sans-serif"> LOCK(&cache->gc_lock);</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> bucket = id % cache->gc_nbuckets;</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> agl = BUCKET_START(cache->gc_cache, bucket);</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> for (i = 0; i < AUX_GID_CACHE_ASSOC; i++, agl++) {</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> if (!agl->gl_list || agl->gl_id != id)</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> continue;</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> /*</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> @uid and @gid reflect the latest UID/GID of the</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> process performing the syscall (taken from frame->root).</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> If the UID and GID has changed for the PID since the</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> time we cached it, we should treat the cache as having</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> stale values and query them freshly.</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> */</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> if (agl->gl_uid != uid || agl->gl_gid != gid)</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> break;</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> /*</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> * We don't put new entries in the cache when expiration=0, but</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> * there might be entries still in there if expiration was</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> * changed very recently. Writing the check this way ensures</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> * that they're not used.</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> */</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> if (now < agl->gl_deadline) {</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> <b><font color="#ff0000">return agl;</font></b></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> }</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> /*</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> * We're not going to find any more UID matches, and reaping</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> * is handled further down to maintain LRU order.</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> */</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> break;</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> }</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> UNLOCK(&cache->gc_lock);</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> return NULL;</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">}</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">TIA,</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">Y.</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div style="font-family:arial,helvetica,sans-serif"><br></div></div></div></div></div>
</blockquote></div></div>