mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 13:41:30 +00:00
audit: Send replies in the proper network namespace.
In perverse cases of file descriptor passing the current network namespace of a process and the network namespace of a socket used by that socket may differ. Therefore use the network namespace of the appropiate socket to ensure replies always go to the appropiate socket. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
parent
48095d991d
commit
6f285b19d0
3 changed files with 17 additions and 14 deletions
|
@ -570,9 +570,11 @@ static int audit_send_reply_thread(void *arg)
|
|||
* Allocates an skb, builds the netlink message, and sends it to the port id.
|
||||
* No failure notifications.
|
||||
*/
|
||||
static void audit_send_reply(__u32 portid, int seq, int type, int done,
|
||||
static void audit_send_reply(struct sk_buff *request_skb, int seq, int type, int done,
|
||||
int multi, const void *payload, int size)
|
||||
{
|
||||
u32 portid = NETLINK_CB(request_skb).portid;
|
||||
struct net *net = sock_net(NETLINK_CB(request_skb).sk);
|
||||
struct sk_buff *skb;
|
||||
struct task_struct *tsk;
|
||||
struct audit_reply *reply = kmalloc(sizeof(struct audit_reply),
|
||||
|
@ -585,7 +587,7 @@ static void audit_send_reply(__u32 portid, int seq, int type, int done,
|
|||
if (!skb)
|
||||
goto out;
|
||||
|
||||
reply->net = get_net(current->nsproxy->net_ns);
|
||||
reply->net = get_net(net);
|
||||
reply->portid = portid;
|
||||
reply->skb = skb;
|
||||
|
||||
|
@ -675,8 +677,7 @@ static int audit_get_feature(struct sk_buff *skb)
|
|||
|
||||
seq = nlmsg_hdr(skb)->nlmsg_seq;
|
||||
|
||||
audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
|
||||
&af, sizeof(af));
|
||||
audit_send_reply(skb, seq, AUDIT_GET, 0, 0, &af, sizeof(af));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -796,8 +797,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
s.backlog = skb_queue_len(&audit_skb_queue);
|
||||
s.version = AUDIT_VERSION_LATEST;
|
||||
s.backlog_wait_time = audit_backlog_wait_time;
|
||||
audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
|
||||
&s, sizeof(s));
|
||||
audit_send_reply(skb, seq, AUDIT_GET, 0, 0, &s, sizeof(s));
|
||||
break;
|
||||
}
|
||||
case AUDIT_SET: {
|
||||
|
@ -907,7 +907,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
seq, data, nlmsg_len(nlh));
|
||||
break;
|
||||
case AUDIT_LIST_RULES:
|
||||
err = audit_list_rules_send(NETLINK_CB(skb).portid, seq);
|
||||
err = audit_list_rules_send(skb, seq);
|
||||
break;
|
||||
case AUDIT_TRIM:
|
||||
audit_trim_trees();
|
||||
|
@ -972,8 +972,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
memcpy(sig_data->ctx, ctx, len);
|
||||
security_release_secctx(ctx, len);
|
||||
}
|
||||
audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_SIGNAL_INFO,
|
||||
0, 0, sig_data, sizeof(*sig_data) + len);
|
||||
audit_send_reply(skb, seq, AUDIT_SIGNAL_INFO, 0, 0,
|
||||
sig_data, sizeof(*sig_data) + len);
|
||||
kfree(sig_data);
|
||||
break;
|
||||
case AUDIT_TTY_GET: {
|
||||
|
@ -985,8 +985,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
s.log_passwd = tsk->signal->audit_tty_log_passwd;
|
||||
spin_unlock(&tsk->sighand->siglock);
|
||||
|
||||
audit_send_reply(NETLINK_CB(skb).portid, seq,
|
||||
AUDIT_TTY_GET, 0, 0, &s, sizeof(s));
|
||||
audit_send_reply(skb, seq, AUDIT_TTY_GET, 0, 0, &s, sizeof(s));
|
||||
break;
|
||||
}
|
||||
case AUDIT_TTY_SET: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue