Bug 138338 - dmsetup fails to set up crypto mapping with cipher_null
dmsetup fails to set up crypto mapping with cipher_null
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Alasdair Kergon
Depends On:
  Show dependency treegraph
Reported: 2004-11-08 08:16 EST by Ralf Ertzinger
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-12-21 11:17:49 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Ralf Ertzinger 2004-11-08 08:16:31 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3)
Gecko/20041104 Firefox/1.0RC1

Description of problem:
Note: maybe this needs to be fixed in the kernel itself.

Trying to set up a dm crypto mapping with dmsetup fails (/dev/loop0 is
a 16MB file bound with losetup):

[sun@nausicaa ~/crypto :) 56]$ echo "0 32768 crypt cipher_null-plain 0
0 /dev/loop0 0" | sudo /sbin/dmsetup create lall
device-mapper ioctl cmd 9 failed: Invalid argument
Command failed

This leaves the mapping in a semi-setup state:
[sun@nausicaa ~/crypto :( (1) 57]$ ls -l /dev/mapper
total 0
crw-------  1 root root 10, 63 Nov  8 11:28 control
[sun@nausicaa ~/crypto :) 58]$ sudo /sbin/dmsetup ls
lall    (253, 0)

cryptsetup also fails to create such a mapping (same error message)

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Try to set up a dm crypt mapping with cipher_null

Actual Results:  Fails to setup

Expected Results:  Create a mapping

Additional info:

Although it looks kind of pointless to create a mapping with
cipher_null (which just passes the data through), it ought to work
nonetheless, cipher_null is a valid crypto algorithm, after all.
cipher_null can be quite useful in test scenarios, where all the data
passes though the device mapper, but without being actually scrambled.
Comment 1 Alasdair Kergon 2004-11-09 12:21:17 EST
There's certainly something wrong because it issues a blank error message!

Nov  9 16:29:33 cn6 kernel: 
Nov  9 16:29:33 cn6 kernel: device-mapper: error adding target to table
Comment 2 Alasdair Kergon 2004-11-09 12:41:15 EST
You're supposed to use '-' instead of 0 in place of the key - but
there's a bug in an 'if' statement meaning it tries to decode it as a
hex key of zero length regardless, then fails because it's not zero
Comment 3 Ralf Ertzinger 2004-11-09 14:48:08 EST
Was this a bug in the kernel, or in dmsetup? If the latter, does the
same bug need fixing in cryptsetup?
Comment 4 Alasdair Kergon 2004-11-09 15:05:15 EST
Kernel bug.

After fixing it (below), the next problem (not fixed) is that it
derives the block size from the key length, so that's invalid too.

-       if ((key_size == 0 && strcmp(argv[1], "-") != 0)
-           || crypt_decode_key(cc->key, argv[1], key_size) < 0) {
+       if ((!key_size && strcmp(argv[1], "-") != 0) ||
+           (key_size && crypt_decode_key(cc->key, argv[1], key_size)
< 0)) {

If you want to pursue the second bug further, use the dm crypt mailing
list, dm-crypt@saout.de.

Comment 5 Alasdair Kergon 2004-11-10 08:38:12 EST
The block size isn't a problem with ecb:
  0 32768 crypt cipher_null-ecb - 0 /dev/loop0 0

Notice though that cipher_null doesn't do anything useful - I've no
idea why it's in the kernel.
Comment 6 Ralf Ertzinger 2004-11-10 08:45:17 EST
Testing purposes, try out the framework without modifying the data.
That's what I need it for (and why I noticed that it does not work :)
Comment 7 Ralf Ertzinger 2004-12-02 13:28:10 EST
Sorry to raise the issue again, this problem seems to persist in
2.6.9-1.1008_FC4 (with cipher_null-plain as well as with cipher_null-ecb)
Comment 8 Ralf Ertzinger 2004-12-20 06:39:31 EST
The issue is still present in 2.6.9-1.1047_FC4 (both -plain and -ecb),
marking as new again, and reassigning to kernel.
Comment 9 Alasdair Kergon 2004-12-21 11:17:49 EST
If you want to take this further and persuade people to change the
behaviour of cypher_null, please use the dm-crypt or linux-kernel
mailing lists.

Note You need to log in before you can comment on or make changes to this bug.