From nobody Thu Apr 2 20:09:00 2026 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (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 A086339D6E0 for ; Thu, 26 Mar 2026 17:46:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774547196; cv=none; b=swS/YWCOaa1L+oRRQjTmrdIbJw38R7D36Z0C8YPjAwAn1S8itE2FyZYP9DMEyRSSUi3Z2KJ0Qo3lTql1CwFK4LZY4xIsGvC7DYni424WrjBdk+UUB5m9LxKaYo+hmhpeA+43RWSXaawmcoCwOKb3nFhhgKDZpycGvYb8t051jYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774547196; c=relaxed/simple; bh=+vw2JkvCXKRoQRcER3jPQEIB++vTT0CoMaEKfyNHHnE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bOZpLCz4i8G/D498tswt5nrOoYGE7uiRo3LrBe8c5+8ULYg7HeI0Mf0mZ6+0l76dODCMR2ZZaT8njzAD4I6JAsL2JvWF9zRnZX5jydhhavCXMdmGk6n/8cjI2uEj/ac3qyLrem4LBerPRsV0gsWZ3YFRxDMhAkYA+t2q/o//L00= 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=XxvibRvn; arc=none smtp.client-ip=95.215.58.174 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="XxvibRvn" 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=1774547187; 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=HCZCqssiuCqpmDoMVvWj4+RE/eoOZ2EbUqziqvm6HAE=; b=XxvibRvnJcKmbi0t2gTV4FaZBAa4E5sb/AllqGZBIqLWHaIqhll5jGnGEdoeWS7RdofD6o v7hmI8c616gGvMP/WZybPyCG8HmixmAzRV8N784ua9WpCfmH/xbh3/rapXeRCImbRKnW4T Ct1qGcEkAmlIzG04r5XG1d6Nik1BFcA= 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/2] net: hsr: constify hsr_ops and prp_ops protocol operation structures Date: Thu, 26 Mar 2026 18:45:59 +0100 Message-ID: <20260326174600.136232-2-luka.gejak@linux.dev> In-Reply-To: <20260326174600.136232-1-luka.gejak@linux.dev> References: <20260326174600.136232-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 The hsr_ops and prp_ops structures are assigned to hsr->proto_ops during device initialization and are never modified at runtime. Declaring them as const allows the compiler to place these structures in read-only memory, which improves security by preventing accidental or malicious modification of the function pointers they contain. The proto_ops field in struct hsr_priv is also updated to a const pointer to maintain type consistency. Signed-off-by: Luka Gejak --- net/hsr/hsr_device.c | 4 ++-- net/hsr/hsr_main.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 5c3eca2235ce..90236028817d 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -616,7 +616,7 @@ static const struct device_type hsr_type =3D { .name =3D "hsr", }; =20 -static struct hsr_proto_ops hsr_ops =3D { +static const struct hsr_proto_ops hsr_ops =3D { .send_sv_frame =3D send_hsr_supervision_frame, .create_tagged_frame =3D hsr_create_tagged_frame, .get_untagged_frame =3D hsr_get_untagged_frame, @@ -626,7 +626,7 @@ static struct hsr_proto_ops hsr_ops =3D { .register_frame_out =3D hsr_register_frame_out, }; =20 -static struct hsr_proto_ops prp_ops =3D { +static const struct hsr_proto_ops prp_ops =3D { .send_sv_frame =3D send_prp_supervision_frame, .create_tagged_frame =3D prp_create_tagged_frame, .get_untagged_frame =3D prp_get_untagged_frame, diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h index 33b0d2460c9b..134e4f3fff60 100644 --- a/net/hsr/hsr_main.h +++ b/net/hsr/hsr_main.h @@ -202,7 +202,7 @@ struct hsr_priv { enum hsr_version prot_version; /* Indicate if HSRv0, HSRv1 or PRPv1 */ spinlock_t seqnr_lock; /* locking for sequence_nr */ spinlock_t list_lock; /* locking for node list */ - struct hsr_proto_ops *proto_ops; + const struct hsr_proto_ops *proto_ops; #define PRP_LAN_ID 0x5 /* 0x1010 for A and 0x1011 for B. Bit 0 is set * based on SLAVE_A or SLAVE_B */ --=20 2.53.0