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

[Nbd] [PATCH/RFC 0/3] Introduce TLS on nbdserver



This is an RFC patch to introduce TLS support on nbdserver.

This is *NOT* production ready by any means, and is submitted for comment.

I have added crypto-gnutls.[ch] from:
  github.com/abligh/tlsproxy
which is my attempt at an MIT licenced GnuTLS proxy. The proxy element
is standalone, and is incorporated here. Whilst it's not GPL licensed,
MIT is compatible. Also it uses GNU format indentation (sorry about that).
However, it (together with buffer.[ch]) is almost entirely self-contained.

The same approach (believe it or not) could be taken for nbdclient (which
is my plan). As the proxy runs as an independent process, nbdclient can
launch it, then call the DOIT ioctl() on one end of the created socketpair().
The proxy process then drops into the background and closes after
either the kernel closes the socket or the other end closes the socket.

I have tested this to a minimal extent against qemu-img (i.e. qemu
acting as a client). The problem (see nbdgeneral ad nauseam) we have
with NBD_CMD_DISC means that we see false reports of 'magic number mismatch'.
This appears to be because read() returns 0 in negotiate(), and nbdserver
does not check for this. It then reverses (again) the *previous* magic
number, using ntohll(), and this causes the 'magic number mismatch' issue.
This isn't really a problem but causes confusing errors.

The first two patches are preparatory work, and the third patch actually
adds NBD_OPT_STARTTLS. The comment in that patch shows what is left to
figure out.

Alex Bligh (3):
  Add GnuTLS infrastructure
  Add options for TLS support for server
  Add TLS support to server

 Makefile.am              |   4 +-
 buffer.c                 | 225 +++++++++++++++++
 buffer.h                 |  45 ++++
 cliserv.h                |   1 +
 configure.ac             |  11 +
 crypto-gnutls.c          | 615 +++++++++++++++++++++++++++++++++++++++++++++++
 crypto-gnutls.h          |  43 ++++
 man/nbd-server.5.in.sgml |  65 +++++
 nbd-server.c             | 204 +++++++++++++---
 nbdsrv.h                 |   1 +
 10 files changed, 1185 insertions(+), 29 deletions(-)
 create mode 100644 buffer.c
 create mode 100644 buffer.h
 create mode 100644 crypto-gnutls.c
 create mode 100644 crypto-gnutls.h

-- 
1.9.1




Reply to: