diff mbox

netem: loss model API sizes

Message ID 20111223111630.52f9f6d7@nehalam.linuxnetplumber.net
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

stephen hemminger Dec. 23, 2011, 7:16 p.m. UTC
The new netem loss model is configured with nested netlink messages.
This code is being overly strict about sizes, and is easily confused
by padding (or possible future expansion). Also message
for gemodel is incorrect.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller Dec. 23, 2011, 10:11 p.m. UTC | #1
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Fri, 23 Dec 2011 11:16:30 -0800

> The new netem loss model is configured with nested netlink messages.
> This code is being overly strict about sizes, and is easily confused
> by padding (or possible future expansion). Also message
> for gemodel is incorrect.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- a/net/sched/sch_netem.c	2011-08-01 14:13:55.000000000 -0700
+++ b/net/sched/sch_netem.c	2011-12-22 16:57:35.310210173 -0800
@@ -548,7 +548,7 @@  static int get_loss_clg(struct Qdisc *sc
 		case NETEM_LOSS_GI: {
 			const struct tc_netem_gimodel *gi = nla_data(la);
 
-			if (nla_len(la) != sizeof(struct tc_netem_gimodel)) {
+			if (nla_len(la) < sizeof(struct tc_netem_gimodel)) {
 				pr_info("netem: incorrect gi model size\n");
 				return -EINVAL;
 			}
@@ -567,8 +567,8 @@  static int get_loss_clg(struct Qdisc *sc
 		case NETEM_LOSS_GE: {
 			const struct tc_netem_gemodel *ge = nla_data(la);
 
-			if (nla_len(la) != sizeof(struct tc_netem_gemodel)) {
-				pr_info("netem: incorrect gi model size\n");
+			if (nla_len(la) < sizeof(struct tc_netem_gemodel)) {
+				pr_info("netem: incorrect ge model size\n");
 				return -EINVAL;
 			}