Commit 70de41ef authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Jakub Kicinski
Browse files

llc: Constify struct llc_conn_state_trans



'struct llc_conn_state_trans' are not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig, as an example:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  13923	  10896	     32	  24851	   6113	net/llc/llc_c_st.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  21859	   3328	      0	  25187	   6263	net/llc/llc_c_st.o

Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/87cda89e4c9414e71d1a54bb1eb491b0e7f70375.1720973029.git.christophe.jaillet@wanadoo.fr


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f96eb117
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ struct llc_conn_state_trans {

struct llc_conn_state {
	u8				  current_state;
	struct llc_conn_state_trans **transitions;
	const struct llc_conn_state_trans **transitions;
};

extern struct llc_conn_state llc_conn_state_table[];
+250 −250

File changed.

Preview size limit exceeded, changes collapsed.

+10 −10
Original line number Diff line number Diff line
@@ -34,9 +34,9 @@ static int llc_find_offset(int state, int ev_type);
static void llc_conn_send_pdus(struct sock *sk);
static int llc_conn_service(struct sock *sk, struct sk_buff *skb);
static int llc_exec_conn_trans_actions(struct sock *sk,
				       struct llc_conn_state_trans *trans,
				       const struct llc_conn_state_trans *trans,
				       struct sk_buff *ev);
static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
static const struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
							      struct sk_buff *skb);

/* Offset table on connection states transition diagram */
@@ -356,9 +356,9 @@ static void llc_conn_send_pdus(struct sock *sk)
 */
static int llc_conn_service(struct sock *sk, struct sk_buff *skb)
{
	int rc = 1;
	const struct llc_conn_state_trans *trans;
	struct llc_sock *llc = llc_sk(sk);
	struct llc_conn_state_trans *trans;
	int rc = 1;

	if (llc->state > NBR_CONN_STATES)
		goto out;
@@ -384,10 +384,10 @@ static int llc_conn_service(struct sock *sk, struct sk_buff *skb)
 *	This function finds transition that matches with happened event.
 *	Returns pointer to found transition on success, %NULL otherwise.
 */
static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
static const struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
							      struct sk_buff *skb)
{
	struct llc_conn_state_trans **next_trans;
	const struct llc_conn_state_trans **next_trans;
	const llc_conn_ev_qfyr_t *next_qualifier;
	struct llc_conn_state_ev *ev = llc_conn_ev(skb);
	struct llc_sock *llc = llc_sk(sk);
@@ -432,7 +432,7 @@ static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
 *	success, 1 to indicate failure of at least one action.
 */
static int llc_exec_conn_trans_actions(struct sock *sk,
				       struct llc_conn_state_trans *trans,
				       const struct llc_conn_state_trans *trans,
				       struct sk_buff *skb)
{
	int rc = 0;
@@ -635,8 +635,8 @@ u8 llc_data_accept_state(u8 state)
 */
static u16 __init llc_find_next_offset(struct llc_conn_state *state, u16 offset)
{
	const struct llc_conn_state_trans **next_trans;
	u16 cnt = 0;
	struct llc_conn_state_trans **next_trans;

	for (next_trans = state->transitions + offset;
	     (*next_trans)->ev; next_trans++)