* [PATCH v2] ptrace: annotate siglock acquisition
@ 2010-09-25 11:53 Namhyung Kim
2010-09-26 17:51 ` Oleg Nesterov
0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2010-09-25 11:53 UTC (permalink / raw)
To: Roland McGrath, Oleg Nesterov; +Cc: linux-kernel
lock_task_sighand() conditionally acquires sighand->siglock in case of
returning non-NULL but unlock_task_sighand() releases it unconditionally.
This leads sparse to complain about the lock context imbalance. Annotate it
to make sparse happier.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
Roland, I sent the same patch a month ago and got your Acked-by but this
time I update it using __cond_lock() suggested by Al Viro. Please take a
look again, Thanks.
kernel/ptrace.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index f34d798..8d9b7b2 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -435,7 +435,8 @@ static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info)
unsigned long flags;
int error = -ESRCH;
- if (lock_task_sighand(child, &flags)) {
+ if (__cond_lock(&child->sighand->siglock,
+ lock_task_sighand(child, &flags))) {
error = -EINVAL;
if (likely(child->last_siginfo != NULL)) {
*info = *child->last_siginfo;
@@ -451,7 +452,8 @@ static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info)
unsigned long flags;
int error = -ESRCH;
- if (lock_task_sighand(child, &flags)) {
+ if (__cond_lock(&child->sighand->siglock,
+ lock_task_sighand(child, &flags))) {
error = -EINVAL;
if (likely(child->last_siginfo != NULL)) {
*child->last_siginfo = *info;
--
1.7.2.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] ptrace: annotate siglock acquisition
2010-09-25 11:53 [PATCH v2] ptrace: annotate siglock acquisition Namhyung Kim
@ 2010-09-26 17:51 ` Oleg Nesterov
0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2010-09-26 17:51 UTC (permalink / raw)
To: Namhyung Kim; +Cc: Roland McGrath, linux-kernel
On 09/25, Namhyung Kim wrote:
>
> --- a/kernel/ptrace.c
> +++ b/kernel/ptrace.c
> @@ -435,7 +435,8 @@ static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info)
> unsigned long flags;
> int error = -ESRCH;
>
> - if (lock_task_sighand(child, &flags)) {
> + if (__cond_lock(&child->sighand->siglock,
> + lock_task_sighand(child, &flags))) {
Well, this looks fine, but if we are going to make sparse happy
then we have more callers to fix.
Perhaps we should just renam lock_task_sighand to __lock_task_sighand
and add
#define lock_task_sighand(tsk, flagsp) \
__cond_lock((tsk)->sighand->siglock, __lock_task_sighand((tsk), (flagsp)))
?
Oleg.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-26 17:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-25 11:53 [PATCH v2] ptrace: annotate siglock acquisition Namhyung Kim
2010-09-26 17:51 ` Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).