hashinfo->lhash_lock might be acquired by write_lock() in softirq,
so using read_lock() here isn't safe, just substitudes by read_lock_bh().
Signed-off-by: Gui Jianfeng <redacted>
---
include/net/inet_hashtables.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
hashinfo->lhash_lock might be acquired by write_lock() in softirq,
How?
so using read_lock() here isn't safe, just substitudes by read_lock_bh().
Signed-off-by: Gui Jianfeng <redacted>
I don't think this is necessary.
The only place the write lock is obtained, is via
the ->hash() and ->unhash() sk_prot operation methods.
And for listening sockets that only occurs in normal base
context. Never from softirqs.
If there is a patch from softirqs where this can occur,
that is a bug and must be fixed.
so using read_lock() here isn't safe, just substitudes by read_lock_bh().
Signed-off-by: Gui Jianfeng <redacted>
I don't think this is necessary.
The only place the write lock is obtained, is via
the ->hash() and ->unhash() sk_prot operation methods.
And for listening sockets that only occurs in normal base
context. Never from softirqs.
If there is a patch from softirqs where this can occur,
that is a bug and must be fixed.
You're not answering my question.
I'll ask my question one more time.
How can this happen for a LISTENING SOCKET? Ie. with
sk_state == TCP_LISTEN.
Only listening sockets go into inet_listen_wlock().
This DCCP call trace you're showing sets the sk_state to DCCP_PARTOPEN
right before that ->rebuild_header() call. (DCCP_PARTOPEN is defined
to be equal to TCP_MAX_STATES in include/linux/dccp.h)
So this call chain is absolutely impossible.
We specifically forbid listening sockets from calling hash or unhash
in BH context. And this is exactly what makes the locking legal.
You had to have a reason for writing this patch. You saw something,
either a deadlock or a lockdep trace. My theory is that you saw
lockdep triggered erroneously because it can't see what prevents BH
contexts from invoking inet_listen_wlock().
Or did you just write this patch in response to pure code reading?
You're not answering my question.
I'll ask my question one more time.
How can this happen for a LISTENING SOCKET? Ie. with
sk_state == TCP_LISTEN.
Only listening sockets go into inet_listen_wlock().
This DCCP call trace you're showing sets the sk_state to DCCP_PARTOPEN
right before that ->rebuild_header() call. (DCCP_PARTOPEN is defined
to be equal to TCP_MAX_STATES in include/linux/dccp.h)
So this call chain is absolutely impossible.
We specifically forbid listening sockets from calling hash or unhash
in BH context. And this is exactly what makes the locking legal.
You had to have a reason for writing this patch. You saw something,
either a deadlock or a lockdep trace. My theory is that you saw
lockdep triggered erroneously because it can't see what prevents BH
contexts from invoking inet_listen_wlock().
Or did you just write this patch in response to pure code reading?
I think you are right. I read the code, and thought it might have
deadlock problem. I'm very sorry for my mistake.
Please ignore this patch.