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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20111028160115.bba2b8cf.akpm@linux-foundation.org>
Date:	Fri, 28 Oct 2011 16:01:15 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Tejun Heo <tj@...nel.org>
Cc:	linux-kernel@...r.kernel.org, rusty@...tcorp.com.au
Subject: Re: [PATCH] ida: make ida_simple_get/put() IRQ safe

On Wed, 26 Oct 2011 13:33:11 -0700
Tejun Heo <tj@...nel.org> wrote:

> It's often convenient to be able to release resource from IRQ context.
> Make ida_simple_*() use irqsave/restore spin ops so that they are IRQ
> safe.

The patch also accidentally makes ida_simple_get() callable from
interrupt context.  That's a somewhat unreliable operation due to
-ENOMEM possibilities even with GFP_ATOMIC.

> --- work.orig/lib/idr.c
> +++ work/lib/idr.c
> @@ -944,6 +944,7 @@ int ida_simple_get(struct ida *ida, unsi
>  {
>  	int ret, id;
>  	unsigned int max;
> +	unsigned long flags;
>  
>  	BUG_ON((int)start < 0);
>  	BUG_ON((int)end < 0);
> @@ -959,7 +960,7 @@ again:
>  	if (!ida_pre_get(ida, gfp_mask))
>  		return -ENOMEM;
>  
> -	spin_lock(&simple_ida_lock);
> +	spin_lock_irqsave(&simple_ida_lock, flags);
>  	ret = ida_get_new_above(ida, start, &id);
>  	if (!ret) {
>  		if (id > max) {
> @@ -969,7 +970,7 @@ again:
>  			ret = id;
>  		}
>  	}
> -	spin_unlock(&simple_ida_lock);
> +	spin_unlock_irqrestore(&simple_ida_lock, flags);
>  
>  	if (unlikely(ret == -EAGAIN))
>  		goto again;
> @@ -985,10 +986,12 @@ EXPORT_SYMBOL(ida_simple_get);
>   */
>  void ida_simple_remove(struct ida *ida, unsigned int id)
>  {
> +	unsigned long flags;
> +
>  	BUG_ON((int)id < 0);
> -	spin_lock(&simple_ida_lock);
> +	spin_lock_irqsave(&simple_ida_lock, flags);
>  	ida_remove(ida, id);
> -	spin_unlock(&simple_ida_lock);
> +	spin_unlock_irqrestore(&simple_ida_lock, flags);
>  }
>  EXPORT_SYMBOL(ida_simple_remove);

It didn't update the kerneldoc.  I wouldn't have bothered either ;)
We're generally bad about documenting permissible calling environments
and preconditions.

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