diff options
author | Kay Sievers <kay@vrfy.org> | 2014-03-08 16:43:43 +0100 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2014-03-08 16:43:43 +0100 |
commit | 34509af4e1b7cd1748e5d83ed8e59f1f2649025c (patch) | |
tree | 5f3e098bf2f4a2caa63d2bdb409abcf55173b0fd | |
parent | d2e2cadf8354f4be73c5ea3a0a6b6cb5e9c1a067 (diff) | |
download | kdbus-bus-34509af4e1b7cd1748e5d83ed8e59f1f2649025c.tar.gz kdbus-bus-34509af4e1b7cd1748e5d83ed8e59f1f2649025c.tar.bz2 kdbus-bus-34509af4e1b7cd1748e5d83ed8e59f1f2649025c.zip |
policy: add KDBUS_ITEMS_END() check
-rw-r--r-- | bus.c | 2 | ||||
-rw-r--r-- | domain.c | 2 | ||||
-rw-r--r-- | endpoint.c | 2 | ||||
-rw-r--r-- | handle.c | 2 | ||||
-rw-r--r-- | match.c | 3 | ||||
-rw-r--r-- | message.c | 2 | ||||
-rw-r--r-- | policy.c | 3 | ||||
-rw-r--r-- | util.h | 4 |
8 files changed, 12 insertions, 8 deletions
@@ -375,7 +375,7 @@ int kdbus_bus_make_user(const struct kdbus_cmd_make *make, } } - if (!KDBUS_ITEMS_END(item, make)) + if (!KDBUS_ITEMS_END(item, make->items, KDBUS_ITEMS_SIZE(make, items))) return -EINVAL; if (!n) @@ -397,7 +397,7 @@ int kdbus_domain_make_user(struct kdbus_cmd_make *cmd, char **name) } } - if (!KDBUS_ITEMS_END(item, cmd)) + if (!KDBUS_ITEMS_END(item, cmd->items, KDBUS_ITEMS_SIZE(cmd, items))) return -EINVAL; if (!name) diff --git a/endpoint.c b/endpoint.c index 6d38b2dffb0..826d7d98e38 100644 --- a/endpoint.c +++ b/endpoint.c @@ -300,7 +300,7 @@ int kdbus_ep_make_user(const struct kdbus_cmd_make *make, char **name) } } - if (!KDBUS_ITEMS_END(item, make)) + if (!KDBUS_ITEMS_END(item, make->items, KDBUS_ITEMS_SIZE(make, items))) return -EINVAL; if (!n) @@ -287,7 +287,7 @@ static int kdbus_handle_memfd(void __user *buf) } } - if (!KDBUS_ITEMS_END(item, m)) { + if (!KDBUS_ITEMS_END(item, m->items, KDBUS_ITEMS_SIZE(m, items))) { ret = -EINVAL; goto exit; } @@ -492,7 +492,8 @@ int kdbus_match_db_add(struct kdbus_conn *conn, list_add_tail(&rule->rules_entry, &entry->rules_list); } - if (ret == 0 && !KDBUS_ITEMS_END(item, cmd)) + if (ret == 0 && + !KDBUS_ITEMS_END(item, cmd->items, KDBUS_ITEMS_SIZE(cmd, items))) ret = -EINVAL; if (ret == 0) diff --git a/message.c b/message.c index 3b9d373b100..1a88bf1f436 100644 --- a/message.c +++ b/message.c @@ -210,7 +210,7 @@ static int kdbus_msg_scan_items(struct kdbus_conn *conn, } } - if (!KDBUS_ITEMS_END(item, msg)) + if (!KDBUS_ITEMS_END(item, msg->items, KDBUS_ITEMS_SIZE(msg, items))) return -EINVAL; /* name is needed if no ID is given */ @@ -614,6 +614,9 @@ int kdbus_policy_set(struct kdbus_policy_db *db, } } + if (!KDBUS_ITEMS_END(item, items, items_size)) + return -EINVAL; + if (e) { ret = kdbus_policy_add_one(db, e); if (ret < 0) @@ -42,8 +42,8 @@ #define KDBUS_ITEMS_FOREACH(item, head, first) \ KDBUS_ITEMS_FOREACH_SIZE(item, (head)->first, \ KDBUS_ITEMS_SIZE(head, first)) -#define KDBUS_ITEMS_END(item, head) \ - ((u8 *)item == ((u8 *)(head) + KDBUS_ALIGN8((head)->size))) +#define KDBUS_ITEMS_END(item, items, size) \ + ((u8 *)item == ((u8 *)(items) + KDBUS_ALIGN8(size))) /** * kdbus_size_get_user - read the size variable from user memory |