Skip to content

Commit

Permalink
mqueue: fix si_pid value in mqueue do_notify()
Browse files Browse the repository at this point in the history
If a process registers for asynchronous notification on a POSIX message
queue, it gets a signal and a siginfo_t structure when a message arrives
on the message queue.  The si_pid in the siginfo_t structure is set to the
PID of the process that sent the message to the message queue.

The principle is the following:
. when mq_notify(SIGEV_SIGNAL) is called, the caller registers for
  notification when a msg arrives. The associated pid structure is stroed into
  inode_info->notify_owner. Let's call this process P1.
. when mq_send() is called by say P2, P2 sends a signal to P1 to notify
  him about msg arrival.

The way .si_pid is set today is not correct, since it doesn't take into account
the fact that the process that is sending the message might not be in the
same namespace as the notified one.

This patch proposes to set si_pid to the sender's pid into the notify_owner
namespace.

Signed-off-by: Nadia Derbey <[email protected]>
Signed-off-by: Sukadev Bhattiprolu <[email protected]>
Acked-by: Oleg Nesterov <[email protected]>
Cc: Roland McGrath <[email protected]>
Cc: Bastian Blank <[email protected]>
Cc: Pavel Emelyanov <[email protected]>
Cc: Eric W. Biederman <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Sukadev Bhattiprolu authored and torvalds committed Jan 8, 2009
1 parent 61bce0f commit a668499
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ static void __do_notify(struct mqueue_inode_info *info)
sig_i.si_errno = 0;
sig_i.si_code = SI_MESGQ;
sig_i.si_value = info->notify.sigev_value;
sig_i.si_pid = task_tgid_vnr(current);
sig_i.si_pid = task_tgid_nr_ns(current,
ns_of_pid(info->notify_owner));
sig_i.si_uid = current_uid();

kill_pid_info(info->notify.sigev_signo,
Expand Down

0 comments on commit a668499

Please sign in to comment.