lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130923103504.GG6192@mwanda>
Date:	Mon, 23 Sep 2013 13:35:04 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Dominik Paulus <dominik.paulus@....de>
Cc:	usbip-devel@...ts.sourceforge.net,
	Anthony Foiani <anthony.foiani@...il.com>,
	devel@...verdev.osuosl.org, linux-kernel@...cs.fau.de,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-usb@...r.kernel.org,
	Kurt Kanzenbach <ly80toro@....cs.fau.de>,
	Tobias Polzer <tobias.polzer@....de>,
	Harvey Yang <harvey.huawei.yang@...il.com>,
	linux-kernel@...r.kernel.org,
	Ilija Hadzic <ihadzic@...earch.bell-labs.com>,
	Bart Westgeest <bart@...rys.com>,
	Joe Perches <joe@...ches.com>,
	Jake Champlin <jake.champlin.27@...il.com>,
	Stefan Reif <ke42caxa@....cs.fau.de>,
	Bernard Blackham <b-linuxgit@...gestprime.net>
Subject: Re: [PATCH 5/7] staging: usbip: Add encryption support to kernel

On Thu, Sep 19, 2013 at 04:11:57PM +0200, Dominik Paulus wrote:
> +int usbip_init_crypto(struct usbip_device *ud, unsigned char *sendkey, unsigned
> +		char *recvkey)
> +{
> +	int ret;
> +
> +	ud->use_crypto = 1;
> +
> +	ud->tfm_recv = crypto_alloc_aead("gcm(aes)", 0, 0);
> +	if (IS_ERR(ud->tfm_recv))
> +		return -PTR_ERR(ud->tfm_recv);
> +	ud->tfm_send = crypto_alloc_aead("gcm(aes)", 0, 0);
> +	if (IS_ERR(ud->tfm_send)) {
> +		crypto_free_aead(ud->tfm_recv);
> +		return -PTR_ERR(ud->tfm_send);
> +	}
> +	ret = kfifo_alloc(&ud->recv_queue, RECVQ_SIZE, GFP_KERNEL);
> +	if (ret) {
> +		crypto_free_aead(ud->tfm_recv);
> +		crypto_free_aead(ud->tfm_send);
> +		return ret;
> +	}
> +
> +	if (crypto_aead_setkey(ud->tfm_send, sendkey, USBIP_KEYSIZE) != 0 ||
> +			crypto_aead_setkey(ud->tfm_recv, recvkey,
> +				USBIP_KEYSIZE) != 0 ||
> +			crypto_aead_setauthsize(ud->tfm_send,
> +				USBIP_AUTHSIZE) != 0 ||
> +			crypto_aead_setauthsize(ud->tfm_recv,
> +				USBIP_AUTHSIZE)) {
> +		crypto_free_aead(ud->tfm_recv);
> +		crypto_free_aead(ud->tfm_send);
> +		kfifo_free(&ud->recv_queue);
> +	}

This returns success on error instead of failure.

The indenting is messed up.  There are three places which check " != 0"
and doesn't.  Please leave off the "!= 0" throughout the whole patch.
It should look like:

	if (crypto_aead_setkey(ud->tfm_send, sendkey, USBIP_KEYSIZE) ||
	    crypto_aead_setkey(ud->tfm_recv, recvkey, USBIP_KEYSIZE) ||
	    crypto_aead_setauthsize(ud->tfm_send, USBIP_AUTHSIZE) ||
	    crypto_aead_setauthsize(ud->tfm_recv, USBIP_AUTHSIZE)) {
	    	ret = -EINVAL;
		goto err_free_fifo;
	}

Notice how the label name is chosen based on the label location and not
the goto location.

The end of the function should look like:

	return 0;

err_free_fifo:
	kfifo_free(&ud->recv_queue);
err_free_send:
	crypto_free_aead(ud->tfm_send);
err_free_recv:
	crypto_free_aead(ud->tfm_recv);

	return ret;

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ