|
|
db1822 |
From bcb3ef5ab848eb648f05a840030df1f230976a70 Mon Sep 17 00:00:00 2001
|
|
|
db1822 |
From: Aaron Conole <aconole@redhat.com>
|
|
|
db1822 |
Date: Wed, 25 Aug 2021 10:37:22 -0400
|
|
|
db1822 |
Subject: [PATCH 4/8] 8021Qaz: check for rx block validity
|
|
|
db1822 |
|
|
|
db1822 |
There is a slim but possible race in the 8021Qaz processing when handling
|
|
|
db1822 |
TLVs during ifdown windows. To address this, check for the rx block
|
|
|
db1822 |
before dereferencing it.
|
|
|
db1822 |
|
|
|
db1822 |
closes https://github.com/intel/openlldp/issues/78
|
|
|
db1822 |
Signed-off-by: Aaron Conole <aconole@redhat.com>
|
|
|
db1822 |
---
|
|
|
db1822 |
lldp_8021qaz.c | 41 ++++++++++++++++++++++++++++-------------
|
|
|
db1822 |
1 file changed, 28 insertions(+), 13 deletions(-)
|
|
|
db1822 |
|
|
|
db1822 |
diff --git a/lldp_8021qaz.c b/lldp_8021qaz.c
|
|
|
db1822 |
index 045bd45..8bb2bc9 100644
|
|
|
db1822 |
--- a/lldp_8021qaz.c
|
|
|
db1822 |
+++ b/lldp_8021qaz.c
|
|
|
db1822 |
@@ -1563,48 +1563,63 @@ static bool unpack_ieee8021qaz_tlvs(struct port *port,
|
|
|
db1822 |
/* Process */
|
|
|
db1822 |
switch (tlv->info[OUI_SIZE]) {
|
|
|
db1822 |
case IEEE8021QAZ_ETSCFG_TLV:
|
|
|
db1822 |
- if (tlvs->rx->etscfg == NULL) {
|
|
|
db1822 |
+ if (tlvs->rx && tlvs->rx->etscfg == NULL) {
|
|
|
db1822 |
tlvs->ieee8021qazdu |= RCVD_IEEE8021QAZ_TLV_ETSCFG;
|
|
|
db1822 |
tlvs->rx->etscfg = tlv;
|
|
|
db1822 |
- } else {
|
|
|
db1822 |
+ } else if (tlvs->rx) {
|
|
|
db1822 |
LLDPAD_WARN("%s: %s: 802.1Qaz Duplicate ETSCFG TLV\n",
|
|
|
db1822 |
__func__, port->ifname);
|
|
|
db1822 |
agent->rx.dupTlvs |= DUP_IEEE8021QAZ_TLV_ETSCFG;
|
|
|
db1822 |
return false;
|
|
|
db1822 |
+ } else {
|
|
|
db1822 |
+ LLDPAD_INFO("%s: %s: 802.1Qaz port IFDOWN\n",
|
|
|
db1822 |
+ __func__, port->ifname);
|
|
|
db1822 |
+ return false;
|
|
|
db1822 |
}
|
|
|
db1822 |
break;
|
|
|
db1822 |
case IEEE8021QAZ_ETSREC_TLV:
|
|
|
db1822 |
- if (tlvs->rx->etsrec == NULL) {
|
|
|
db1822 |
+ if (tlvs->rx && tlvs->rx->etsrec == NULL) {
|
|
|
db1822 |
tlvs->ieee8021qazdu |= RCVD_IEEE8021QAZ_TLV_ETSREC;
|
|
|
db1822 |
tlvs->rx->etsrec = tlv;
|
|
|
db1822 |
- } else {
|
|
|
db1822 |
+ } else if (tlvs->rx) {
|
|
|
db1822 |
LLDPAD_WARN("%s: %s: 802.1Qaz Duplicate ETSREC TLV\n",
|
|
|
db1822 |
__func__, port->ifname);
|
|
|
db1822 |
agent->rx.dupTlvs |= DUP_IEEE8021QAZ_TLV_ETSREC;
|
|
|
db1822 |
return false;
|
|
|
db1822 |
+ } else {
|
|
|
db1822 |
+ LLDPAD_INFO("%s: %s: 802.1Qaz port IFDOWN\n",
|
|
|
db1822 |
+ __func__, port->ifname);
|
|
|
db1822 |
+ return false;
|
|
|
db1822 |
}
|
|
|
db1822 |
break;
|
|
|
db1822 |
-
|
|
|
db1822 |
case IEEE8021QAZ_PFC_TLV:
|
|
|
db1822 |
- if (tlvs->rx->pfc == NULL) {
|
|
|
db1822 |
+ if (tlvs->rx && tlvs->rx->pfc == NULL) {
|
|
|
db1822 |
tlvs->ieee8021qazdu |= RCVD_IEEE8021QAZ_TLV_PFC;
|
|
|
db1822 |
tlvs->rx->pfc = tlv;
|
|
|
db1822 |
- } else {
|
|
|
db1822 |
+ } else if (tlvs->rx) {
|
|
|
db1822 |
LLDPAD_WARN("%s: %s: 802.1Qaz Duplicate PFC TLV\n",
|
|
|
db1822 |
__func__, port->ifname);
|
|
|
db1822 |
agent->rx.dupTlvs |= DUP_IEEE8021QAZ_TLV_PFC;
|
|
|
db1822 |
return false;
|
|
|
db1822 |
+ } else {
|
|
|
db1822 |
+ LLDPAD_INFO("%s: %s: 802.1Qaz port IFDOWN\n",
|
|
|
db1822 |
+ __func__, port->ifname);
|
|
|
db1822 |
+ return false;
|
|
|
db1822 |
}
|
|
|
db1822 |
break;
|
|
|
db1822 |
case IEEE8021QAZ_APP_TLV:
|
|
|
db1822 |
- if (tlvs->rx->app == NULL) {
|
|
|
db1822 |
+ if (tlvs->rx && tlvs->rx->app == NULL) {
|
|
|
db1822 |
tlvs->ieee8021qazdu |= RCVD_IEEE8021QAZ_TLV_APP;
|
|
|
db1822 |
tlvs->rx->app = tlv;
|
|
|
db1822 |
- } else {
|
|
|
db1822 |
+ } else if (tlvs->rx) {
|
|
|
db1822 |
LLDPAD_WARN("%s: %s: 802.1Qaz Duplicate APP TLV\n",
|
|
|
db1822 |
__func__, port->ifname);
|
|
|
db1822 |
agent->rx.dupTlvs |= DUP_IEEE8021QAZ_TLV_APP;
|
|
|
db1822 |
return false;
|
|
|
db1822 |
+ } else {
|
|
|
db1822 |
+ LLDPAD_INFO("%s: %s: 802.1Qaz port IFDOWN\n",
|
|
|
db1822 |
+ __func__, port->ifname);
|
|
|
db1822 |
+ return false;
|
|
|
db1822 |
}
|
|
|
db1822 |
break;
|
|
|
db1822 |
default:
|
|
|
db1822 |
@@ -1891,26 +1906,26 @@ static void ieee8021qaz_mibUpdateObjects(struct port *port)
|
|
|
db1822 |
|
|
|
db1822 |
tlvs = ieee8021qaz_data(port->ifname);
|
|
|
db1822 |
|
|
|
db1822 |
- if (tlvs->rx->etscfg) {
|
|
|
db1822 |
+ if (tlvs->rx && tlvs->rx->etscfg) {
|
|
|
db1822 |
process_ieee8021qaz_etscfg_tlv(port);
|
|
|
db1822 |
} else if (tlvs->ets->cfgr) {
|
|
|
db1822 |
free(tlvs->ets->cfgr);
|
|
|
db1822 |
tlvs->ets->cfgr = NULL;
|
|
|
db1822 |
}
|
|
|
db1822 |
|
|
|
db1822 |
- if (tlvs->rx->etsrec) {
|
|
|
db1822 |
+ if (tlvs->rx && tlvs->rx->etsrec) {
|
|
|
db1822 |
process_ieee8021qaz_etsrec_tlv(port);
|
|
|
db1822 |
} else if (tlvs->ets->recr) {
|
|
|
db1822 |
free(tlvs->ets->recr);
|
|
|
db1822 |
tlvs->ets->recr = NULL;
|
|
|
db1822 |
}
|
|
|
db1822 |
|
|
|
db1822 |
- if (tlvs->rx->pfc)
|
|
|
db1822 |
+ if (tlvs->rx && tlvs->rx->pfc)
|
|
|
db1822 |
process_ieee8021qaz_pfc_tlv(port);
|
|
|
db1822 |
else if (tlvs->pfc)
|
|
|
db1822 |
tlvs->pfc->remote_param = false;
|
|
|
db1822 |
|
|
|
db1822 |
- if (tlvs->rx->app)
|
|
|
db1822 |
+ if (tlvs->rx && tlvs->rx->app)
|
|
|
db1822 |
process_ieee8021qaz_app_tlv(port);
|
|
|
db1822 |
else
|
|
|
db1822 |
ieee8021qaz_app_reset(&tlvs->app_head);
|
|
|
db1822 |
--
|
|
|
db1822 |
2.31.1
|
|
|
db1822 |
|