From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (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 B6CA9408230 for ; Thu, 26 Mar 2026 15:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774540071; cv=none; b=Wr/00JBFLxtGCSidsXdfm0JaWy/0JhlBI/P62HfHxRlt4Qwn6sF2GM3cmU94zgZjkrXQxmAUnx+hBV8cD3h0GfEiOuCFKDa4q4bP2I85tjKiKmDlBMK02Z6CCTP4YemFY+zhNmIP22S3/Y/GHe91RDZv8nPqLzCOF59nvztYMj8= 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.183 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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; } - if (data[IFLA_HSR_INTERLINK]) + if (data[IFLA_HSR_INTERLINK]) { interlink = __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; + } + } if (interlink && interlink == link[0]) { NL_SET_ERR_MSG_MOD(extack, "Interlink and Slave1 are the same"); -- 2.53.0