Commit 237dfc5b authored by Marcelo Leitner's avatar Marcelo Leitner Committed by Willy Tarreau

ipv6: addrconf: validate new MTU before applying it

commit 77751427 upstream.

Currently we don't check if the new MTU is valid or not and this allows
one to configure a smaller than minimum allowed by RFCs or even bigger
than interface own MTU, which is a problem as it may lead to packet
drops.

If you have a daemon like NetworkManager running, this may be exploited
by remote attackers by forging RA packets with an invalid MTU, possibly
leading to a DoS. (NetworkManager currently only validates for values
too small, but not for too big ones.)

The fix is just to make sure the new value is valid. That is, between
IPV6_MIN_MTU and interface's MTU.

Note that similar check is already performed at
ndisc_router_discovery(), for when kernel itself parses the RA.
Signed-off-by: default avatarMarcelo Ricardo Leitner <mleitner@redhat.com>
Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
[bwh: Backported to 2.6.32:
 - Add a strategy for the sysctl as we don't get a default strategy
 - Adjust context, spacing]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent 37b602d2
......@@ -4036,6 +4036,40 @@ static int addrconf_sysctl_forward_strategy(ctl_table *table,
return addrconf_fixup_forwarding(table, valp, val);
}
static
struct ctl_table *addrconf_sysctl_mtu_init(struct ctl_table *newctl,
const struct ctl_table *ctl)
{
struct inet6_dev *idev = ctl->extra1;
static int min_mtu = IPV6_MIN_MTU;
*newctl = *ctl;
newctl->extra1 = &min_mtu;
newctl->extra2 = idev ? &idev->dev->mtu : NULL;
return newctl;
}
static
int addrconf_sysctl_mtu(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
struct ctl_table lctl;
return proc_dointvec_minmax(addrconf_sysctl_mtu_init(&lctl, ctl),
write, buffer, lenp, ppos);
}
static int addrconf_sysctl_mtu_strategy(struct ctl_table *ctl,
void __user *oldval,
size_t __user *oldlenp,
void __user *newval, size_t newlen)
{
struct ctl_table lctl;
return sysctl_intvec(addrconf_sysctl_mtu_init(&lctl, ctl),
oldval, oldlenp, newval, newlen);
}
static void dev_disable_change(struct inet6_dev *idev)
{
if (!idev || !idev->dev)
......@@ -4142,7 +4176,8 @@ static struct addrconf_sysctl_table
.data = &ipv6_devconf.mtu6,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
.proc_handler = addrconf_sysctl_mtu,
.strategy = addrconf_sysctl_mtu_strategy,
},
{
.ctl_name = NET_IPV6_ACCEPT_RA,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment