Commit e04fd238 authored by Zhengchao Shao's avatar Zhengchao Shao
Browse files

genetlink: fix kabi change in struct genl_multicast_group

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9K8D1



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

Fix kabi change in struct genl_multicast_group.

Fixes: 015870c10c45 ("genetlink: add CAP_NET_ADMIN test for multicast bind")
Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
parent 3d0d9df7
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -9,19 +9,12 @@

#define GENLMSG_DEFAULT_SIZE (NLMSG_DEFAULT_SIZE - GENL_HDRLEN)

/* Binding to multicast group requires %CAP_NET_ADMIN */
#define GENL_MCAST_CAP_NET_ADMIN	BIT(0)
/* Binding to multicast group requires %CAP_SYS_ADMIN */
#define GENL_MCAST_CAP_SYS_ADMIN	BIT(1)

/**
 * struct genl_multicast_group - generic netlink multicast group
 * @name: name of the multicast group, names are per-family
 * @flags: GENL_MCAST_* flags
 */
struct genl_multicast_group {
	char			name[GENL_NAMSIZ];
	u8			flags;
};

struct genl_ops;
+1 −1
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
}

static const struct genl_multicast_group dropmon_mcgrps[] = {
	{ .name = "events", .flags = GENL_MCAST_CAP_SYS_ADMIN, },
	{ .name = "events" },
};

static void send_dm_alert(struct work_struct *work)
+13 −3
Original line number Diff line number Diff line
@@ -1366,6 +1366,7 @@ static struct genl_family genl_ctrl __ro_after_init = {

static int genl_bind(struct net *net, int group)
{
	bool check_sys_admin, check_net_admin;
	const struct genl_family *family;
	unsigned int id;
	int ret = 0;
@@ -1382,12 +1383,21 @@ static int genl_bind(struct net *net, int group)
		i = group - family->mcgrp_offset;
		if (i < 0 || i >= family->n_mcgrps)
			continue;

		check_sys_admin = false;
		check_net_admin = false;
		grp = &family->mcgrps[i];
		if ((grp->flags & GENL_MCAST_CAP_NET_ADMIN) &&
		if (!strcmp(family->name, "NET_DM")) {
			if (!strcmp(grp->name, "events"))
				check_sys_admin = true;
		} else if (!strcmp(family->name, "psample")) {
			if (!strcmp(grp->name, "packets"))
				check_net_admin = true;
		}

		if (check_net_admin &&
		    !ns_capable(net->user_ns, CAP_NET_ADMIN))
			ret = -EPERM;
		if ((grp->flags & GENL_MCAST_CAP_SYS_ADMIN) &&
		if (check_sys_admin &&
		    !ns_capable(net->user_ns, CAP_SYS_ADMIN))
			ret = -EPERM;

+1 −2
Original line number Diff line number Diff line
@@ -30,8 +30,7 @@ enum psample_nl_multicast_groups {

static const struct genl_multicast_group psample_nl_mcgrps[] = {
	[PSAMPLE_NL_MCGRP_CONFIG] = { .name = PSAMPLE_NL_MCGRP_CONFIG_NAME },
	[PSAMPLE_NL_MCGRP_SAMPLE] = { .name = PSAMPLE_NL_MCGRP_SAMPLE_NAME,
				      .flags = GENL_MCAST_CAP_NET_ADMIN,},
	[PSAMPLE_NL_MCGRP_SAMPLE] = { .name = PSAMPLE_NL_MCGRP_SAMPLE_NAME },
};

static struct genl_family psample_nl_family __ro_after_init;