diff options
| author | Qing Luo <luoqing@kylinos.cn> | 2026-08-07 14:43:14 +0800 |
|---|---|---|
| committer | Paolo Abeni <pabeni@redhat.com> | 2026-08-11 10:43:54 +0200 |
| commit | 5d3ae80ecddeb82b492a2cf31ac3e44412b426f4 (patch) | |
| tree | e70361aeb2c0eeda0f44e1128e8268e25c6cd0b3 /include | |
| parent | d67e5dbda22604d0fcde32fce58c65f88676e676 (diff) | |
sctp: auth: propagate HMAC calculation errors to callers
sctp_auth_calculate_hmac() can fail when building the association secret
under memory pressure, but its void return silently leaves the HMAC digest
zeroed. On the receive path, sctp_sf_authenticate() compares this zeroed
digest against the peer-supplied one using crypto_memneq(), potentially
accepting an all-zero HMAC from the peer if the allocation failed. On the
send path, sctp_packet_pack() transmits a packet with a zeroed HMAC that
the peer would reject.
Improve error handling by making sctp_auth_calculate_hmac() return int:
- sctp_sf_authenticate() returns SCTP_IERROR_NOMEM instead of accepting
a zero HMAC.
- sctp_packet_pack() drops the packet on failure instead of transmitting
a zeroed HMAC.
Update the declaration in auth.h accordingly.
Assisted-by: LLM
Signed-off-by: Qing Luo <luoqing@kylinos.cn>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20260807064314.500742-1-l1138897701@163.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/net/sctp/auth.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/net/sctp/auth.h b/include/net/sctp/auth.h index 6f2cd562b1de..eeb3297fe97d 100644 --- a/include/net/sctp/auth.h +++ b/include/net/sctp/auth.h @@ -83,9 +83,9 @@ int sctp_auth_send_cid(enum sctp_cid chunk, const struct sctp_association *asoc); int sctp_auth_recv_cid(enum sctp_cid chunk, const struct sctp_association *asoc); -void sctp_auth_calculate_hmac(const struct sctp_association *asoc, - struct sk_buff *skb, struct sctp_auth_chunk *auth, - struct sctp_shared_key *ep_key, gfp_t gfp); +int sctp_auth_calculate_hmac(const struct sctp_association *asoc, + struct sk_buff *skb, struct sctp_auth_chunk *auth, + struct sctp_shared_key *ep_key, gfp_t gfp); void sctp_auth_shkey_release(struct sctp_shared_key *sh_key); void sctp_auth_shkey_hold(struct sctp_shared_key *sh_key); |
