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] [day] [month] [year] [list]
Message-ID: <20090203091434.GB1091@infradead.org>
Date:	Tue, 3 Feb 2009 04:14:34 -0500
From:	Christoph Hellwig <hch@...radead.org>
To:	Rodolfo Giometti <giometti@...ux.it>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	David Woodhouse <dwmw2@...radead.org>,
	Dave Jones <davej@...hat.com>, Sam Ravnborg <sam@...nborg.org>,
	Greg KH <greg@...ah.com>,
	Randy Dunlap <randy.dunlap@...cle.com>,
	Kay Sievers <kay.sievers@...y.org>,
	Alan Cox <alan@...rguk.ukuu.org.uk>,
	"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...e.hu>,
	Michael Kerrisk <mtk.manpages@...il.com>,
	Christoph Hellwig <hch@...radead.org>
Subject: Re: [PATCH 1/1] LinuxPPS core support.

> +static long pps_cdev_ioctl(struct file *file,
> +		unsigned int cmd, unsigned long arg)
> +{
> +	struct pps_device *pps = file->private_data;
> +	struct pps_kparams params;
> +	struct pps_fdata fdata;
> +	unsigned long ticks;
> +	void __user *uarg = (void __user *) arg;
> +	int __user *iuarg = (int __user *) arg;
> +	int err;
> +
> +	switch (cmd) {
> +	case PPS_CHECK:
> +
> +		/* This does nothing but signal we are a PPS source... */
> +
> +		return 0;

I think this one is superflous.  Just doing a PPS_GETPARAMS: should get
your the same information..

> +	case PPS_GETPARAMS:
> +		pr_debug("PPS_GETPARAMS: source %d\n", pps->id);
> +
> +		/* Return current parameters */
> +		err = copy_to_user(uarg, &pps->params,
> +						sizeof(struct pps_kparams));
> +		if (err)
> +			return -EFAULT;
> +
> +		break;
> +
> +	case PPS_SETPARAMS:
> +		pr_debug("PPS_SETPARAMS: source %d\n", pps->id);
> +
> +		/* Check the capabilities */
> +		if (!capable(CAP_SYS_TIME))
> +			return -EPERM;
> +
> +		err = copy_from_user(&params, uarg, sizeof(struct pps_kparams));
> +		if (err)
> +			return -EFAULT;
> +		if (!(params.mode & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR))) {
> +			pr_debug("capture mode unspecified (%x)\n",
> +								params.mode);
> +			return -EINVAL;
> +		}

Note that splitting out any non-trivial ioctl into it's own small helper
function gives generally much cleaner code.

> +	if (pps_devt)
> +		unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES);

Given that you have proper error handling in pps_init this can't
ever be zero.

> +
> +	pr_info("LinuxPPS API ver. %d removed\n", PPS_API_VERS);

Printing stuff on exit is rather noisy and should be avoided

--
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