diff options
author | Johannes Berg <johannes.berg@intel.com> | 2013-11-19 09:19:33 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-11-19 16:39:05 -0500 |
commit | 2ecf7536b2787580616d23b6507005d930975ca0 (patch) | |
tree | 050b07aaf96d86a83ed42c34511a3f28e1c0d1d4 /fs/quota | |
parent | e5dcecba015f9774a402ba559b80b16999747e3b (diff) |
quota/genetlink: use proper genetlink multicast APIs
The quota code is abusing the genetlink API and is using
its family ID as the multicast group ID, which is invalid
and may belong to somebody else (and likely will.)
Make the quota code use the correct API, but since this
is already used as-is by userspace, reserve a family ID
for this code and also reserve that group ID to not break
userspace assumptions.
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'fs/quota')
-rw-r--r-- | fs/quota/netlink.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c index 16e8abb7709b..aa22fe03b76c 100644 --- a/fs/quota/netlink.c +++ b/fs/quota/netlink.c | |||
@@ -11,13 +11,23 @@ | |||
11 | 11 | ||
12 | /* Netlink family structure for quota */ | 12 | /* Netlink family structure for quota */ |
13 | static struct genl_family quota_genl_family = { | 13 | static struct genl_family quota_genl_family = { |
14 | .id = GENL_ID_GENERATE, | 14 | /* |
15 | * Needed due to multicast group ID abuse - old code assumed | ||
16 | * the family ID was also a valid multicast group ID (which | ||
17 | * isn't true) and userspace might thus rely on it. Assign a | ||
18 | * static ID for this group to make dealing with that easier. | ||
19 | */ | ||
20 | .id = GENL_ID_VFS_DQUOT, | ||
15 | .hdrsize = 0, | 21 | .hdrsize = 0, |
16 | .name = "VFS_DQUOT", | 22 | .name = "VFS_DQUOT", |
17 | .version = 1, | 23 | .version = 1, |
18 | .maxattr = QUOTA_NL_A_MAX, | 24 | .maxattr = QUOTA_NL_A_MAX, |
19 | }; | 25 | }; |
20 | 26 | ||
27 | static struct genl_multicast_group quota_mcgrp = { | ||
28 | .name = "events", | ||
29 | }; | ||
30 | |||
21 | /** | 31 | /** |
22 | * quota_send_warning - Send warning to userspace about exceeded quota | 32 | * quota_send_warning - Send warning to userspace about exceeded quota |
23 | * @type: The quota type: USRQQUOTA, GRPQUOTA,... | 33 | * @type: The quota type: USRQQUOTA, GRPQUOTA,... |
@@ -78,7 +88,7 @@ void quota_send_warning(struct kqid qid, dev_t dev, | |||
78 | goto attr_err_out; | 88 | goto attr_err_out; |
79 | genlmsg_end(skb, msg_head); | 89 | genlmsg_end(skb, msg_head); |
80 | 90 | ||
81 | genlmsg_multicast(skb, 0, quota_genl_family.id, GFP_NOFS); | 91 | genlmsg_multicast(skb, 0, quota_mcgrp.id, GFP_NOFS); |
82 | return; | 92 | return; |
83 | attr_err_out: | 93 | attr_err_out: |
84 | printk(KERN_ERR "VFS: Not enough space to compose quota message!\n"); | 94 | printk(KERN_ERR "VFS: Not enough space to compose quota message!\n"); |
@@ -92,6 +102,9 @@ static int __init quota_init(void) | |||
92 | if (genl_register_family("a_genl_family) != 0) | 102 | if (genl_register_family("a_genl_family) != 0) |
93 | printk(KERN_ERR | 103 | printk(KERN_ERR |
94 | "VFS: Failed to create quota netlink interface.\n"); | 104 | "VFS: Failed to create quota netlink interface.\n"); |
105 | if (genl_register_mc_group("a_genl_family, "a_mcgrp)) | ||
106 | printk(KERN_ERR | ||
107 | "VFS: Failed to register quota mcast group.\n"); | ||
95 | return 0; | 108 | return 0; |
96 | }; | 109 | }; |
97 | 110 | ||