[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Update for forward-compatibility bug in nbd-client?



Hi,

Older versions of nbd-client (up to 3.10) contain a bug wherein they
incorrectly merge two flag fields before passing them to the kernel. The
bug has existed for a long time, but originally nobody cared since the
one flag field had just one flag that happened to merge onto a flag
that's always set to one in the other flags field.

In nbd 3.9, however, I added a second flag which is always set by the
server, and which mapped onto the "read-only" flag in the other flags
field. The result is that whenever you try to connect nbd-client <= 3.9
to nbd-server >= 3.9, all exports will be marked as read-only. Since
Jessie has 3.8 and Stretch already had 3.13, this will make
interoperation between Jessie and Stretch problematic for nbd.

I would like to apply the following one-line patch to jessie to remedy
this situation:

diff --git a/nbd-client.c b/nbd-client.c
index cc9a06e..ddc849c 100644
--- a/nbd-client.c
+++ b/nbd-client.c
@@ -318,7 +318,7 @@ void negotiate(int sock, u64 *rsize64, u32 *flags, char* name, uint32_t needed_f
        } else {
                if(read(sock, &tmp, sizeof(tmp)) < 0)
                        err("Failed/4: %m\n");
-               *flags |= (uint32_t)ntohs(tmp);
+               *flags = (uint32_t)ntohs(tmp);
        }

        if (read(sock, &buf, 124) < 0)

Does this seem like a reasonable thing to do for stable?

Note that this has no effect on Jessie-Jessie interaction (the other
flags field just doesn't contain any information that should be passed
to the kernel).

Thanks for your input,

-- 
< ron> I mean, the main *practical* problem with C++, is there's like a dozen
       people in the world who think they really understand all of its rules,
       and pretty much all of them are just lying to themselves too.
 -- #debian-devel, OFTC, 2016-02-12

Attachment: signature.asc
Description: PGP signature


Reply to: