2005-04-16 15:20:36 -07:00
|
|
|
|
2014-06-24 14:27:04 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-05-15 17:00:25 +02:00
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:09 +00:00
|
|
|
|
2006-08-22 20:29:17 +10:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2006-10-19 23:28:16 -07:00
|
|
|
|
2011-07-26 16:09:06 -07:00
|
|
|
|
2005-09-17 17:55:31 +10:00
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-10-21 17:44:59 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-06-26 00:27:35 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:09 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2013-10-11 15:45:43 -07:00
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-02-08 02:10:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2008-02-08 02:10:38 +00:00
|
|
|
|
2008-02-08 02:10:54 +00:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
2014-03-28 15:51:55 -04:00
|
|
|
|
2008-02-08 02:10:38 +00:00
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
2009-03-16 17:44:33 +00:00
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-19 22:42:37 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:55 +00:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:08 -05:00
|
|
|
|
dm crypt: fix a possible hang due to race condition on exit
A kernel thread executes __set_current_state(TASK_INTERRUPTIBLE),
__add_wait_queue, spin_unlock_irq and then tests kthread_should_stop().
It is possible that the processor reorders memory accesses so that
kthread_should_stop() is executed before __set_current_state(). If such
reordering happens, there is a possible race on thread termination:
CPU 0:
calls kthread_should_stop()
it tests KTHREAD_SHOULD_STOP bit, returns false
CPU 1:
calls kthread_stop(cc->write_thread)
sets the KTHREAD_SHOULD_STOP bit
calls wake_up_process on the kernel thread, that sets the thread
state to TASK_RUNNING
CPU 0:
sets __set_current_state(TASK_INTERRUPTIBLE)
spin_unlock_irq(&cc->write_thread_wait.lock)
schedule() - and the process is stuck and never terminates, because the
state is TASK_INTERRUPTIBLE and wake_up_process on CPU 1 already
terminated
Fix this race condition by using a new flag DM_CRYPT_EXIT_THREAD to
signal that the kernel thread should exit. The flag is set and tested
while holding cc->write_thread_wait.lock, so there is no possibility of
racy access to the flag.
Also, remove the unnecessary set_task_state(current, TASK_RUNNING)
following the schedule() call. When the process was woken up, its state
was already set to TASK_RUNNING. Other kernel code also doesn't set the
state to TASK_RUNNING following schedule() (for example,
do_wait_for_common in completion.c doesn't do it).
Fixes: dc2676210c42 ("dm crypt: offload writes to thread")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org # v4.0+
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2015-11-19 07:36:50 -05:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-10-03 01:15:40 -07:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-19 22:38:58 +01:00
|
|
|
|
|
|
|
|
|
2008-03-28 14:16:07 -07:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2011-01-13 19:59:52 +00:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-12-05 13:41:52 -08:00
|
|
|
|
2009-12-10 23:51:55 +00:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
2006-12-05 13:41:52 -08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-28 15:51:55 -04:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-10-28 23:21:03 +01:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:40 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-07-12 17:26:32 +01:00
|
|
|
|
2008-02-08 02:10:52 +00:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2007-05-09 02:32:52 -07:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-02 18:17:33 +10:00
|
|
|
|
2007-10-19 23:10:43 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-12-10 23:52:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-02 18:17:33 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-05-09 02:32:55 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
2015-04-05 18:03:10 +02:00
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2011-08-02 12:32:01 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:52:25 +00:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2009-12-10 23:52:25 +00:00
|
|
|
|
|
|
|
|
|
2011-08-02 12:32:01 +01:00
|
|
|
|
2009-12-10 23:52:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:55 +00:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2009-12-10 23:51:55 +00:00
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2009-12-10 23:51:55 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-19 22:42:37 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
2006-06-26 00:27:35 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
2006-08-24 19:10:20 +10:00
|
|
|
|
|
|
|
|
|
2006-06-26 00:27:35 -07:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
2006-06-26 00:27:35 -07:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2011-08-02 12:32:01 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2006-12-08 02:37:49 -08:00
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:55 +00:00
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
2006-12-05 13:41:52 -08:00
|
|
|
|
|
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
2006-12-05 13:41:52 -08:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2006-12-05 13:41:52 -08:00
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
2007-05-09 02:32:55 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
2013-10-28 23:21:03 +01:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-28 13:26:02 +08:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
2011-11-28 13:26:02 +08:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-28 13:26:02 +08:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-28 13:26:02 +08:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
2012-07-02 13:50:54 +02:00
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-11-22 09:36:04 +01:00
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:52:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-05-09 02:32:55 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-19 22:42:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:41 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-11 15:45:43 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-02-08 02:11:09 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2009-03-16 17:44:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
2013-10-11 15:45:43 -07:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
2009-03-16 17:44:33 +00:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2009-03-16 17:44:33 +00:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
2013-10-11 15:45:43 -07:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
2013-10-11 15:45:43 -07:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
2013-10-11 15:45:43 -07:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
2008-02-08 02:11:04 +00:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
2015-05-15 17:00:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
|
|
|
|
|
2014-03-28 15:51:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-19 22:42:37 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-03-28 14:16:07 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2008-10-10 13:37:08 +01:00
|
|
|
|
2013-10-11 15:45:43 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2008-03-28 14:16:07 -07:00
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
|
|
|
|
|
2015-05-15 17:00:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
|
|
|
|
|
2013-11-14 14:32:02 -08:00
|
|
|
|
2015-05-15 17:00:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Revert "dm crypt: fix deadlock when async crypto algorithm returns -EBUSY"
This reverts Linux 4.1-rc1 commit 0618764cb25f6fa9fb31152995de42a8a0496475.
The problem which that commit attempts to fix actually lies in the
Freescale CAAM crypto driver not dm-crypt.
dm-crypt uses CRYPTO_TFM_REQ_MAY_BACKLOG. This means the the crypto
driver should internally backlog requests which arrive when the queue is
full and process them later. Until the crypto hw's queue becomes full,
the driver returns -EINPROGRESS. When the crypto hw's queue if full,
the driver returns -EBUSY, and if CRYPTO_TFM_REQ_MAY_BACKLOG is set, is
expected to backlog the request and process it when the hardware has
queue space. At the point when the driver takes the request from the
backlog and starts processing it, it calls the completion function with
a status of -EINPROGRESS. The completion function is called (for a
second time, in the case of backlogged requests) with a status/err of 0
when a request is done.
Crypto drivers for hardware without hardware queueing use the helpers,
crypto_init_queue(), crypto_enqueue_request(), crypto_dequeue_request()
and crypto_get_backlog() helpers to implement this behaviour correctly,
while others implement this behaviour without these helpers (ccp, for
example).
dm-crypt (before the patch that needs reverting) uses this API
correctly. It queues up as many requests as the hw queues will allow
(i.e. as long as it gets back -EINPROGRESS from the request function).
Then, when it sees at least one backlogged request (gets -EBUSY), it
waits till that backlogged request is handled (completion gets called
with -EINPROGRESS), and then continues. The references to
af_alg_wait_for_completion() and af_alg_complete() in that commit's
commit message are irrelevant because those functions only handle one
request at a time, unlink dm-crypt.
The problem is that the Freescale CAAM driver, which that commit
describes as having being tested with, fails to implement the
backlogging behaviour correctly. In cam_jr_enqueue(), if the hardware
queue is full, it simply returns -EBUSY without backlogging the request.
What the observed deadlock was is not described in the commit message
but it is obviously the wait_for_completion() in crypto_convert() where
dm-crypto would wait for the completion being called with -EINPROGRESS
in the case of backlogged requests. This completion will never be
completed due to the bug in the CAAM driver.
Commit 0618764cb25 incorrectly made dm-crypt wait for every request,
even when the driver/hardware queues are not full, which means that
dm-crypt will never see -EBUSY. This means that that commit will cause
a performance regression on all crypto drivers which implement the API
correctly.
Revert it. Correct backlog handling should be implemented in the CAAM
driver instead.
Cc'ing stable purely because commit 0618764cb25 did. If for some reason
a stable@ kernel did pick up commit 0618764cb25 it should get reverted.
Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Reviewed-by: Horia Geanta <horia.geanta@freescale.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2015-05-05 15:15:56 +02:00
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
2015-05-15 17:00:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-28 14:16:07 -07:00
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-07-02 09:34:28 +01:00
|
|
|
|
2008-03-28 14:16:07 -07:00
|
|
|
|
|
|
|
|
|
2015-05-15 17:00:25 +02:00
|
|
|
|
2008-03-28 14:16:07 -07:00
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2008-03-28 14:16:07 -07:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2008-03-28 14:16:07 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:23:52 -05:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2015-09-09 21:34:51 -04:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-02-13 08:23:52 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
|
|
|
|
|
2007-12-13 14:16:10 +00:00
|
|
|
|
2015-02-13 08:23:52 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
2015-11-06 16:28:21 -08:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
|
|
|
|
|
2007-05-09 02:32:53 -07:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-05-09 02:32:52 -07:00
|
|
|
|
2006-10-03 01:15:40 -07:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
|
|
|
|
|
2007-05-09 02:32:54 -07:00
|
|
|
|
2007-12-13 14:16:10 +00:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-06 16:28:21 -08:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-02-13 08:23:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-13 14:16:10 +00:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
2015-11-06 16:28:21 -08:00
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2007-10-16 13:48:46 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-16 13:48:46 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2012-09-05 15:22:02 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-28 15:51:55 -04:00
|
|
|
|
|
|
|
|
|
2008-10-10 13:37:03 +01:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-10-10 13:37:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2008-10-10 13:37:03 +01:00
|
|
|
|
|
|
|
|
|
2008-10-10 13:37:02 +01:00
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2008-10-10 13:37:02 +01:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:43 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2009-03-16 17:44:36 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2014-02-20 18:01:01 -05:00
|
|
|
|
2014-03-28 15:51:55 -04:00
|
|
|
|
2009-03-16 17:44:36 +00:00
|
|
|
|
2015-07-20 15:29:37 +02:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-19 22:38:58 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:39 -07:00
|
|
|
|
2007-10-19 22:38:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-07-20 15:29:37 +02:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2007-07-12 17:26:32 +01:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-02-08 02:10:46 +00:00
|
|
|
|
2015-08-10 19:05:18 -04:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
2007-09-27 12:47:43 +02:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2008-02-08 02:10:46 +00:00
|
|
|
|
2007-10-16 13:48:46 +02:00
|
|
|
|
2008-02-08 02:10:46 +00:00
|
|
|
|
2015-08-10 19:05:18 -04:00
|
|
|
|
2008-02-08 02:10:46 +00:00
|
|
|
|
|
|
|
|
|
2015-08-10 19:05:18 -04:00
|
|
|
|
2008-02-08 02:10:46 +00:00
|
|
|
|
|
|
|
|
|
2007-09-27 12:47:43 +02:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2015-08-10 19:05:18 -04:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:43 +00:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
2007-07-12 17:26:32 +01:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2006-10-03 01:15:38 -07:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2015-04-09 16:53:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2015-04-09 16:53:24 -04:00
|
|
|
|
2011-03-10 08:52:07 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2013-10-11 15:44:27 -07:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2006-10-03 01:15:38 -07:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2008-02-08 02:10:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:52 +00:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2008-02-08 02:10:52 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-02-08 02:10:52 +00:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2008-02-08 02:10:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
dm crypt: fix a possible hang due to race condition on exit
A kernel thread executes __set_current_state(TASK_INTERRUPTIBLE),
__add_wait_queue, spin_unlock_irq and then tests kthread_should_stop().
It is possible that the processor reorders memory accesses so that
kthread_should_stop() is executed before __set_current_state(). If such
reordering happens, there is a possible race on thread termination:
CPU 0:
calls kthread_should_stop()
it tests KTHREAD_SHOULD_STOP bit, returns false
CPU 1:
calls kthread_stop(cc->write_thread)
sets the KTHREAD_SHOULD_STOP bit
calls wake_up_process on the kernel thread, that sets the thread
state to TASK_RUNNING
CPU 0:
sets __set_current_state(TASK_INTERRUPTIBLE)
spin_unlock_irq(&cc->write_thread_wait.lock)
schedule() - and the process is stuck and never terminates, because the
state is TASK_INTERRUPTIBLE and wake_up_process on CPU 1 already
terminated
Fix this race condition by using a new flag DM_CRYPT_EXIT_THREAD to
signal that the kernel thread should exit. The flag is set and tested
while holding cc->write_thread_wait.lock, so there is no possibility of
racy access to the flag.
Also, remove the unnecessary set_task_state(current, TASK_RUNNING)
following the schedule() call. When the process was woken up, its state
was already set to TASK_RUNNING. Other kernel code also doesn't set the
state to TASK_RUNNING following schedule() (for example,
do_wait_for_common in completion.c doesn't do it).
Fixes: dc2676210c42 ("dm crypt: offload writes to thread")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org # v4.0+
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2015-11-19 07:36:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-28 18:41:22 +01:00
|
|
|
|
2008-02-08 02:10:49 +00:00
|
|
|
|
2008-02-08 02:10:57 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:57 +00:00
|
|
|
|
2012-03-28 18:41:22 +01:00
|
|
|
|
2008-02-08 02:10:57 +00:00
|
|
|
|
|
|
|
|
|
2008-10-10 13:37:06 +01:00
|
|
|
|
2008-02-08 02:10:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-11 15:45:43 -07:00
|
|
|
|
2008-02-08 02:10:57 +00:00
|
|
|
|
2013-10-11 15:44:27 -07:00
|
|
|
|
2008-02-08 02:11:02 +00:00
|
|
|
|
2015-02-13 08:27:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:49 +00:00
|
|
|
|
|
|
|
|
|
2008-10-10 13:37:04 +01:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2008-10-10 13:37:08 +01:00
|
|
|
|
2008-10-21 17:45:00 +01:00
|
|
|
|
2008-02-08 02:10:57 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2008-10-10 13:37:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-10-21 17:45:00 +01:00
|
|
|
|
2008-10-10 13:37:04 +01:00
|
|
|
|
2015-02-13 08:23:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2008-02-08 02:11:02 +00:00
|
|
|
|
2015-02-13 08:23:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:02 +00:00
|
|
|
|
2008-02-08 02:10:59 +00:00
|
|
|
|
|
|
|
|
|
2012-03-28 18:41:22 +01:00
|
|
|
|
2008-02-08 02:10:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:49 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-02-08 02:10:43 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2008-10-10 13:37:02 +01:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
2008-02-08 02:10:38 +00:00
|
|
|
|
2008-02-08 02:10:54 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2008-02-08 02:10:43 +00:00
|
|
|
|
2012-03-28 18:41:22 +01:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:43 +00:00
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
2012-03-28 18:41:22 +01:00
|
|
|
|
2008-02-08 02:11:14 +00:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-03-16 17:44:33 +00:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
2015-05-15 17:00:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Revert "dm crypt: fix deadlock when async crypto algorithm returns -EBUSY"
This reverts Linux 4.1-rc1 commit 0618764cb25f6fa9fb31152995de42a8a0496475.
The problem which that commit attempts to fix actually lies in the
Freescale CAAM crypto driver not dm-crypt.
dm-crypt uses CRYPTO_TFM_REQ_MAY_BACKLOG. This means the the crypto
driver should internally backlog requests which arrive when the queue is
full and process them later. Until the crypto hw's queue becomes full,
the driver returns -EINPROGRESS. When the crypto hw's queue if full,
the driver returns -EBUSY, and if CRYPTO_TFM_REQ_MAY_BACKLOG is set, is
expected to backlog the request and process it when the hardware has
queue space. At the point when the driver takes the request from the
backlog and starts processing it, it calls the completion function with
a status of -EINPROGRESS. The completion function is called (for a
second time, in the case of backlogged requests) with a status/err of 0
when a request is done.
Crypto drivers for hardware without hardware queueing use the helpers,
crypto_init_queue(), crypto_enqueue_request(), crypto_dequeue_request()
and crypto_get_backlog() helpers to implement this behaviour correctly,
while others implement this behaviour without these helpers (ccp, for
example).
dm-crypt (before the patch that needs reverting) uses this API
correctly. It queues up as many requests as the hw queues will allow
(i.e. as long as it gets back -EINPROGRESS from the request function).
Then, when it sees at least one backlogged request (gets -EBUSY), it
waits till that backlogged request is handled (completion gets called
with -EINPROGRESS), and then continues. The references to
af_alg_wait_for_completion() and af_alg_complete() in that commit's
commit message are irrelevant because those functions only handle one
request at a time, unlink dm-crypt.
The problem is that the Freescale CAAM driver, which that commit
describes as having being tested with, fails to implement the
backlogging behaviour correctly. In cam_jr_enqueue(), if the hardware
queue is full, it simply returns -EBUSY without backlogging the request.
What the observed deadlock was is not described in the commit message
but it is obviously the wait_for_completion() in crypto_convert() where
dm-crypto would wait for the completion being called with -EINPROGRESS
in the case of backlogged requests. This completion will never be
completed due to the bug in the CAAM driver.
Commit 0618764cb25 incorrectly made dm-crypt wait for every request,
even when the driver/hardware queues are not full, which means that
dm-crypt will never see -EBUSY. This means that that commit will cause
a performance regression on all crypto drivers which implement the API
correctly.
Revert it. Correct backlog handling should be implemented in the CAAM
driver instead.
Cc'ing stable purely because commit 0618764cb25 did. If for some reason
a stable@ kernel did pick up commit 0618764cb25 it should get reverted.
Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Reviewed-by: Horia Geanta <horia.geanta@freescale.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2015-05-05 15:15:56 +02:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
Revert "dm crypt: fix deadlock when async crypto algorithm returns -EBUSY"
This reverts Linux 4.1-rc1 commit 0618764cb25f6fa9fb31152995de42a8a0496475.
The problem which that commit attempts to fix actually lies in the
Freescale CAAM crypto driver not dm-crypt.
dm-crypt uses CRYPTO_TFM_REQ_MAY_BACKLOG. This means the the crypto
driver should internally backlog requests which arrive when the queue is
full and process them later. Until the crypto hw's queue becomes full,
the driver returns -EINPROGRESS. When the crypto hw's queue if full,
the driver returns -EBUSY, and if CRYPTO_TFM_REQ_MAY_BACKLOG is set, is
expected to backlog the request and process it when the hardware has
queue space. At the point when the driver takes the request from the
backlog and starts processing it, it calls the completion function with
a status of -EINPROGRESS. The completion function is called (for a
second time, in the case of backlogged requests) with a status/err of 0
when a request is done.
Crypto drivers for hardware without hardware queueing use the helpers,
crypto_init_queue(), crypto_enqueue_request(), crypto_dequeue_request()
and crypto_get_backlog() helpers to implement this behaviour correctly,
while others implement this behaviour without these helpers (ccp, for
example).
dm-crypt (before the patch that needs reverting) uses this API
correctly. It queues up as many requests as the hw queues will allow
(i.e. as long as it gets back -EINPROGRESS from the request function).
Then, when it sees at least one backlogged request (gets -EBUSY), it
waits till that backlogged request is handled (completion gets called
with -EINPROGRESS), and then continues. The references to
af_alg_wait_for_completion() and af_alg_complete() in that commit's
commit message are irrelevant because those functions only handle one
request at a time, unlink dm-crypt.
The problem is that the Freescale CAAM driver, which that commit
describes as having being tested with, fails to implement the
backlogging behaviour correctly. In cam_jr_enqueue(), if the hardware
queue is full, it simply returns -EBUSY without backlogging the request.
What the observed deadlock was is not described in the commit message
but it is obviously the wait_for_completion() in crypto_convert() where
dm-crypto would wait for the completion being called with -EINPROGRESS
in the case of backlogged requests. This completion will never be
completed due to the bug in the CAAM driver.
Commit 0618764cb25 incorrectly made dm-crypt wait for every request,
even when the driver/hardware queues are not full, which means that
dm-crypt will never see -EBUSY. This means that that commit will cause
a performance regression on all crypto drivers which implement the API
correctly.
Revert it. Correct backlog handling should be implemented in the CAAM
driver instead.
Cc'ing stable purely because commit 0618764cb25 did. If for some reason
a stable@ kernel did pick up commit 0618764cb25 it should get reverted.
Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Reviewed-by: Horia Geanta <horia.geanta@freescale.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2015-05-05 15:15:56 +02:00
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-28 18:41:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-28 15:51:55 -04:00
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
2012-07-27 15:08:04 +01:00
|
|
|
|
Revert "dm crypt: fix deadlock when async crypto algorithm returns -EBUSY"
This reverts Linux 4.1-rc1 commit 0618764cb25f6fa9fb31152995de42a8a0496475.
The problem which that commit attempts to fix actually lies in the
Freescale CAAM crypto driver not dm-crypt.
dm-crypt uses CRYPTO_TFM_REQ_MAY_BACKLOG. This means the the crypto
driver should internally backlog requests which arrive when the queue is
full and process them later. Until the crypto hw's queue becomes full,
the driver returns -EINPROGRESS. When the crypto hw's queue if full,
the driver returns -EBUSY, and if CRYPTO_TFM_REQ_MAY_BACKLOG is set, is
expected to backlog the request and process it when the hardware has
queue space. At the point when the driver takes the request from the
backlog and starts processing it, it calls the completion function with
a status of -EINPROGRESS. The completion function is called (for a
second time, in the case of backlogged requests) with a status/err of 0
when a request is done.
Crypto drivers for hardware without hardware queueing use the helpers,
crypto_init_queue(), crypto_enqueue_request(), crypto_dequeue_request()
and crypto_get_backlog() helpers to implement this behaviour correctly,
while others implement this behaviour without these helpers (ccp, for
example).
dm-crypt (before the patch that needs reverting) uses this API
correctly. It queues up as many requests as the hw queues will allow
(i.e. as long as it gets back -EINPROGRESS from the request function).
Then, when it sees at least one backlogged request (gets -EBUSY), it
waits till that backlogged request is handled (completion gets called
with -EINPROGRESS), and then continues. The references to
af_alg_wait_for_completion() and af_alg_complete() in that commit's
commit message are irrelevant because those functions only handle one
request at a time, unlink dm-crypt.
The problem is that the Freescale CAAM driver, which that commit
describes as having being tested with, fails to implement the
backlogging behaviour correctly. In cam_jr_enqueue(), if the hardware
queue is full, it simply returns -EBUSY without backlogging the request.
What the observed deadlock was is not described in the commit message
but it is obviously the wait_for_completion() in crypto_convert() where
dm-crypto would wait for the completion being called with -EINPROGRESS
in the case of backlogged requests. This completion will never be
completed due to the bug in the CAAM driver.
Commit 0618764cb25 incorrectly made dm-crypt wait for every request,
even when the driver/hardware queues are not full, which means that
dm-crypt will never see -EBUSY. This means that that commit will cause
a performance regression on all crypto drivers which implement the API
correctly.
Revert it. Correct backlog handling should be implemented in the CAAM
driver instead.
Cc'ing stable purely because commit 0618764cb25 did. If for some reason
a stable@ kernel did pick up commit 0618764cb25 it should get reverted.
Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Reviewed-by: Horia Geanta <horia.geanta@freescale.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2015-05-05 15:15:56 +02:00
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
|
|
|
|
|
2012-03-28 18:41:22 +01:00
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
2012-03-28 18:41:22 +01:00
|
|
|
|
2008-02-08 02:11:12 +00:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
2008-02-08 02:10:52 +00:00
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2008-02-08 02:10:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:07:59 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:03 +01:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2013-10-28 23:21:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
2011-03-24 13:54:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:49 +00:00
|
|
|
|
2011-03-24 13:54:27 +00:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2011-01-13 19:59:49 +00:00
|
|
|
|
|
|
|
|
|
2011-03-24 13:54:27 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2011-01-13 19:59:49 +00:00
|
|
|
|
2011-03-24 13:54:27 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-03-24 13:54:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dm crypt: fix a possible hang due to race condition on exit
A kernel thread executes __set_current_state(TASK_INTERRUPTIBLE),
__add_wait_queue, spin_unlock_irq and then tests kthread_should_stop().
It is possible that the processor reorders memory accesses so that
kthread_should_stop() is executed before __set_current_state(). If such
reordering happens, there is a possible race on thread termination:
CPU 0:
calls kthread_should_stop()
it tests KTHREAD_SHOULD_STOP bit, returns false
CPU 1:
calls kthread_stop(cc->write_thread)
sets the KTHREAD_SHOULD_STOP bit
calls wake_up_process on the kernel thread, that sets the thread
state to TASK_RUNNING
CPU 0:
sets __set_current_state(TASK_INTERRUPTIBLE)
spin_unlock_irq(&cc->write_thread_wait.lock)
schedule() - and the process is stuck and never terminates, because the
state is TASK_INTERRUPTIBLE and wake_up_process on CPU 1 already
terminated
Fix this race condition by using a new flag DM_CRYPT_EXIT_THREAD to
signal that the kernel thread should exit. The flag is set and tested
while holding cc->write_thread_wait.lock, so there is no possibility of
racy access to the flag.
Also, remove the unnecessary set_task_state(current, TASK_RUNNING)
following the schedule() call. When the process was woken up, its state
was already set to TASK_RUNNING. Other kernel code also doesn't set the
state to TASK_RUNNING following schedule() (for example,
do_wait_for_common in completion.c doesn't do it).
Fixes: dc2676210c42 ("dm crypt: offload writes to thread")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org # v4.0+
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2015-11-19 07:36:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
dm crypt: fix a possible hang due to race condition on exit
A kernel thread executes __set_current_state(TASK_INTERRUPTIBLE),
__add_wait_queue, spin_unlock_irq and then tests kthread_should_stop().
It is possible that the processor reorders memory accesses so that
kthread_should_stop() is executed before __set_current_state(). If such
reordering happens, there is a possible race on thread termination:
CPU 0:
calls kthread_should_stop()
it tests KTHREAD_SHOULD_STOP bit, returns false
CPU 1:
calls kthread_stop(cc->write_thread)
sets the KTHREAD_SHOULD_STOP bit
calls wake_up_process on the kernel thread, that sets the thread
state to TASK_RUNNING
CPU 0:
sets __set_current_state(TASK_INTERRUPTIBLE)
spin_unlock_irq(&cc->write_thread_wait.lock)
schedule() - and the process is stuck and never terminates, because the
state is TASK_INTERRUPTIBLE and wake_up_process on CPU 1 already
terminated
Fix this race condition by using a new flag DM_CRYPT_EXIT_THREAD to
signal that the kernel thread should exit. The flag is set and tested
while holding cc->write_thread_wait.lock, so there is no possibility of
racy access to the flag.
Also, remove the unnecessary set_task_state(current, TASK_RUNNING)
following the schedule() call. When the process was woken up, its state
was already set to TASK_RUNNING. Other kernel code also doesn't set the
state to TASK_RUNNING following schedule() (for example,
do_wait_for_common in completion.c doesn't do it).
Fixes: dc2676210c42 ("dm crypt: offload writes to thread")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org # v4.0+
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2015-11-19 07:36:50 -05:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-13 14:15:05 +02:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2011-01-13 19:59:52 +00:00
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
dm: reject trailing characters in sccanf input
Device mapper uses sscanf to convert arguments to numbers. The problem is that
the way we use it ignores additional unmatched characters in the scanned string.
For example, this `if (sscanf(string, "%d", &number) == 1)' will match a number,
but also it will match number with some garbage appended, like "123abc".
As a result, device mapper accepts garbage after some numbers. For example
the command `dmsetup create vg1-new --table "0 16384 linear 254:1bla 34816bla"'
will pass without an error.
This patch fixes all sscanf uses in device mapper. It appends "%c" with
a pointer to a dummy character variable to every sscanf statement.
The construct `if (sscanf(string, "%d%c", &number, &dummy) == 1)' succeeds
only if string is a null-terminated number (optionally preceded by some
whitespace characters). If there is some character appended after the number,
sscanf matches "%c", writes the character to the dummy variable and returns 2.
We check the return value for 1 and consequently reject numbers with some
garbage appended.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2012-03-28 18:41:26 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dm: reject trailing characters in sccanf input
Device mapper uses sscanf to convert arguments to numbers. The problem is that
the way we use it ignores additional unmatched characters in the scanned string.
For example, this `if (sscanf(string, "%d", &number) == 1)' will match a number,
but also it will match number with some garbage appended, like "123abc".
As a result, device mapper accepts garbage after some numbers. For example
the command `dmsetup create vg1-new --table "0 16384 linear 254:1bla 34816bla"'
will pass without an error.
This patch fixes all sscanf uses in device mapper. It appends "%c" with
a pointer to a dummy character variable to every sscanf statement.
The construct `if (sscanf(string, "%d%c", &number, &dummy) == 1)' succeeds
only if string is a null-terminated number (optionally preceded by some
whitespace characters). If there is some character appended after the number,
sscanf matches "%c", writes the character to the dummy variable and returns 2.
We check the return value for 1 and consequently reject numbers with some
garbage appended.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2012-03-28 18:41:26 +01:00
|
|
|
|
2011-01-13 19:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:03 +01:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2011-01-13 19:59:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-22 20:29:17 +10:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-22 20:29:17 +10:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:52:25 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2006-09-03 08:56:39 +10:00
|
|
|
|
|
|
|
|
|
2007-05-09 02:32:55 -07:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
2013-10-28 23:21:03 +01:00
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
2013-10-28 23:21:03 +01:00
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:55 +00:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2006-06-26 00:27:35 -07:00
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2013-10-28 23:21:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:56 +00:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
dm crypt: fix access beyond the end of allocated space
The DM crypt target accesses memory beyond allocated space resulting in
a crash on 32 bit x86 systems.
This bug is very old (it dates back to 2.6.25 commit 3a7f6c990ad04 "dm
crypt: use async crypto"). However, this bug was masked by the fact
that kmalloc rounds the size up to the next power of two. This bug
wasn't exposed until 3.17-rc1 commit 298a9fa08a ("dm crypt: use per-bio
data"). By switching to using per-bio data there was no longer any
padding beyond the end of a dm-crypt allocated memory block.
To minimize allocation overhead dm-crypt puts several structures into one
block allocated with kmalloc. The block holds struct ablkcipher_request,
cipher-specific scratch pad (crypto_ablkcipher_reqsize(any_tfm(cc))),
struct dm_crypt_request and an initialization vector.
The variable dmreq_start is set to offset of struct dm_crypt_request
within this memory block. dm-crypt allocates the block with this size:
cc->dmreq_start + sizeof(struct dm_crypt_request) + cc->iv_size.
When accessing the initialization vector, dm-crypt uses the function
iv_of_dmreq, which performs this calculation: ALIGN((unsigned long)(dmreq
+ 1), crypto_ablkcipher_alignmask(any_tfm(cc)) + 1).
dm-crypt allocated "cc->iv_size" bytes beyond the end of dm_crypt_request
structure. However, when dm-crypt accesses the initialization vector, it
takes a pointer to the end of dm_crypt_request, aligns it, and then uses
it as the initialization vector. If the end of dm_crypt_request is not
aligned on a crypto_ablkcipher_alignmask(any_tfm(cc)) boundary the
alignment causes the initialization vector to point beyond the allocated
space.
Fix this bug by calculating the variable iv_size_padding and adding it
to the allocated size.
Also correct the alignment of dm_crypt_request. struct dm_crypt_request
is specific to dm-crypt (it isn't used by the crypto subsystem at all),
so it is aligned on __alignof__(struct dm_crypt_request).
Also align per_bio_data_size on ARCH_KMALLOC_MINALIGN, so that it is
aligned as if the block was allocated with kmalloc.
Reported-by: Krzysztof Kolasa <kkolasa@winsoft.pl>
Tested-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2014-08-28 11:09:31 -04:00
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
|
|
|
|
|
dm: reject trailing characters in sccanf input
Device mapper uses sscanf to convert arguments to numbers. The problem is that
the way we use it ignores additional unmatched characters in the scanned string.
For example, this `if (sscanf(string, "%d", &number) == 1)' will match a number,
but also it will match number with some garbage appended, like "123abc".
As a result, device mapper accepts garbage after some numbers. For example
the command `dmsetup create vg1-new --table "0 16384 linear 254:1bla 34816bla"'
will pass without an error.
This patch fixes all sscanf uses in device mapper. It appends "%c" with
a pointer to a dummy character variable to every sscanf statement.
The construct `if (sscanf(string, "%d%c", &number, &dummy) == 1)' succeeds
only if string is a null-terminated number (optionally preceded by some
whitespace characters). If there is some character appended after the number,
sscanf matches "%c", writes the character to the dummy variable and returns 2.
We check the return value for 1 and consequently reject numbers with some
garbage appended.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2012-03-28 18:41:26 +01:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
2015-02-13 08:27:08 -05:00
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:49 +00:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
dm crypt: fix access beyond the end of allocated space
The DM crypt target accesses memory beyond allocated space resulting in
a crash on 32 bit x86 systems.
This bug is very old (it dates back to 2.6.25 commit 3a7f6c990ad04 "dm
crypt: use async crypto"). However, this bug was masked by the fact
that kmalloc rounds the size up to the next power of two. This bug
wasn't exposed until 3.17-rc1 commit 298a9fa08a ("dm crypt: use per-bio
data"). By switching to using per-bio data there was no longer any
padding beyond the end of a dm-crypt allocated memory block.
To minimize allocation overhead dm-crypt puts several structures into one
block allocated with kmalloc. The block holds struct ablkcipher_request,
cipher-specific scratch pad (crypto_ablkcipher_reqsize(any_tfm(cc))),
struct dm_crypt_request and an initialization vector.
The variable dmreq_start is set to offset of struct dm_crypt_request
within this memory block. dm-crypt allocates the block with this size:
cc->dmreq_start + sizeof(struct dm_crypt_request) + cc->iv_size.
When accessing the initialization vector, dm-crypt uses the function
iv_of_dmreq, which performs this calculation: ALIGN((unsigned long)(dmreq
+ 1), crypto_ablkcipher_alignmask(any_tfm(cc)) + 1).
dm-crypt allocated "cc->iv_size" bytes beyond the end of dm_crypt_request
structure. However, when dm-crypt accesses the initialization vector, it
takes a pointer to the end of dm_crypt_request, aligns it, and then uses
it as the initialization vector. If the end of dm_crypt_request is not
aligned on a crypto_ablkcipher_alignmask(any_tfm(cc)) boundary the
alignment causes the initialization vector to point beyond the allocated
space.
Fix this bug by calculating the variable iv_size_padding and adding it
to the allocated size.
Also correct the alignment of dm_crypt_request. struct dm_crypt_request
is specific to dm-crypt (it isn't used by the crypto subsystem at all),
so it is aligned on __alignof__(struct dm_crypt_request).
Also align per_bio_data_size on ARCH_KMALLOC_MINALIGN, so that it is
aligned as if the block was allocated with kmalloc.
Reported-by: Krzysztof Kolasa <kkolasa@winsoft.pl>
Tested-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2014-08-28 11:09:31 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
2015-02-13 08:25:26 -05:00
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
dm crypt: fix access beyond the end of allocated space
The DM crypt target accesses memory beyond allocated space resulting in
a crash on 32 bit x86 systems.
This bug is very old (it dates back to 2.6.25 commit 3a7f6c990ad04 "dm
crypt: use async crypto"). However, this bug was masked by the fact
that kmalloc rounds the size up to the next power of two. This bug
wasn't exposed until 3.17-rc1 commit 298a9fa08a ("dm crypt: use per-bio
data"). By switching to using per-bio data there was no longer any
padding beyond the end of a dm-crypt allocated memory block.
To minimize allocation overhead dm-crypt puts several structures into one
block allocated with kmalloc. The block holds struct ablkcipher_request,
cipher-specific scratch pad (crypto_ablkcipher_reqsize(any_tfm(cc))),
struct dm_crypt_request and an initialization vector.
The variable dmreq_start is set to offset of struct dm_crypt_request
within this memory block. dm-crypt allocates the block with this size:
cc->dmreq_start + sizeof(struct dm_crypt_request) + cc->iv_size.
When accessing the initialization vector, dm-crypt uses the function
iv_of_dmreq, which performs this calculation: ALIGN((unsigned long)(dmreq
+ 1), crypto_ablkcipher_alignmask(any_tfm(cc)) + 1).
dm-crypt allocated "cc->iv_size" bytes beyond the end of dm_crypt_request
structure. However, when dm-crypt accesses the initialization vector, it
takes a pointer to the end of dm_crypt_request, aligns it, and then uses
it as the initialization vector. If the end of dm_crypt_request is not
aligned on a crypto_ablkcipher_alignmask(any_tfm(cc)) boundary the
alignment causes the initialization vector to point beyond the allocated
space.
Fix this bug by calculating the variable iv_size_padding and adding it
to the allocated size.
Also correct the alignment of dm_crypt_request. struct dm_crypt_request
is specific to dm-crypt (it isn't used by the crypto subsystem at all),
so it is aligned on __alignof__(struct dm_crypt_request).
Also align per_bio_data_size on ARCH_KMALLOC_MINALIGN, so that it is
aligned as if the block was allocated with kmalloc.
Reported-by: Krzysztof Kolasa <kkolasa@winsoft.pl>
Tested-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2014-08-28 11:09:31 -04:00
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
2008-02-08 02:11:07 +00:00
|
|
|
|
|
|
|
|
|
2014-03-28 15:51:55 -04:00
|
|
|
|
dm crypt: fix access beyond the end of allocated space
The DM crypt target accesses memory beyond allocated space resulting in
a crash on 32 bit x86 systems.
This bug is very old (it dates back to 2.6.25 commit 3a7f6c990ad04 "dm
crypt: use async crypto"). However, this bug was masked by the fact
that kmalloc rounds the size up to the next power of two. This bug
wasn't exposed until 3.17-rc1 commit 298a9fa08a ("dm crypt: use per-bio
data"). By switching to using per-bio data there was no longer any
padding beyond the end of a dm-crypt allocated memory block.
To minimize allocation overhead dm-crypt puts several structures into one
block allocated with kmalloc. The block holds struct ablkcipher_request,
cipher-specific scratch pad (crypto_ablkcipher_reqsize(any_tfm(cc))),
struct dm_crypt_request and an initialization vector.
The variable dmreq_start is set to offset of struct dm_crypt_request
within this memory block. dm-crypt allocates the block with this size:
cc->dmreq_start + sizeof(struct dm_crypt_request) + cc->iv_size.
When accessing the initialization vector, dm-crypt uses the function
iv_of_dmreq, which performs this calculation: ALIGN((unsigned long)(dmreq
+ 1), crypto_ablkcipher_alignmask(any_tfm(cc)) + 1).
dm-crypt allocated "cc->iv_size" bytes beyond the end of dm_crypt_request
structure. However, when dm-crypt accesses the initialization vector, it
takes a pointer to the end of dm_crypt_request, aligns it, and then uses
it as the initialization vector. If the end of dm_crypt_request is not
aligned on a crypto_ablkcipher_alignmask(any_tfm(cc)) boundary the
alignment causes the initialization vector to point beyond the allocated
space.
Fix this bug by calculating the variable iv_size_padding and adding it
to the allocated size.
Also correct the alignment of dm_crypt_request. struct dm_crypt_request
is specific to dm-crypt (it isn't used by the crypto subsystem at all),
so it is aligned on __alignof__(struct dm_crypt_request).
Also align per_bio_data_size on ARCH_KMALLOC_MINALIGN, so that it is
aligned as if the block was allocated with kmalloc.
Reported-by: Krzysztof Kolasa <kkolasa@winsoft.pl>
Tested-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2014-08-28 11:09:31 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-28 15:51:55 -04:00
|
|
|
|
2015-02-13 08:23:52 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-06-26 00:27:35 -07:00
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2008-12-10 15:35:05 +01:00
|
|
|
|
2006-10-03 01:15:40 -07:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
2006-10-03 01:15:40 -07:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:24:41 -05:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
dm: reject trailing characters in sccanf input
Device mapper uses sscanf to convert arguments to numbers. The problem is that
the way we use it ignores additional unmatched characters in the scanned string.
For example, this `if (sscanf(string, "%d", &number) == 1)' will match a number,
but also it will match number with some garbage appended, like "123abc".
As a result, device mapper accepts garbage after some numbers. For example
the command `dmsetup create vg1-new --table "0 16384 linear 254:1bla 34816bla"'
will pass without an error.
This patch fixes all sscanf uses in device mapper. It appends "%c" with
a pointer to a dummy character variable to every sscanf statement.
The construct `if (sscanf(string, "%d%c", &number, &dummy) == 1)' succeeds
only if string is a null-terminated number (optionally preceded by some
whitespace characters). If there is some character appended after the number,
sscanf matches "%c", writes the character to the dummy variable and returns 2.
We check the return value for 1 and consequently reject numbers with some
garbage appended.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2012-03-28 18:41:26 +01:00
|
|
|
|
2006-06-26 00:27:35 -07:00
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-03-27 01:17:48 -08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-07-31 09:20:36 -04:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-31 09:20:36 -04:00
|
|
|
|
dm: reject trailing characters in sccanf input
Device mapper uses sscanf to convert arguments to numbers. The problem is that
the way we use it ignores additional unmatched characters in the scanned string.
For example, this `if (sscanf(string, "%d", &number) == 1)' will match a number,
but also it will match number with some garbage appended, like "123abc".
As a result, device mapper accepts garbage after some numbers. For example
the command `dmsetup create vg1-new --table "0 16384 linear 254:1bla 34816bla"'
will pass without an error.
This patch fixes all sscanf uses in device mapper. It appends "%c" with
a pointer to a dummy character variable to every sscanf statement.
The construct `if (sscanf(string, "%d%c", &number, &dummy) == 1)' succeeds
only if string is a null-terminated number (optionally preceded by some
whitespace characters). If there is some character appended after the number,
sscanf matches "%c", writes the character to the dummy variable and returns 2.
We check the return value for 1 and consequently reject numbers with some
garbage appended.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2012-03-28 18:41:26 +01:00
|
|
|
|
2006-06-26 00:27:35 -07:00
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-03-27 01:17:48 -08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-16 22:00:50 -04:00
|
|
|
|
2015-02-13 08:23:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
2015-02-13 08:23:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:23:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
2013-07-30 08:40:21 -04:00
|
|
|
|
2007-10-19 22:38:58 +01:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
2007-10-19 22:38:58 +01:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:23:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-19 22:38:58 +01:00
|
|
|
|
2007-10-19 22:38:57 +01:00
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
2007-10-19 22:38:57 +01:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2015-02-13 08:27:41 -05:00
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-01 22:45:47 +00:00
|
|
|
|
2012-07-27 15:08:08 +01:00
|
|
|
|
2011-09-25 23:26:21 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2010-08-12 04:14:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2012-12-21 20:23:41 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-07-12 17:26:32 +01:00
|
|
|
|
2012-07-27 15:08:05 +01:00
|
|
|
|
2009-06-22 10:12:23 +01:00
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-22 10:12:23 +01:00
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
2013-10-11 15:44:27 -07:00
|
|
|
|
|
|
|
|
|
2009-06-22 10:12:23 +01:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2014-03-28 15:51:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-19 22:38:58 +01:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:59 -05:00
|
|
|
|
2011-01-13 19:59:53 +00:00
|
|
|
|
2007-10-19 22:38:58 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-12-08 02:41:06 -08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2013-03-01 22:45:44 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-08-12 04:14:07 +01:00
|
|
|
|
2013-03-01 22:45:44 +00:00
|
|
|
|
2015-02-13 08:23:09 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 19:59:52 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-03-01 22:45:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-03-27 01:17:48 -08:00
|
|
|
|
|
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
2015-02-13 08:23:09 -05:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:08 -05:00
|
|
|
|
2015-02-13 08:23:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:27:08 -05:00
|
|
|
|
|
|
|
|
|
2015-02-13 08:23:09 -05:00
|
|
|
|
2011-08-02 12:32:08 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-02 12:32:04 +01:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-02 12:32:04 +01:00
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-02 12:32:04 +01:00
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-22 10:12:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-23 20:30:42 +01:00
|
|
|
|
2009-06-22 10:12:33 +01:00
|
|
|
|
|
|
|
|
|
2015-09-09 21:34:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2015-09-09 21:34:51 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-22 10:12:33 +01:00
|
|
|
|
2015-09-09 21:34:51 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 08:25:26 -05:00
|
|
|
|
2006-06-26 00:27:35 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-06 03:04:58 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-24 14:27:04 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|