mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dominik Paulus <dominik.paulus@fau.de>
To: Max Vozeler <max@hinterhof.net>
Cc: Maximilian Eschenbacher <maximilian@eschenbacher.email>,
	linux-kernel@vger.kernel.org, valentina.manea.m@gmail.com,
	shuah.kh@samsung.com, gregkh@linuxfoundation.org,
	Dominik Paulus <dominik.paulus@fau.de>,
	Fjodor Schelichow <fjodor.schelichow@hotmail.com>,
	Johannes Stadlinger <johannes.stadlinger@fau.de>,
	Tobias Polzer <tobias.polzer@fau.de>
Subject: Re: [PATCH 02/18] usbip: Add support for client authentication
Date: Sun, 21 Sep 2014 14:43:41 +0200	[thread overview]
Message-ID: <20140921124340.GB2097@d-paulus.de> (raw)
In-Reply-To: <20140921004259.GA23120@x201t.vpn.hinterhof.net>

Hi,

thanks for your feedback!

On Sun, Sep 21, 2014 at 02:42:59AM +0200, Max Vozeler wrote:
> > +	if (strcmp(username, "dummyuser"))
> > +		/* User invalid, stored dummy data in g and n. */
> > +		return 1;
> 
> Could you describe the role of "dummyuser" in a comment? It seems to be
> a placeholder for GnuTLS SRP requiring a username.

It is, SRP is designed for username/password authentication, but we only
do password.

> 
> > +	return 0;
> > +}
> > +
> > +int usbip_net_init_gnutls(void)
> > +{
> > +	int ret;
> > +
> > +	gnutls_global_init();
> > +
> > +	usbip_net_srp_salt.data = gnutls_malloc(16);
> 
> This should be freed somewhere.

Actually, it is used for the whole lifetime of the process.

> > +	/*
> > +	 * Process opcodes. We might receive more than one, as the
> > +	 * client might send STARTTLS first
> > +	 */
> > +	while (cont) {
> > +		uint16_t code = OP_UNSPEC;
> >  
> > -	if (ret == 0)
> > -		info("request %#0x(%d): complete", code, connfd);
> > -	else
> > -		info("request %#0x(%d): failed", code, connfd);
> > +		ret = usbip_net_recv_op_common(connfd, &code);
> > +		if (ret < 0) {
> > +			dbg("could not receive opcode: %#0x", code);
> > +			return -1;
> > +		}
> > +
> > +		info("received request: %#0x(%d)", code, connfd);
> > +
> > +		/* We require an authenticated encryption */
> > +		if (!auth && code != OP_REQ_STARTTLS) {
> > +			usbip_net_send_op_common(connfd, OP_REPLY, ST_NA);
> > +			return -1;
> > +		}
> > +
> > +		switch (code) {
> > +#ifdef HAVE_GNUTLS
> > +		case OP_REQ_STARTTLS:
> > +			if (!need_auth) {
> > +				ret = -1;
> > +				err("Unexpected TLS handshake attempt (client uses password, server doesn't)");
> > +			} else {
> > +				ret = net_srp_server_handshake(connfd);
> > +				if (ret != 0)
> > +					err("TLS handshake failed");
> > +				auth = 1;
> 
> This marks the connection as authenticated even if the handshake has
> failed, which doesn't seem right.
> 
> The err() used here is a macro that merely logs the error and moves
> on. It does not exit() like the err.h err() functions.
> 
> So this should probably be
> 
> > +				if (ret != 0)
> > +					err("TLS handshake failed");
> 				else
> > +					auth = 1;
> 
> instead?

It might be even better to just drop the connection after a failed
handshake, as existing clients aren't going to do more than one
authentication attempt, anyway.

Note that - after patch 11/18 has been applied, too -
net_srp_server_handshake() sets the "have_crypto" flag on the connection
handle, thus, all subsequent network operations are going to fail
anyway, as no TLS session has been established. Thus, the incorrectly
set "auth" flag doesn't have any security implications here.

Regards,
Dominik

  reply	other threads:[~2014-09-21 12:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16 23:38 [PATCH 00/18] usbip: Crypto and ACLs Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 01/18] usbip: sysfs_utils: add read_sysfs_attribute Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 02/18] usbip: Add support for client authentication Maximilian Eschenbacher
2014-09-21  0:42   ` Max Vozeler
2014-09-21 12:43     ` Dominik Paulus [this message]
2014-10-03 14:16   ` Valentina Manea
2014-09-16 23:38 ` [PATCH 03/18] usbip: Add kernel support for client ACLs Maximilian Eschenbacher
2014-09-21  0:44   ` Max Vozeler
2014-09-21 12:42     ` Dominik Paulus
2014-09-16 23:38 ` [PATCH 04/18] usbip: Add CIDR matching helper functions Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 05/18] usbip: Add ACL support to usbip bind Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 06/18] usbip: Add support for ACLs in usbipd Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 07/18] usbip: Add proper error reporting Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 08/18] usbip: Handle usbip being started as user Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 09/18] usbip: Improve debug output Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 10/18] usbip: Separate protocol/program version Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 11/18] usbip: TLS for all userspace communication Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 12/18] usbip: Exchange session keys in userspace Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 13/18] usbip: Pass session keys to the kernel Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 14/18] usbip: Wrap kernel_sendmsg()/recvmsg() Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 15/18] usbip: Add encryption support to kernel Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 16/18] usbip: Update documentation Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 17/18] usbip: Increment version number to 1.2.1 Maximilian Eschenbacher
2014-09-17 17:51   ` Denys Vlasenko
2014-09-18 15:31     ` Fjodor Schelichow
2014-09-16 23:38 ` [PATCH 18/18] usbip: list.h include stddef.h for offsetof Maximilian Eschenbacher
2014-09-26 11:56 ` [PATCH 00/18] usbip: Crypto and ACLs Valentina Manea
2014-11-07 17:49   ` Greg KH
2014-11-09 21:10     ` Valentina Manea
2014-11-09 23:33       ` Greg KH
2014-11-11 17:52       ` Maximilian Eschenbacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140921124340.GB2097@d-paulus.de \
    --to=dominik.paulus@fau.de \
    --cc=fjodor.schelichow@hotmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes.stadlinger@fau.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=max@hinterhof.net \
    --cc=maximilian@eschenbacher.email \
    --cc=shuah.kh@samsung.com \
    --cc=tobias.polzer@fau.de \
    --cc=valentina.manea.m@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®