“befe9b6fd897e1bfce224b662ce62dd751843c34”上不存在“drivers/net/wireless/intel/iwlwifi/dvm/ucode.c”
提交 f6740a11 编写于 作者: L Lu Wei 提交者: Zheng Zengkai

net: core: Add a GID field to struct sock.

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I545NW
CVE: NA

--------------------------------

UID and GID are requested as filters for socketmap, but we can only get
UID from sock structure. This patch adds GID field to struct sock as UID.
Signed-off-by: NLu Wei <luwei32@huawei.com>
Signed-off-by: NLiu Jian <liujian56@huawei.com>
Reviewed-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 bf0f3171
......@@ -303,6 +303,7 @@ struct bpf_local_storage;
* @sk_ack_backlog: current listen backlog
* @sk_max_ack_backlog: listen backlog set in listen()
* @sk_uid: user id of owner
* @sk_gid: group id of owner
* @sk_priority: %SO_PRIORITY setting
* @sk_type: socket type (%SOCK_STREAM, etc)
* @sk_protocol: which protocol this socket belongs in this network family
......@@ -527,7 +528,14 @@ struct sock {
#endif
struct rcu_head sk_rcu;
#ifndef __GENKSYMS__
union {
kgid_t sk_gid;
u64 sk_gid_padding;
};
#else
KABI_RESERVE(1)
#endif
KABI_RESERVE(2)
KABI_RESERVE(3)
KABI_RESERVE(4)
......@@ -1904,6 +1912,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent)
parent->sk = sk;
sk_set_socket(sk, parent);
sk->sk_uid = SOCK_INODE(parent)->i_uid;
sk->sk_gid = SOCK_INODE(parent)->i_gid;
security_sock_graft(sk, parent);
write_unlock_bh(&sk->sk_callback_lock);
}
......@@ -1916,6 +1925,11 @@ static inline kuid_t sock_net_uid(const struct net *net, const struct sock *sk)
return sk ? sk->sk_uid : make_kuid(net->user_ns, 0);
}
static inline kgid_t sock_net_gid(const struct net *net, const struct sock *sk)
{
return sk ? sk->sk_gid : make_kgid(net->user_ns, 0);
}
static inline u32 net_tx_rndhash(void)
{
u32 v = prandom_u32();
......
......@@ -2985,9 +2985,11 @@ void sock_init_data(struct socket *sock, struct sock *sk)
RCU_INIT_POINTER(sk->sk_wq, &sock->wq);
sock->sk = sk;
sk->sk_uid = SOCK_INODE(sock)->i_uid;
sk->sk_gid = SOCK_INODE(sock)->i_gid;
} else {
RCU_INIT_POINTER(sk->sk_wq, NULL);
sk->sk_uid = make_kuid(sock_net(sk)->user_ns, 0);
sk->sk_gid = make_kgid(sock_net(sk)->user_ns, 0);
}
rwlock_init(&sk->sk_callback_lock);
......
......@@ -543,11 +543,13 @@ static int sockfs_setattr(struct dentry *dentry, struct iattr *iattr)
if (!err && (iattr->ia_valid & ATTR_UID)) {
struct socket *sock = SOCKET_I(d_inode(dentry));
if (sock->sk)
if (sock->sk) {
sock->sk->sk_uid = iattr->ia_uid;
else
sock->sk->sk_gid = iattr->ia_gid;
} else {
err = -ENOENT;
}
}
return err;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册