Skip to content

Commit 9828994

Browse files
Emeel HakimSaeed Mahameed
authored andcommitted
net/mlx5e: Fix macsec possible null dereference when updating MAC security entity (SecY)
Upon updating MAC security entity (SecY) in hw offload path, the macsec security association (SA) initialization routine is called. In case of extended packet number (epn) is enabled the salt and ssci attributes are retrieved using the MACsec driver rx_sa context which is unavailable when updating a SecY property such as encoding-sa hence the null dereference. Fix by using the provided SA to set those attributes. Fixes: 4411a6c ("net/mlx5e: Support MACsec offload extended packet number (EPN)") Signed-off-by: Emeel Hakim <[email protected]> Reviewed-by: Raed Salem <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent f5e1ed0 commit 9828994

File tree

1 file changed

+2
-7
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en_accel

1 file changed

+2
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
359359
struct mlx5_core_dev *mdev = priv->mdev;
360360
struct mlx5_macsec_obj_attrs obj_attrs;
361361
union mlx5e_macsec_rule *macsec_rule;
362-
struct macsec_key *key;
363362
int err;
364363

365364
obj_attrs.next_pn = sa->next_pn;
@@ -369,13 +368,9 @@ static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
369368
obj_attrs.aso_pdn = macsec->aso.pdn;
370369
obj_attrs.epn_state = sa->epn_state;
371370

372-
key = (is_tx) ? &ctx->sa.tx_sa->key : &ctx->sa.rx_sa->key;
373-
374371
if (sa->epn_state.epn_enabled) {
375-
obj_attrs.ssci = (is_tx) ? cpu_to_be32((__force u32)ctx->sa.tx_sa->ssci) :
376-
cpu_to_be32((__force u32)ctx->sa.rx_sa->ssci);
377-
378-
memcpy(&obj_attrs.salt, &key->salt, sizeof(key->salt));
372+
obj_attrs.ssci = cpu_to_be32((__force u32)sa->ssci);
373+
memcpy(&obj_attrs.salt, &sa->salt, sizeof(sa->salt));
379374
}
380375

381376
obj_attrs.replay_window = ctx->secy->replay_window;

0 commit comments

Comments
 (0)