therealromster / cryptsetup

Automatically exported from code.google.com/p/cryptsetup
GNU General Public License v2.0
0 stars 0 forks source link

re-encrypt doesn't handle EINTR #226

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Forwarding a minor issue in reencrytion support reported by Stephan
Mueller:

---->8----
copy_data_forward contains:

                s1 = read(fd_old, buf, block_size);
                if (s1 < 0 || ((size_t)s1 != block_size &&
                    (rc->device_offset + s1) != rc->device_size)) {
                        log_dbg("Read error, expecting %d, got %d.",
                                (int)block_size, (int)s1);
                        return -EIO;
                }

IMHO the unconditional failure is not always correct, because the code 
does not check for EINTR and ERESTARTSYS. When you get an 
EINTR/ERESTARTSYS, the code needs to re-setup the read.

The same applies to copy_data_backward.
---->8----

Original issue reported on code.google.com by ludwig.n...@suse.de on 15 Sep 2014 at 10:06

GoogleCodeExporter commented 9 years ago
Yes, I had already note to fix this as it was reported already (and probably 
handle also partial reads).

Just need to re-shift priorities of my work somehow...

For now, it is happen, just restart reencryption, it should continue without 
any data loss.

Thanks.

Original comment by gmazyl...@gmail.com on 15 Sep 2014 at 12:02

GoogleCodeExporter commented 9 years ago
Fixed in
https://code.google.com/p/cryptsetup/source/detail?r=f16f37233f87fb2758c9a2181fd
e4d97b93a418a#

The ERESTARTSYS should never appear in userspace, it should be replaced by 
EINTR if syscall cannot be restarted, so we do not need to handle it here.

Thanks!

Original comment by gmazyl...@gmail.com on 4 Oct 2014 at 1:42