l4_task_cap_equal broken?

Stefan kalkowski stefan.kalkowski at genode-labs.com
Fri Apr 20 13:08:39 CEST 2012

Hi Alexander,

thanks for your explanations.

On 19.04.2012 17:36, Alexander Warg wrote:
> Yes, you missed the rights assigned to the capabilities. Two
> capabilities are equal if they are exactly equal. This means they must
> point to the same object and have exactly the same rights.

Ok, in that case I think the documentation is misleading, citation:

"Test if two capabilities point to the same object."

Nevertheless, I already recognized the rights being encountered in the
comparison when looking at the kernel-source. From my understanding the
two least significant bits of the kobject_iface pointer are used for
that. But they're equal in my situation, as well as the kernel-object
the capabilities point to. Nevertheless, the kobject_iface pointer
differs between both.
When using the original source and adding the following prints to

  printf("cap a: kobject=%lx rights=%x obj()=%lx\n",
         c_a.obj()->kobject_start_addr(), c_a.rights(), c_a.obj());
  printf("cap b: kobject=%lx rights=%x obj()=%lx\n",
         c_b.obj()->kobject_start_addr(), c_b.rights(), c_b.obj());
  printf("a == b ? %x\n", (c_a == c_b));

I get for instance the following output:

  cap a: kobject=fd9b4ec0 rights=3 obj()=fd9b4efc
  cap b: kobject=fd9b4ec0 rights=3 obj()=fd9b4ec0
  a == b ? 0

Can you please shed light on this behaviour? In what situation do I have
differing kobject_iface objects (with the same rights) that represent
actually the same kobject?

> The patch uses a debugging feature of the Kobject class and additionally
> removes the rights check. Note, the object pointers in two capabilities
> may also differ if they point to the same kernel object but have
> different rights!

Sorry, I didn't recognized "kobject_start_addr()" being a debugging
feature. The patch just circumnavigated my actual problem. I didn't
wanted you to apply it mainline ;-).

Regards Stefan

More information about the l4-hackers mailing list