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: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/87cda89e4c9414e71d1a54bb1eb491b0e7f70375.1720973029.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Christophe JAILLET 2024-07-14 18:05:56 +02:00 committed by Jakub Kicinski
parent f96eb1172e
commit 70de41ef78
3 changed files with 262 additions and 262 deletions

View File

@ -44,8 +44,8 @@ struct llc_conn_state_trans {
}; };
struct llc_conn_state { struct llc_conn_state {
u8 current_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[]; extern struct llc_conn_state llc_conn_state_table[];

File diff suppressed because it is too large Load Diff

View File

@ -34,10 +34,10 @@ static int llc_find_offset(int state, int ev_type);
static void llc_conn_send_pdus(struct sock *sk); static void llc_conn_send_pdus(struct sock *sk);
static int llc_conn_service(struct sock *sk, struct sk_buff *skb); static int llc_conn_service(struct sock *sk, struct sk_buff *skb);
static int llc_exec_conn_trans_actions(struct sock *sk, 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); 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); struct sk_buff *skb);
/* Offset table on connection states transition diagram */ /* Offset table on connection states transition diagram */
static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV]; static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
@ -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) 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_sock *llc = llc_sk(sk);
struct llc_conn_state_trans *trans; int rc = 1;
if (llc->state > NBR_CONN_STATES) if (llc->state > NBR_CONN_STATES)
goto out; goto out;
@ -384,10 +384,10 @@ out:
* This function finds transition that matches with happened event. * This function finds transition that matches with happened event.
* Returns pointer to found transition on success, %NULL otherwise. * 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 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; const llc_conn_ev_qfyr_t *next_qualifier;
struct llc_conn_state_ev *ev = llc_conn_ev(skb); struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_sock *llc = llc_sk(sk); 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. * success, 1 to indicate failure of at least one action.
*/ */
static int llc_exec_conn_trans_actions(struct sock *sk, 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) struct sk_buff *skb)
{ {
int rc = 0; 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) 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; u16 cnt = 0;
struct llc_conn_state_trans **next_trans;
for (next_trans = state->transitions + offset; for (next_trans = state->transitions + offset;
(*next_trans)->ev; next_trans++) (*next_trans)->ev; next_trans++)