All of lore.kernel.org
 help / color / mirror / Atom feed
From: viro@ZenIV.linux.org.uk (Al Viro)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] Change the spin_lock/unlock_irq interface in proc_alloc_inum() function
Date: Wed, 2 Mar 2016 03:09:41 +0000	[thread overview]
Message-ID: <20160302030941.GH17997@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1456886879-28128-1-git-send-email-majun258@huawei.com>

On Wed, Mar 02, 2016 at 10:47:59AM +0800, MaJun wrote:
> From: Ma Jun <majun258@huawei.com>
> 
> The spin_lock/unlock_irq interface is not safe when this function is called
> at some case which need irq disabled.

> For example:
> 	spin_lock_irqsave()
> 	|
> 	request_irq() --> proc_alloc_inum()
> 	|
> 	spin_unlock_irqrestore()

Do you even read your own patch?

>  	if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL))
					 ^^^^^^^^^^
					 This.

It can block.  You *can't* call that under spin_lock_irqsave().  At all.
You also can't do request_irq() under a spinlock, no matter whether you
disable irqs or not - it also blocks.  So does proc_mkdir(), for that
matter, and not only in proc_alloc_inum().

NAKed.  Don't do it.  request_irq() is not to be called under spinlocks,
with or without irqs disabled.

WARNING: multiple messages have this Message-ID (diff)
From: Al Viro <viro@ZenIV.linux.org.uk>
To: MaJun <majun258@huawei.com>
Cc: ebiederm@xmission.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org,
	dhowells@redhat.com, Waiman.Long@hp.com, dingtianhong@huawei.com,
	guohanjun@huawei.com, fanjinke1@huawei.com
Subject: Re: [PATCH] Change the spin_lock/unlock_irq interface in proc_alloc_inum() function
Date: Wed, 2 Mar 2016 03:09:41 +0000	[thread overview]
Message-ID: <20160302030941.GH17997@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1456886879-28128-1-git-send-email-majun258@huawei.com>

On Wed, Mar 02, 2016 at 10:47:59AM +0800, MaJun wrote:
> From: Ma Jun <majun258@huawei.com>
> 
> The spin_lock/unlock_irq interface is not safe when this function is called
> at some case which need irq disabled.

> For example:
> 	spin_lock_irqsave()
> 	|
> 	request_irq() --> proc_alloc_inum()
> 	|
> 	spin_unlock_irqrestore()

Do you even read your own patch?

>  	if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL))
					 ^^^^^^^^^^
					 This.

It can block.  You *can't* call that under spin_lock_irqsave().  At all.
You also can't do request_irq() under a spinlock, no matter whether you
disable irqs or not - it also blocks.  So does proc_mkdir(), for that
matter, and not only in proc_alloc_inum().

NAKed.  Don't do it.  request_irq() is not to be called under spinlocks,
with or without irqs disabled.

  reply	other threads:[~2016-03-02  3:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02  2:47 [PATCH] Change the spin_lock/unlock_irq interface in proc_alloc_inum() function MaJun
2016-03-02  2:47 ` MaJun
2016-03-02  3:09 ` Al Viro [this message]
2016-03-02  3:09   ` Al Viro
2016-03-02  6:32   ` majun (F)
2016-03-02  6:32     ` majun (F)
2016-03-02 17:29     ` Al Viro
2016-03-02 17:29       ` Al Viro
2016-03-02 17:57       ` Al Viro
2016-03-02 17:57         ` Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160302030941.GH17997@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.