The local_ip and remote_ip configfs attributes are written independently and nothing stops a user from mixing ipv4 and ipv6. This leads to an ipv4 address being zero-extended into an ipv6 header or an ipv6 address being truncated to its first 4 bytes for an ipv4 header. The command-line parser already refuses such a mismatch. This adds a similar check when a dynamic target is being enabled. Signed-off-by: Gustavo Luiz Duarte --- drivers/net/netconsole.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index a41b0a5ce64f..69621705d68d 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -477,6 +477,13 @@ static int netcons_netpoll_setup(struct netconsole_target *nt) goto unlock; } + if (nt->local_ip.family != AF_UNSPEC && + nt->local_ip.family != nt->remote_ip.family) { + np_err(np, "local and remote IP address families differ, aborting\n"); + err = -EINVAL; + goto unlock; + } + if (np->dev_name[0]) ndev = __dev_get_by_name(net, np->dev_name); else if (is_valid_ether_addr(np->dev_mac)) -- 2.55.0