Only allow a SCTP-AUTH shared key to be updated by the application

if it is not deactivated and not used.
This avoids a use-after-free problem.

Reported by:		da_cheng_shao@yeah.net
MFC after:		3 days
This commit is contained in:
Michael Tuexen 2019-09-17 09:46:42 +00:00
parent 7f65185940
commit 3c19311544
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=352438

View File

@ -523,7 +523,7 @@ sctp_insert_sharedkey(struct sctp_keyhead *shared_keys,
} else if (new_skey->keyid == skey->keyid) {
/* replace the existing key */
/* verify this key *can* be replaced */
if ((skey->deactivated) && (skey->refcount > 1)) {
if ((skey->deactivated) || (skey->refcount > 1)) {
SCTPDBG(SCTP_DEBUG_AUTH1,
"can't replace shared key id %u\n",
new_skey->keyid);