Fails to decrypt LUKS file on a samba server due to use of O_DIRECT flag
Issue 247 by DarkStarSw... on 2015-03-02 23:52:23:
<b>What steps will reproduce the problem?</b>
- Create a LUKS encrypted file on a samba server using an older version of cryptsetup
- Attempt to open the encrypted file using the current version of cryptsetup
<b>What is the expected output? What do you see instead?</b>
Expected:
$ sudo ./cryptsetup luksOpen /mnt/Media/photo-backup.img pbak --key-file pbak.key
$ ls /dev/mapper/
control pbak
What I see:
$ sudo cryptsetup luksOpen /mnt/Media/photo-backup.img pbak --key-file pbak.key
IO error while decrypting keyslot.
$ ls /dev/mapper/
control
<b>What version of the product are you using? On what operating system?</b>
cryptsetup 2:1.6.6-5 on Debian
Also confirmed on upstream commit 6b10f30e
<b>Please provide any additional information below.</b>
strace snippet:
open("/mnt/Media/photo-backup.img", O_RDONLY|O_SYNC|O_DIRECT) = 10
lseek(10, 135168, SEEK_SET) = 135168
fstatfs(10, {f_type=0xff534d42, f_bsize=4096, f_blocks=1453494282, f_bfree=602178550, f_bavail=528926691, f_files=183132160, f_ffree=181634697, f_fsid={0, 0}, f_namelen=4096, f_frsize=4096}) = 0
fstat(10, {st_mode=S_IFREG|0644, st_size=214748364800, ...}) = 0
read(10, 0x10d9000, 126976) = -1 EINVAL (Invalid argument)
Removing the O_DIRECT flag from device_open() solves the issue.