From: Rodolfo Giometti Date: Wed, 11 Nov 2009 22:26:52 +0000 (-0800) Subject: pps: locking scheme fix up for PPS_GETPARAMS X-Git-Tag: v2.6.31.7~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=073493a20768a109ed1e6e744a2fe88e8bbd2fab;p=thirdparty%2Fkernel%2Fstable.git pps: locking scheme fix up for PPS_GETPARAMS commit cbf83cc5a29dba480cf1ba1c5e3417a0d4a31410 upstream. Userland programs may read/write PPS parameters at same time and these operations may corrupt PPS data. Signed-off-by: Rodolfo Giometti Tested-by: Reg Clemens Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c index fea17e7805e9d..ca5183bdad85f 100644 --- a/drivers/pps/pps.c +++ b/drivers/pps/pps.c @@ -71,9 +71,14 @@ static long pps_cdev_ioctl(struct file *file, 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)); + spin_lock_irq(&pps->lock); + + /* Get the current parameters */ + params = pps->params; + + spin_unlock_irq(&pps->lock); + + err = copy_to_user(uarg, ¶ms, sizeof(struct pps_kparams)); if (err) return -EFAULT;