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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1266335876.8849.11.camel@localhost.localdomain>
Date:	Tue, 16 Feb 2010 07:57:56 -0800
From:	Marcel Holtmann <marcel@...tmann.org>
To:	sjur.brandeland@...ricsson.com
Cc:	davem@...emloft.net, netdev@...r.kernel.org,
	stefano.babic@...ic.homelinux.org, randy.dunlap@...cle.com,
	daniel.martensson@...ricsson.com, kaber@...sh.net
Subject: Re: [PATCH net-next-2.6 v2 08/12] net-caif: add CAIF socket
 implementation

Hi Sjur,

> +static int setsockopt(struct socket *sock,
> +			int lvl, int opt, char __user *ov, unsigned int ol)
> +{
> +	struct sock *sk = sock->sk;
> +	struct caifsock *cf_sk = container_of(sk, struct caifsock, sk);
> +	int prio, linksel;
> +	struct ifreq ifreq;
> +	struct caif_param caif_param;
> +	if (lvl != SOL_CAIF) {
> +		pr_debug("CAIF: %s(): setsockopt bad level\n", __func__);
> +		return -ENOPROTOOPT;
> +	}
> +	if (STATE_IS_OPEN(cf_sk)) {
> +		pr_debug("CAIF: %s(): setsockopt "
> +			 "cannot be done on a connected socket\n",
> +			 __func__);
> +		return -ENOPROTOOPT;
> +	}
> +	switch (opt) {
> +	case CAIFSO_LINK_SELECT:
> +		if (ol < sizeof(int)) {
> +			pr_debug("CAIF: %s(): setsockopt"
> +				 " CAIFSO_CHANNEL_CONFIG bad size\n", __func__);
> +			return -EINVAL;
> +		}
> +		if (copy_from_user(&linksel, ov, sizeof(int)))
> +			return -EINVAL;
> +		lock_sock(&(cf_sk->sk));
> +		cf_sk->config.phy_pref = linksel;
> +		pr_debug("CAIF: %s(): Setting sockopt pref=%dn", __func__,
> +			cf_sk->config.phy_pref);
> +		release_sock(&cf_sk->sk);
> +		return 0;
> +
> +	case SO_PRIORITY:
> +		if (ol < sizeof(int)) {
> +			pr_debug("CAIF: %s(): setsockopt"
> +				 " SO_PRIORITY bad size\n", __func__);
> +			return -EINVAL;
> +		}
> +		if (copy_from_user(&prio, ov, sizeof(int)))
> +			return -EINVAL;
> +		lock_sock(&(cf_sk->sk));
> +		cf_sk->config.phy_pref = prio;
> +		pr_debug("CAIF: %s(): Setting sockopt pref=%dn", __func__,
> +			cf_sk->config.phy_pref);
> +		release_sock(&cf_sk->sk);
> +		return 0;
> +
> +	case SO_BINDTODEVICE:
> +		if (ol < sizeof(struct ifreq)) {
> +			pr_debug("CAIF: %s(): setsockopt"
> +				 " SO_PRIORITY bad size\n", __func__);
> +			return -EINVAL;
> +		}
> +		if (copy_from_user(&ifreq, ov, sizeof(ifreq)))
> +			return -EFAULT;
> +		lock_sock(&(cf_sk->sk));
> +		strncpy(cf_sk->config.phy_name, ifreq.ifr_name,
> +			sizeof(cf_sk->config.phy_name));
> +		cf_sk->config.phy_name[sizeof(cf_sk->config.phy_name)-1] = 0;
> +
> +		release_sock(&cf_sk->sk);
> +		return 0;

I would have implemented SO_PRIORITY and SO_BINDTODEVICE on SOL_SOCKET
level. Having them on SOL_CAIF level is not really useful.

Regards

Marcel


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ