Files
linux/include/linux
Mikulas Patocka a931707282 dm: fix truncated status strings
commit fd7c092e71 upstream.

Avoid returning a truncated table or status string instead of setting
the DM_BUFFER_FULL_FLAG when the last target of a table fills the
buffer.

When processing a table or status request, the function retrieve_status
calls ti->type->status. If ti->type->status returns non-zero,
retrieve_status assumes that the buffer overflowed and sets
DM_BUFFER_FULL_FLAG.

However, targets don't return non-zero values from their status method
on overflow. Most targets returns always zero.

If a buffer overflow happens in a target that is not the last in the
table, it gets noticed during the next iteration of the loop in
retrieve_status; but if a buffer overflow happens in the last target, it
goes unnoticed and erroneously truncated data is returned.

In the current code, the targets behave in the following way:
* dm-crypt returns -ENOMEM if there is not enough space to store the
  key, but it returns 0 on all other overflows.
* dm-thin returns errors from the status method if a disk error happened.
  This is incorrect because retrieve_status doesn't check the error
  code, it assumes that all non-zero values mean buffer overflow.
* all the other targets always return 0.

This patch changes the ti->type->status function to return void (because
most targets don't use the return code). Overflow is detected in
retrieve_status: if the status method fills up the remaining space
completely, it is assumed that buffer overflow happened.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-14 11:26:11 -07:00
..
2011-03-31 11:26:23 -03:00
2013-01-02 17:36:10 -08:00
2013-01-27 01:35:32 +01:00
2013-01-02 17:36:10 -08:00
2012-12-07 17:02:47 +00:00
2012-11-30 12:37:36 +01:00
2011-07-22 08:25:37 -07:00
2012-07-30 17:25:21 -07:00
2011-07-20 20:47:43 -04:00
2012-10-08 13:50:20 +10:30
2012-12-02 00:05:12 +00:00
2011-10-26 15:43:25 -04:00
2011-03-11 14:25:50 +00:00
2012-09-19 19:08:46 -06:00
2012-09-20 14:31:45 +02:00
2011-08-03 11:30:42 -04:00
2011-07-26 16:49:47 -07:00
2011-03-31 11:26:23 -03:00
2012-07-30 17:25:11 -07:00
2012-01-03 22:54:57 -05:00
2011-10-29 21:20:22 +02:00
2011-03-31 11:26:23 -03:00
2012-03-23 16:58:38 -07:00
2011-07-25 20:57:16 -07:00
2012-12-20 13:57:36 -05:00
2011-01-10 08:51:44 -08:00
2012-02-20 19:46:36 +11:00
2011-05-29 13:03:09 +01:00
2012-11-08 16:58:31 +01:00
2012-09-30 18:02:20 -07:00
2012-11-28 11:54:40 +01:00
2011-11-26 14:59:39 -05:00
2012-10-16 18:49:15 -07:00
2011-09-14 15:24:51 -04:00
2012-11-22 13:43:27 +09:00
2012-11-28 21:49:02 -05:00
2011-01-10 08:51:44 -08:00
2012-11-28 21:49:02 -05:00
2012-11-08 16:58:30 +01:00
2012-04-27 10:46:45 +08:00
2012-11-21 10:07:48 +01:00
2011-07-01 15:34:45 -07:00
2012-10-29 21:31:32 +01:00
2011-03-31 11:26:23 -03:00
2012-03-26 21:47:19 +02:00
2012-03-26 21:47:19 +02:00
2012-03-26 21:47:19 +02:00
2011-02-23 00:53:26 +00:00
2012-11-23 12:23:40 +01:00
2011-07-01 10:37:15 +02:00
2012-12-14 13:05:26 +10:30
2011-07-21 13:47:54 -07:00
2013-01-10 10:57:01 -08:00
2012-09-07 14:57:45 -04:00
2012-03-20 12:47:48 +01:00
2012-09-11 10:15:02 +02:00
2012-03-20 12:47:47 +01:00
2012-11-21 15:09:26 -08:00
2012-07-17 09:13:37 -07:00
2012-05-31 17:49:32 -07:00
2012-09-26 13:52:36 -07:00
2011-01-13 17:32:47 -08:00
2011-01-24 14:45:11 +10:30
2012-11-20 16:15:02 +10:00
2012-11-03 14:50:15 -04:00
2011-09-16 19:20:20 -04:00
2012-10-10 01:15:44 -04:00
2011-04-25 18:14:10 -07:00
2012-03-15 21:41:34 +01:00
2012-12-12 17:38:33 -08:00
2012-12-14 13:06:40 +10:30
2011-07-26 16:49:47 -07:00
2012-12-25 18:45:06 -05:00
2012-12-11 17:22:27 -08:00
2012-10-17 15:53:02 -05:00
2012-10-10 22:41:05 -04:00
2012-07-10 10:32:06 -05:00
2012-05-21 14:31:48 +01:00
2012-07-31 18:42:43 -07:00
2012-06-20 14:39:36 -07:00
2011-01-16 13:47:07 -05:00
2012-01-06 12:10:26 -08:00
2011-11-02 16:07:02 -07:00
2011-03-31 11:26:23 -03:00
2013-01-03 15:57:14 -08:00
2012-03-20 21:29:38 -04:00
2012-01-03 22:55:07 -05:00
2011-01-14 02:36:43 +00:00
2012-11-16 14:33:04 -08:00
2012-10-06 03:05:01 +09:00
2012-09-27 12:45:28 +02:00
2012-12-18 15:02:13 -08:00
2012-12-18 15:02:14 -08:00
2011-03-31 11:26:23 -03:00
2012-06-05 17:32:30 +02:00
2012-06-13 21:16:42 +02:00
2012-10-27 15:38:29 -07:00
2011-08-16 00:16:49 -07:00
2012-10-09 16:22:55 +09:00
2012-08-21 16:28:31 +02:00
2012-10-09 16:22:32 +09:00
2012-07-22 23:57:55 +04:00
2012-10-22 16:58:28 -07:00
2012-11-15 17:20:58 -08:00
2012-09-05 17:21:36 -07:00
2013-01-25 15:06:01 -08:00
2011-03-31 11:26:23 -03:00
2011-01-13 08:03:24 -08:00