[RAMEN9610-21968]ANDROID: xt_qtaguid: Remove tag_entry from process list on untag
authorKalesh Singh <kaleshsingh@google.com>
Mon, 11 Jan 2021 06:26:18 +0000 (01:26 -0500)
committerlingsen1 <lingsen1@lenovo.com>
Thu, 4 Mar 2021 06:19:46 +0000 (14:19 +0800)
commitf9ed75a969741f5b31add513917b3422fae69571
treef4cc5d75e948b73b7ed93b60d7849ac7bead97f0
parent8985bd8ae9c09b0d618c86081bb593ac18f9d463
[RAMEN9610-21968]ANDROID: xt_qtaguid: Remove tag_entry from process list on untag

A sock_tag_entry can only be part of one process's
pqd_entry->sock_tag_list. RetagGing the socket only updates
sock_tag_entry->tag, and does not add the tag entry to the current
process's pqd_entry list, nor update sock_tag_entry->pid.
So the sock_tag_entry is only ever present in the
pqd_entry list of the process that initially tagged the socket.

A sock_tag_entry can also get created and not be added to any process's
pqd_entry list. This happens if the process that initially tags the
socket has not opened /dev/xt_qtaguid.

ctrl_cmd_untag() supports untagGing from a context other than the
process that initially tagged the socket. Currently, the sock_tag_entry is
only removed from its containing pqd_entry->sock_tag_list if the
process that does the untagGing has opened /dev/xt_qtaguid. However, the
tag entry should always be deleted from its pqd entry list (if present).

Bug: 176919394
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: I5b6f0c36c0ebefd98cc6873a4057104c7d885ccc
(cherry picked from commit c2ab93b45b5cdc426868fb8793ada2cac20568ef)
net/netfilter/xt_qtaguid.c