diff options
| -rw-r--r-- | drivers/md/dm-crypt.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index da0b2e05fdf1..9b99ee9a8690 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/atomic.h> | 24 | #include <linux/atomic.h> |
| 25 | #include <linux/scatterlist.h> | 25 | #include <linux/scatterlist.h> |
| 26 | #include <linux/rbtree.h> | 26 | #include <linux/rbtree.h> |
| 27 | #include <linux/ctype.h> | ||
| 27 | #include <asm/page.h> | 28 | #include <asm/page.h> |
| 28 | #include <asm/unaligned.h> | 29 | #include <asm/unaligned.h> |
| 29 | #include <crypto/hash.h> | 30 | #include <crypto/hash.h> |
| @@ -1489,6 +1490,14 @@ static int crypt_setkey(struct crypt_config *cc) | |||
| 1489 | 1490 | ||
| 1490 | #ifdef CONFIG_KEYS | 1491 | #ifdef CONFIG_KEYS |
| 1491 | 1492 | ||
| 1493 | static bool contains_whitespace(const char *str) | ||
| 1494 | { | ||
| 1495 | while (*str) | ||
| 1496 | if (isspace(*str++)) | ||
| 1497 | return true; | ||
| 1498 | return false; | ||
| 1499 | } | ||
| 1500 | |||
| 1492 | static int crypt_set_keyring_key(struct crypt_config *cc, const char *key_string) | 1501 | static int crypt_set_keyring_key(struct crypt_config *cc, const char *key_string) |
| 1493 | { | 1502 | { |
| 1494 | char *new_key_string, *key_desc; | 1503 | char *new_key_string, *key_desc; |
| @@ -1496,6 +1505,15 @@ static int crypt_set_keyring_key(struct crypt_config *cc, const char *key_string | |||
| 1496 | struct key *key; | 1505 | struct key *key; |
| 1497 | const struct user_key_payload *ukp; | 1506 | const struct user_key_payload *ukp; |
| 1498 | 1507 | ||
| 1508 | /* | ||
| 1509 | * Reject key_string with whitespace. dm core currently lacks code for | ||
| 1510 | * proper whitespace escaping in arguments on DM_TABLE_STATUS path. | ||
| 1511 | */ | ||
| 1512 | if (contains_whitespace(key_string)) { | ||
| 1513 | DMERR("whitespace chars not allowed in key string"); | ||
| 1514 | return -EINVAL; | ||
| 1515 | } | ||
| 1516 | |||
| 1499 | /* look for next ':' separating key_type from key_description */ | 1517 | /* look for next ':' separating key_type from key_description */ |
| 1500 | key_desc = strpbrk(key_string, ":"); | 1518 | key_desc = strpbrk(key_string, ":"); |
| 1501 | if (!key_desc || key_desc == key_string || !strlen(key_desc + 1)) | 1519 | if (!key_desc || key_desc == key_string || !strlen(key_desc + 1)) |
