Skip to content

Commit

Permalink
net: atlantic: macsec: clear encryption keys from the stack
Browse files Browse the repository at this point in the history
Commit aaab73f ("macsec: clear encryption keys from the stack after
setting up offload") made sure to clean encryption keys from the stack
after setting up offloading, but the atlantic driver made a copy and did
not clear it. Fix this.

[4 Fixes tags below, all part of the same series, no need to split this]

Fixes: 9ff40a7 ("net: atlantic: MACSec ingress offload implementation")
Fixes: b8f8a0b ("net: atlantic: MACSec ingress offload HW bindings")
Fixes: 2773656 ("net: atlantic: MACSec egress offload implementation")
Fixes: 9d106c6 ("net: atlantic: MACSec egress offload HW bindings")
Signed-off-by: Antoine Tenart <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
atenart authored and Paolo Abeni committed Nov 10, 2022
1 parent 1b16b3f commit 879785d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/aquantia/atlantic/aq_macsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ static int aq_update_txsa(struct aq_nic_s *nic, const unsigned int sc_idx,

ret = aq_mss_set_egress_sakey_record(hw, &key_rec, sa_idx);

memzero_explicit(&key_rec, sizeof(key_rec));
return ret;
}

Expand Down Expand Up @@ -899,6 +900,7 @@ static int aq_update_rxsa(struct aq_nic_s *nic, const unsigned int sc_idx,

ret = aq_mss_set_ingress_sakey_record(hw, &sa_key_record, sa_idx);

memzero_explicit(&sa_key_record, sizeof(sa_key_record));
return ret;
}

Expand Down
18 changes: 11 additions & 7 deletions drivers/net/ethernet/aquantia/atlantic/macsec/macsec_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ set_ingress_sakey_record(struct aq_hw_s *hw,
u16 table_index)
{
u16 packed_record[18];
int ret;

if (table_index >= NUMROWS_INGRESSSAKEYRECORD)
return -EINVAL;
Expand Down Expand Up @@ -789,9 +790,12 @@ set_ingress_sakey_record(struct aq_hw_s *hw,

packed_record[16] = rec->key_len & 0x3;

return set_raw_ingress_record(hw, packed_record, 18, 2,
ROWOFFSET_INGRESSSAKEYRECORD +
table_index);
ret = set_raw_ingress_record(hw, packed_record, 18, 2,
ROWOFFSET_INGRESSSAKEYRECORD +
table_index);

memzero_explicit(packed_record, sizeof(packed_record));
return ret;
}

int aq_mss_set_ingress_sakey_record(struct aq_hw_s *hw,
Expand Down Expand Up @@ -1739,14 +1743,14 @@ static int set_egress_sakey_record(struct aq_hw_s *hw,
ret = set_raw_egress_record(hw, packed_record, 8, 2,
ROWOFFSET_EGRESSSAKEYRECORD + table_index);
if (unlikely(ret))
return ret;
goto clear_key;
ret = set_raw_egress_record(hw, packed_record + 8, 8, 2,
ROWOFFSET_EGRESSSAKEYRECORD + table_index -
32);
if (unlikely(ret))
return ret;

return 0;
clear_key:
memzero_explicit(packed_record, sizeof(packed_record));
return ret;
}

int aq_mss_set_egress_sakey_record(struct aq_hw_s *hw,
Expand Down

0 comments on commit 879785d

Please sign in to comment.