From: Eric Dumazet Date: Wed, 4 Jan 2012 06:23:01 +0000 (+0000) Subject: net_sched: sfq: always randomize hash perturbation X-Git-Tag: v3.12-rc1~4160^2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02a9098ede0dc7e28c16a03fa7fba86a05219478;p=kernel%2Fkernel-generic.git net_sched: sfq: always randomize hash perturbation SFQ q->perturbation is used in sfq_hash() as an input to Jenkins hash. We currently randomize this 32bit value only if a perturbation timer is setup. Its much better to always initialize it to defeat attackers, or else they can predict very well what kind of packets they have to forge to hit a particular flow. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 16feb88..8430181 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -591,12 +591,12 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt) q->cur_depth = 0; q->tail = NULL; q->divisor = SFQ_DEFAULT_HASH_DIVISOR; - if (opt == NULL) { - q->quantum = psched_mtu(qdisc_dev(sch)); - q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum); - q->perturb_period = 0; - q->perturbation = net_random(); - } else { + q->quantum = psched_mtu(qdisc_dev(sch)); + q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum); + q->perturb_period = 0; + q->perturbation = net_random(); + + if (opt) { int err = sfq_change(sch, opt); if (err) return err;