From nobody Thu Apr 2 20:28:01 2026 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 633244035C9 for ; Thu, 26 Mar 2026 15:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774540067; cv=none; b=AcN9OhcvvxgulCV72TkZYpJ8KNUQQa/Z50t8QtIBGCJNxGTpORFxJYdzbBIr6r5+gRyMpZT3Ims/Rhvp4shMphcKK//Dt/SKSgEUDLFyOd7xIvo4uFtOoWov1iTjhSpHA1JNjZoao9lBC30/ShRoHVV1r7tKzkOoDuW0FCg38BM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774540067; c=relaxed/simple; bh=BRIP1mTZDCMHEU04QrDwkcuyDCBEWWQgkhGzpNxjuEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HhaLkqR7H6c6bY5fjXFgvXLg0R8YzFr1DU7NG8py7KKimztKZqU9rQ75b+zSngR8dZsTLUd/sklWbXKlyZ8YjCmCDnQONt8uUh4814GnnTIwfrjtNJXh9s51g7J2RikPvLonQ7bFUsE+AxKmoEVv+B+VZ0nHjxo7MxKzmuJ7V7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=KTFDLZ29; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="KTFDLZ29" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774540063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u347+uD3sb5mTEYMpGjCMcCICUQJttgR0qXNZxV+wWk=; b=KTFDLZ29KTVJC/qHcc4PdQSnoZfOKODzQ1soytx+KrSMFqQqb/DU6rYKAEoN/SdlNueg2Y INkHJdtAyBMkdV9EhLeMQIow8uyomMZ0oulASU6zNwSO+iQ4bfIbkaDk+YSgy9Nk4jyv6X MEOYKffPYzj/mGjtJvy+t5s1CxenGXQ= From: luka.gejak@linux.dev To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: horms@kernel.org, fmaurer@redhat.com, liuhangbin@gmail.com, linux-kernel@vger.kernel.org, luka.gejak@linux.dev Subject: [PATCH net-next v2 1/4] net: hsr: serialize seq_blocks merge across nodes Date: Thu, 26 Mar 2026 16:47:12 +0100 Message-ID: <20260326154715.38405-2-luka.gejak@linux.dev> In-Reply-To: <20260326154715.38405-1-luka.gejak@linux.dev> References: <20260326154715.38405-1-luka.gejak@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Luka Gejak During node merging, hsr_handle_sup_frame() walks node_curr->seq_blocks to update node_real without holding node_curr->seq_out_lock. This allows concurrent mutations from duplicate registration paths, risking inconsistent state or XArray/bitmap corruption. Fix this by locking both nodes' seq_out_lock during the merge. To prevent ABBA deadlocks, locks are acquired in order of memory address. Reviewed-by: Felix Maurer Signed-off-by: Luka Gejak --- net/hsr/hsr_framereg.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index 577fb588bc2f..d09875b33588 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c @@ -123,6 +123,40 @@ static void hsr_free_node_rcu(struct rcu_head *rn) hsr_free_node(node); } =20 +static void hsr_lock_seq_out_pair(struct hsr_node *node_a, + struct hsr_node *node_b) +{ + if (node_a =3D=3D node_b) { + spin_lock_bh(&node_a->seq_out_lock); + return; + } + + if (node_a < node_b) { + spin_lock_bh(&node_a->seq_out_lock); + spin_lock_nested(&node_b->seq_out_lock, SINGLE_DEPTH_NESTING); + } else { + spin_lock_bh(&node_b->seq_out_lock); + spin_lock_nested(&node_a->seq_out_lock, SINGLE_DEPTH_NESTING); + } +} + +static void hsr_unlock_seq_out_pair(struct hsr_node *node_a, + struct hsr_node *node_b) +{ + if (node_a =3D=3D node_b) { + spin_unlock_bh(&node_a->seq_out_lock); + return; + } + + if (node_a < node_b) { + spin_unlock(&node_b->seq_out_lock); + spin_unlock_bh(&node_a->seq_out_lock); + } else { + spin_unlock(&node_a->seq_out_lock); + spin_unlock_bh(&node_b->seq_out_lock); + } +} + void hsr_del_nodes(struct list_head *node_db) { struct hsr_node *node; @@ -432,7 +466,7 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame) } =20 ether_addr_copy(node_real->macaddress_B, ethhdr->h_source); - spin_lock_bh(&node_real->seq_out_lock); + hsr_lock_seq_out_pair(node_real, node_curr); for (i =3D 0; i < HSR_PT_PORTS; i++) { if (!node_curr->time_in_stale[i] && time_after(node_curr->time_in[i], node_real->time_in[i])) { @@ -455,7 +489,7 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame) src_blk->seq_nrs[i], HSR_SEQ_BLOCK_SIZE); } } - spin_unlock_bh(&node_real->seq_out_lock); + hsr_unlock_seq_out_pair(node_real, node_curr); node_real->addr_B_port =3D port_rcv->type; =20 spin_lock_bh(&hsr->list_lock); --=20 2.53.0 From nobody Thu Apr 2 20:28:01 2026 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 010D1405ADF for ; Thu, 26 Mar 2026 15:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774540068; cv=none; b=YUjvKPZh9+bSK+mI27tscQ/oKBWBlCohn9BDADZkTxXAaWeEs6c3TPnXIqjDGM1DD7VjtwitiD8Rd5wyv4vflxNRzmBC1VRp9/J5f8j3UuAEQAd2ZG43wgiXRFax59YqRIbW9g4+MLVIDhBOGCUws6UCGu70M/zPOmFmSIqiQNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774540068; c=relaxed/simple; bh=U6p3gmpfZYNmIXqvlbwD8jQV3/qsbkyG/cQlRyqNnHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gbRQygeOU+11XAHXqaLZ6slajbj0DR6K0+u+Ziuv+/TjUqfPilBNbnq+EZrwi7IDxXl3KP16qgfBS3b0C24j6sawyMccuV2eiwtDOQ5A+FTNeAvq3zWIVhIWxMIHhZFSu1gPOHo/HEZax+9jB3/RFAKd3zhZPJINTuNses2TA/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kGBZIWSO; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="kGBZIWSO" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774540065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hPY4fsQXGzvXxvTJIcp/TRaosw/Q+GiVOf+xawe5e6k=; b=kGBZIWSOuWQqwBnhi3Kabwd0JVjrAca8wnTmORr34G8ha3ZV2UesYDjuVdhCUxHkT2rnO/ lWESoiTRyg7zzoTZM1ZnuCdGJljVmIgn84oYd60dYiAKLe3RAo/W7021qMVzgBMyTZ8wWw HcplX3UaQBJhl/LXPL3jViMzEsoOk8o= From: luka.gejak@linux.dev To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: horms@kernel.org, fmaurer@redhat.com, liuhangbin@gmail.com, linux-kernel@vger.kernel.org, luka.gejak@linux.dev Subject: [PATCH net-next v2 2/4] net: hsr: fix VLAN add unwind on slave errors Date: Thu, 26 Mar 2026 16:47:13 +0100 Message-ID: <20260326154715.38405-3-luka.gejak@linux.dev> In-Reply-To: <20260326154715.38405-1-luka.gejak@linux.dev> References: <20260326154715.38405-1-luka.gejak@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Luka Gejak When vlan_vid_add() fails for a secondary slave, the error path calls vlan_vid_del() on the failing port instead of the peer slave that had already succeeded. This results in asymmetric VLAN state across the HSR pair. Fix this by switching to a centralized unwind path that removes the VID from any slave device that was already programmed. Signed-off-by: Luka Gejak --- net/hsr/hsr_device.c | 46 ++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 5c3eca2235ce..75c491279df8 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -532,8 +532,8 @@ static void hsr_change_rx_flags(struct net_device *dev,= int change) static int hsr_ndo_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) { - bool is_slave_a_added =3D false; - bool is_slave_b_added =3D false; + struct net_device *slave_a_dev =3D NULL; + struct net_device *slave_b_dev =3D NULL; struct hsr_port *port; struct hsr_priv *hsr; int ret =3D 0; @@ -546,29 +546,28 @@ static int hsr_ndo_vlan_rx_add_vid(struct net_device = *dev, continue; =20 ret =3D vlan_vid_add(port->dev, proto, vid); - switch (port->type) { - case HSR_PT_SLAVE_A: - if (ret) { - /* clean up Slave-B */ + if (ret) { + switch (port->type) { + case HSR_PT_SLAVE_A: netdev_err(dev, "add vid failed for Slave-A\n"); - if (is_slave_b_added) - vlan_vid_del(port->dev, proto, vid); - return ret; + break; + case HSR_PT_SLAVE_B: + netdev_err(dev, "add vid failed for Slave-B\n"); + break; + default: + break; } =20 - is_slave_a_added =3D true; + goto unwind; + } + + switch (port->type) { + case HSR_PT_SLAVE_A: + slave_a_dev =3D port->dev; break; =20 case HSR_PT_SLAVE_B: - if (ret) { - /* clean up Slave-A */ - netdev_err(dev, "add vid failed for Slave-B\n"); - if (is_slave_a_added) - vlan_vid_del(port->dev, proto, vid); - return ret; - } - - is_slave_b_added =3D true; + slave_b_dev =3D port->dev; break; default: break; @@ -576,6 +575,15 @@ static int hsr_ndo_vlan_rx_add_vid(struct net_device *= dev, } =20 return 0; + +unwind: + if (slave_a_dev) + vlan_vid_del(slave_a_dev, proto, vid); + + if (slave_b_dev) + vlan_vid_del(slave_b_dev, proto, vid); + + return ret; } =20 static int hsr_ndo_vlan_rx_kill_vid(struct net_device *dev, --=20 2.53.0 From nobody Thu Apr 2 20:28:01 2026 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54AED4070F3 for ; Thu, 26 Mar 2026 15:47:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774540069; cv=none; b=gO/tfss/lQeuZFdm00yZIdFQTniweeYAMAwL8GM/DfrJbNUoth5KkygsVl57PkS9MwYJA2BNvRa8p+rofauCB6bS8v0Bb78ZztclIDcte/pAFTy9GBEjMB1dpqMInvYoecOh41ROBC0Sdc9UVpuBbx2pXZdqw4hgay2WJ+4Dir0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774540069; c=relaxed/simple; bh=FKvTpO1SluKtjSMrTLWTBN3s/9HEwJe1ge0E6tvCeNg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vj++LipIaHzF7DW+85G844JxJ2df60RbgdXELTnjROhN6D09xP+OEH7ve4l4RT5VFaam1mx3xAtNYuwyx5MZQhTadyuxwNTtrBWFiGcMnhwiGQrBx9ifiKZYgudsNDSnb4Qye6RhgJflYeyuOL3JquGOviQEvYjvWbNv0TB7A8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tZxqKLlp; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tZxqKLlp" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774540066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cz51yi/FiPlzZs1MA69fyINR+7e40BLTFJSWXlWlNIo=; b=tZxqKLlpnMFMiGkyy7wCjYYty2duF5RxJ6PSbgKH6vcqidPWgIvQrr/1dbE0E8lobYa/NA pXz4A5xThe6frR2BJT1g2Jozc4UATgyW4ogaSpj5QJi/WC7ZeJb11r4B2cEw66+s8NVGlg H16JTVtcNiPy5aOTSn8D38Btp0ZqWPo= From: luka.gejak@linux.dev To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: horms@kernel.org, fmaurer@redhat.com, liuhangbin@gmail.com, linux-kernel@vger.kernel.org, luka.gejak@linux.dev Subject: [PATCH net-next v2 3/4] net: hsr: require valid EOT supervision TLV Date: Thu, 26 Mar 2026 16:47:14 +0100 Message-ID: <20260326154715.38405-4-luka.gejak@linux.dev> In-Reply-To: <20260326154715.38405-1-luka.gejak@linux.dev> References: <20260326154715.38405-1-luka.gejak@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Luka Gejak Supervision frames are only valid if terminated with a zero-length EOT TLV. The current check fails to reject non-EOT entries as the terminal TLV, potentially allowing malformed supervision traffic. Fix this by strictly requiring the terminal TLV to be HSR_TLV_EOT with a length of zero. Reviewed-by: Felix Maurer Signed-off-by: Luka Gejak --- net/hsr/hsr_forward.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c index aefc9b6936ba..d26c7d0e8109 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -110,7 +110,7 @@ static bool is_supervision_frame(struct hsr_priv *hsr, = struct sk_buff *skb) } =20 /* end of tlvs must follow at the end */ - if (hsr_sup_tlv->HSR_TLV_type =3D=3D HSR_TLV_EOT && + if (hsr_sup_tlv->HSR_TLV_type !=3D HSR_TLV_EOT || hsr_sup_tlv->HSR_TLV_length !=3D 0) return false; =20 --=20 2.53.0 From nobody Thu Apr 2 20:28:01 2026 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3B8D40822E for ; Thu, 26 Mar 2026 15:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774540071; cv=none; b=Q378Pt17aqyPUKNZnXFFZrzp5tsEl/lPti2lqElZh8shHcogzvihXKJE98QffsvTCJhmx98PMq4mt5vEZFnPpLJFNEtRUG2XVb3tclPQfAvvfZCIlRxQ9oNselK1+nPM6StqtrRfywdgbt4o9/uPXAc3soYx+Zy66C9un6WQRIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774540071; c=relaxed/simple; bh=VKCyhqMVXE+KSqjXVeG+3hvSNLI273PUuk32Xdv7S5Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ovy/tU+kXg3hI4hCY3tmLuPPJBO8AgxyAEV6CpTzow4XIyYUI8whURmQxMnjohiMnSWBkhJEXyp3Z0nApg1vEXQ5dfz66oeGIDYJCIq6uhtszlT66CIoni3y8FkfJk5pJZ8JkVXRRKGzMqyfE0Ckm3HuzlLyf+aycRpUyheE3lg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Ov8t+wVB; arc=none smtp.client-ip=91.218.175.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Ov8t+wVB" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774540068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OXNLfi3VDWQRurd0FK4vAiq2uw5ZAgnel28YQEol3sw=; b=Ov8t+wVBvvTlFIozN/P7qlTc+R44ggI+gmyiou7IkgaObdAWk/SGK6F8aXzGEYf8LMWNjP pNO7l/a3tgRCZm3AGJySOqAG9OQnmsqdbZQqCirmSG0q7wByr+qCC0tlkseieN+DatGpuU BXzoCks5DoaEJEqbaGILZfpt0LqSkes= From: luka.gejak@linux.dev To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: horms@kernel.org, fmaurer@redhat.com, liuhangbin@gmail.com, linux-kernel@vger.kernel.org, luka.gejak@linux.dev Subject: [PATCH net-next v2 4/4] net: hsr: reject unresolved interlink ifindex Date: Thu, 26 Mar 2026 16:47:15 +0100 Message-ID: <20260326154715.38405-5-luka.gejak@linux.dev> In-Reply-To: <20260326154715.38405-1-luka.gejak@linux.dev> References: <20260326154715.38405-1-luka.gejak@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Luka Gejak In hsr_newlink(), a provided but invalid IFLA_HSR_INTERLINK attribute was silently ignored if __dev_get_by_index() returned NULL. This leads to incorrect RedBox topology creation without notifying the user. Fix this by returning -EINVAL and an extack message when the interlink attribute is present but cannot be resolved. Reviewed-by: Felix Maurer Signed-off-by: Luka Gejak --- net/hsr/hsr_netlink.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c index db0b0af7a692..f0ca23da3ab9 100644 --- a/net/hsr/hsr_netlink.c +++ b/net/hsr/hsr_netlink.c @@ -76,9 +76,14 @@ static int hsr_newlink(struct net_device *dev, return -EINVAL; } =20 - if (data[IFLA_HSR_INTERLINK]) + if (data[IFLA_HSR_INTERLINK]) { interlink =3D __dev_get_by_index(link_net, nla_get_u32(data[IFLA_HSR_INTERLINK])); + if (!interlink) { + NL_SET_ERR_MSG_MOD(extack, "Interlink does not exist"); + return -EINVAL; + } + } =20 if (interlink && interlink =3D=3D link[0]) { NL_SET_ERR_MSG_MOD(extack, "Interlink and Slave1 are the same"); --=20 2.53.0