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:	Mon, 30 Jul 2007 10:39:38 +0530 (IST)
From:	Satyam Sharma <satyam@...radead.org>
To:	Rodolfo Giometti <giometti@...eenne.com>
cc:	Satyam Sharma <satyam.sharma@...il.com>,
	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

Hi Rodolfo,


On Sun, 29 Jul 2007, Rodolfo Giometti wrote:

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


Nopes, this isn't quite correct/safe. I suggest you should read:

http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/


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