Files
twx-linux/include/net
Lorenzo Colitti 86741ec254 net: core: Add a UID field to struct sock.
Protocol sockets (struct sock) don't have UIDs, but most of the
time, they map 1:1 to userspace sockets (struct socket) which do.

Various operations such as the iptables xt_owner match need
access to the "UID of a socket", and do so by following the
backpointer to the struct socket. This involves taking
sk_callback_lock and doesn't work when there is no socket
because userspace has already called close().

Simplify this by adding a sk_uid field to struct sock whose value
matches the UID of the corresponding struct socket. The semantics
are as follows:

1. Whenever sk_socket is non-null: sk_uid is the same as the UID
   in sk_socket, i.e., matches the return value of sock_i_uid.
   Specifically, the UID is set when userspace calls socket(),
   fchown(), or accept().
2. When sk_socket is NULL, sk_uid is defined as follows:
   - For a socket that no longer has a sk_socket because
     userspace has called close(): the previous UID.
   - For a cloned socket (e.g., an incoming connection that is
     established but on which userspace has not yet called
     accept): the UID of the socket it was cloned from.
   - For a socket that has never had an sk_socket: UID 0 inside
     the user namespace corresponding to the network namespace
     the socket belongs to.

Kernel sockets created by sock_create_kern are a special case
of #1 and sk_uid is the user that created them. For kernel
sockets created at network namespace creation time, such as the
per-processor ICMP and TCP sockets, this is the user that created
the network namespace.

Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-11-04 14:45:22 -04:00
..
…
…
…
…
…
…
…
…
…
…
…
2016-09-27 21:15:21 -04:00
…
…
…
…
2016-08-26 11:55:18 -07:00
…
…
…
…
2016-09-23 08:38:50 -04:00
…
…
…
…
…
…
…
…
…
…
…
…
2016-10-14 10:59:15 -04:00
…
2016-11-03 15:41:11 -04:00
…
2016-10-26 17:33:22 -04:00
…
…
…
2016-08-17 19:36:23 -04:00
…
…
…
…
…
2016-10-23 17:45:01 -04:00
…
…
2016-10-03 02:00:22 -04:00
…
2016-10-04 02:11:51 -04:00
…
…
…
…
…
…
…
…
2016-09-10 23:12:53 -07:00
…
…
…
…
…
…
…
2016-10-29 20:56:31 -04:00
…
…
…