[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 05/11] nbd: Reject unknown request flags
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v4 05/11] nbd: Reject unknown request flags |
Date: |
Wed, 11 May 2016 16:39:38 -0600 |
The NBD protocol says that clients should not send a command flag
that has not been negotiated (whether by the client requesting an
option during a handshake, or because we advertise support for the
flag in response to NBD_OPT_EXPORT_NAME), and that servers should
reject invalid flags with EINVAL. We were silently ignoring the
flags instead. The client can't rely on our behavior, since it is
their fault for passing the bad flag in the first place, but it's
better to be robust up front than to possibly behave differently
than the client was expecting with the attempted flag.
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Alex Bligh <address@hidden>
---
v3: reorder in series, defer check until after NBD_CMD_WRITE payload
is consumed
---
nbd/server.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/nbd/server.c b/nbd/server.c
index 9ac7e01..2ef2dfa 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1067,6 +1067,11 @@ static ssize_t nbd_co_receive_request(NBDRequest *req,
rc = -EINVAL;
goto out;
}
+ if (request->type & ~NBD_CMD_MASK_COMMAND & ~NBD_CMD_FLAG_FUA) {
+ LOG("unsupported flags (got 0x%x)",
+ request->type & ~NBD_CMD_MASK_COMMAND);
+ return -EINVAL;
+ }
rc = 0;
--
2.5.5
- [Qemu-devel] [PATCH v4 00/11] nbd: tighter protocol compliance, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 01/11] nbd: Use BDRV_REQ_FUA for better FUA where supported, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 10/11] nbd: Detect servers that send unexpected error values, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 11/11] nbd: Avoid magic number for NBD max name size, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 07/11] nbd: Clean up ioctl handling of qemu-nbd -c, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 06/11] nbd: Group all Linux-specific ioctl code in one place, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 02/11] nbd: More debug typo fixes, use correct formats, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 05/11] nbd: Reject unknown request flags,
Eric Blake <=
- [Qemu-devel] [PATCH v4 08/11] nbd: Limit nbdflags to 16 bits, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 09/11] nbd: Add qemu-nbd -D for human-readable description, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 03/11] nbd: Quit server after any write error, Eric Blake, 2016/05/11
- [Qemu-devel] [PATCH v4 04/11] nbd: Improve server handling of bogus commands, Eric Blake, 2016/05/11
- Re: [Qemu-devel] [PATCH v4 00/11] nbd: tighter protocol compliance, Alex Bligh, 2016/05/12