genetlink: fix genl_set_err() group ID

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Nov 22 17:59:07 EST 2013


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=91398a0992c8aa18eb7749060b75761ece5ddc57
Commit:     91398a0992c8aa18eb7749060b75761ece5ddc57
Parent:     220815a9665f7deca98a09ecca655044f94cfa44
Author:     Johannes Berg <johannes.berg at intel.com>
AuthorDate: Thu Nov 21 18:20:28 2013 +0100
Committer:  David S. Miller <davem at davemloft.net>
CommitDate: Thu Nov 21 13:09:43 2013 -0500

    genetlink: fix genl_set_err() group ID
    
    Fix another really stupid bug - I introduced genl_set_err()
    precisely to be able to adjust the group and reject invalid
    ones, but then forgot to do so.
    
    Signed-off-by: Johannes Berg <johannes.berg at intel.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>
---
 include/net/genetlink.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 771af09..1b177ed 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -384,6 +384,9 @@ static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
 static inline int genl_set_err(struct genl_family *family, struct net *net,
 			       u32 portid, u32 group, int code)
 {
+	if (WARN_ON_ONCE(group >= family->n_mcgrps))
+		return -EINVAL;
+	group = family->mcgrp_offset + group;
 	return netlink_set_err(net->genl_sock, portid, group, code);
 }
 



More information about the linux-mtd-cvs mailing list