Package: nbd-client
Version: 1:3.2-2
Severity: normal

after strating nbd-client, ioctl NBD_DO_IT randomly returned EPROTO, or
our cutom server exited because of an EOF condition.

the reason are bugs in nbd-client:

        if (read(sock, buf, 8) < 0)
        if (read(sock, &magic, sizeof(magic)) < 0)
        if (read(sock, &size64, sizeof(size64)) < 0)
        if (read(sock, flags, sizeof(*flags)) < 0)
        if (read(sock, &buf, 124) < 0)

all these reads in negotiate() would work with files, but not with
sockets, as sockets can (and do) legally return "whats there" and do not
wait for more data to arrive on partial reads.

in our case, due to slow network writes, one of these actually read less
data, most commonly the last one:

   [pid 13113] read(5, 
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 124) = 
108

since nbd-client does not properly read all the data, the remaining 16
bytes will errornously be read by the kernel, which then reacts correctly
with EPROTO.

the fix would be to replace all these read's with a function that properly
retries if less data was read, until either eof or an error is hit, or all
data has been read.

interestingly enough, the nbd-server contains a function "readit" for just
that reason, so the code is already there.

-- System Information:
Debian Release: 7.0
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'unstable'), (500, 'testing'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages nbd-client depends on:
ii  debconf [debconf-2.0]  1.5.49
ii  initscripts            2.88dsf-41
ii  libc6                  2.13-38

nbd-client recommends no packages.

nbd-client suggests no packages.

-- debconf information excluded


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to