C

Faults in Linux: Locking but not unlocking and double locking

As part of my project, while reading the reports, I came to know about bugs of type where double locks were taken, locks were taken but never unlocked.  There were many in the versions 2.4.x and 2.6.x. I was also required to list FPs (false positives) by Coccinelle. This post is be about the mentioned type.

You can view the complete report as a PDF here and as a HTML file here.

 

What is a lock?

I’m not gonna a write about this, but I’m gonna link some awesome articles for it. Enjoy! 🙂

 

Why is it a bug?

Double locking is a bug, as you should try to acquire a lock on X, if you already have one. You should unlock X, after the use so that other can acquire a lock on it and use it.

 

Types I studied?

I studied many types for this:

  • Results for the case of finding a lock that is taken but not released.
  • Results for the case of finding a lock that is taken more than once.
  • Results for the case of finding cases where interrupts are turned off but not turned on again, using the functions local_irq_save or save_and_cli.
  • Results for the case of finding cases where interrupts are turned off but not turned on again, using the functions cli.
  • Results for the case of finding a lock that is taken but not released. Interrupts are disabled at the same time.
  • Results for the case of  finding a lock that is taken more than once. Interrupts are disabled at the same time.

 

Example Bug?

You can find many bugs of each type above in the report linked. Have a look at this, Lock acquired at 204 should be unlocked at line 226, before the return statement. spin_unlock and spin_irqrestore.

 

Example FP?

Look at this. In this case Lock will be released only when memory offline operation is complete in second case.

 

Stay tuned for more interesting stuff! 🙂

 

 

 

Advertisements

2 thoughts on “Faults in Linux: Locking but not unlocking and double locking

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s