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]
Date:	Sun, 29 Jul 2007 12:00:07 +0200
From:	Rodolfo Giometti <giometti@...eenne.com>
To:	Satyam Sharma <satyam.sharma@...il.com>
Cc:	Chris Friesen <cfriesen@...tel.com>,
	David Woodhouse <dwmw2@...radead.org>,
	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: LinuxPPS & spinlocks

On Sat, Jul 28, 2007 at 05:11:17AM +0530, Satyam Sharma wrote:

> Take the race between the time_pps_setparams() syscall and a concurrent
> pps_event() from an interrupt for instance. From sys_time_pps_setparams,
> the parameters for an existing source are not modified / set atomically,
> which means a pps_event() called on the same source in between will see
> invalid parameters ... and bad things will happen.

I think this should be a good solution... :)

diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c
index 08de71d..f0c42ec 100644
--- a/drivers/pps/kapi.c
+++ b/drivers/pps/kapi.c
@@ -29,12 +29,6 @@
 #include <linux/pps.h>
 
 /*
- * Local variables
- */
-
-static spinlock_t pps_lock = SPIN_LOCK_UNLOCKED;
-
-/*
  * Local functions
  */
 
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index 9176c01..91b7e4d 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -35,6 +35,7 @@
 
 struct pps_s pps_source[PPS_MAX_SOURCES];
 DEFINE_MUTEX(pps_mutex);
+spinlock_t pps_lock = SPIN_LOCK_UNLOCKED;
 
 /*
  * Misc functions
@@ -227,6 +228,8 @@ asmlinkage long sys_time_pps_setparams(int source,
                goto sys_time_pps_setparams_exit;
        }
 
+       spin_lock(&pps_lock);
+
        /* Save the new parameters */
        ret = copy_from_user(&pps_source[source].params, params,
                                                sizeof(struct pps_kparams));
@@ -245,6 +248,8 @@ asmlinkage long sys_time_pps_setparams(int source,
                pps_source[source].params.mode |= PPS_CANWAIT;
        pps_source[source].params.api_version = PPS_API_VERS;
 
+       spin_unlock(&pps_lock);
+
 sys_time_pps_setparams_exit:
        mutex_unlock(&pps_mutex);
 
diff --git a/include/linux/pps.h b/include/linux/pps.h
index 6eca3ea..93e7384 100644
--- a/include/linux/pps.h
+++ b/include/linux/pps.h
@@ -174,6 +174,7 @@ struct pps_s {
 
 extern struct pps_s pps_source[PPS_MAX_SOURCES];
 extern struct mutex pps_mutex;
+extern spinlock_t pps_lock;
 
 /*
  * Global functions

Ciao,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail:    giometti@...eenne.com
Linux Device Driver                             giometti@...dd.com
Embedded Systems                     		giometti@...ux.it
UNIX programming                     phone:     +39 349 2432127
-
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