* [bug report] octeontx2-af: Drop rules for NPC MCAM
@ 2022-07-13 11:32 Dan Carpenter
2022-07-14 3:25 ` [EXT] " Ratheesh Kannoth
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2022-07-13 11:32 UTC (permalink / raw)
To: rkannoth; +Cc: kernel-janitors
Hello Ratheesh Kannoth,
The patch 3571fe07a090: "octeontx2-af: Drop rules for NPC MCAM" from
Jul 8, 2022, leads to the following Smatch static checker warning:
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1964 rvu_npc_exact_init()
error: uninitialized symbol 'err'.
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
1953
1954 dev_dbg(rvu->dev,
1955 "%s:Drop rule cgx=%d lmac=%d chan(val=0x%llx, mask=0x%llx\n",
1956 __func__, cgx_id, lmac_id, chan_val, chan_mask);
1957
1958 rc = rvu_npc_exact_save_drop_rule_chan_and_mask(rvu, table->num_drop_rules,
1959 chan_val, chan_mask, pcifunc);
1960 if (!rc) {
1961 dev_err(rvu->dev,
1962 "%s: failed to set drop info for cgx=%d, lmac=%d, chan=%llx\n",
1963 __func__, cgx_id, lmac_id, chan_val);
--> 1964 return err;
"err" is uninitialized. This should be return -EINVAL or something.
Let me just send the whole list. The rest are mostly caused by no
error checking. It's possibly deliberate. Hard to tell without knowing
the subsystem more deeply.
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1232 rvu_npc_exact_del_table_entry_by_id() error: uninitialized symbol 'drop_mcam_idx'.
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1312 rvu_npc_exact_add_table_entry() error: uninitialized symbol 'drop_mcam_idx'.
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1391 rvu_npc_exact_update_table_entry() error: uninitialized symbol 'hash_index'.
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1428 rvu_npc_exact_promisc_disable() error: uninitialized symbol 'drop_mcam_idx'.
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1473 rvu_npc_exact_promisc_enable() error: uninitialized symbol 'drop_mcam_idx'.
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1964 rvu_npc_exact_init() error: uninitialized symbol 'err'.
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h:735 otx2_mbox_alloc_msg_npc_get_secret_key() warn: struct type mismatch 'mbox_msghdr vs npc_get_secret_key_req'
drivers/net/ethernet/marvell/octeontx2/nic/otx2_dmac_flt.c:191 otx2_dmacflt_update() error: 'rsp' dereferencing possible ERR_PTR()
drivers/net/ethernet/marvell/octeontx2/nic/otx2_dmac_flt.c:60 otx2_dmacflt_add_pfmac() error: 'rsp' dereferencing possible ERR_PTR()
1965 }
1966
1967 err = npc_install_mcam_drop_rule(rvu, *drop_mcam_idx,
1968 &table->counter_idx[*drop_mcam_idx],
1969 chan_val, chan_mask,
1970 exact_val, exact_mask,
1971 bcast_mcast_val, bcast_mcast_mask);
1972 if (err) {
1973 dev_err(rvu->dev,
1974 "failed to configure drop rule (cgx=%d lmac=%d)\n",
1975 cgx_id, lmac_id);
1976 return err;
1977 }
1978
1979 (*drop_mcam_idx)++;
1980 }
1981
1982 dev_info(rvu->dev, "initialized exact match table successfully\n");
1983 return 0;
1984 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [EXT] [bug report] octeontx2-af: Drop rules for NPC MCAM
2022-07-13 11:32 [bug report] octeontx2-af: Drop rules for NPC MCAM Dan Carpenter
@ 2022-07-14 3:25 ` Ratheesh Kannoth
2022-07-14 9:55 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Ratheesh Kannoth @ 2022-07-14 3:25 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kernel-janitors
>-----Original Message-----
>From: Dan Carpenter <dan.carpenter@oracle.com>
>Sent: Wednesday, July 13, 2022 5:02 PM
>To: Ratheesh Kannoth <rkannoth@marvell.com>
>Cc: kernel-janitors@vger.kernel.org
>Subject: [EXT] [bug report] octeontx2-af: Drop rules for NPC MCAM
>External Email
----------------------------------------------------------------------
>Hello Ratheesh Kannoth,
>The patch 3571fe07a090: "octeontx2-af: Drop rules for NPC MCAM" from Jul 8, 2022, leads to the following Smatch static checker warning:
Dan,
Thanks !!
I tried to run smatch tool and could not see any of these errors ? Am I missing any step ?
===
./smatch-master/smatch_scripts/kchecker drivers/net/ethernet/marvell/octeontx2/
CHECK drivers/net/ethernet/marvell/octeontx2/af/rvu_sdp.c
CC drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.o
CHECK drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
AR drivers/net/ethernet/marvell/octeontx2/af/built-in.a
CHECK drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
CHECK drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
====
>drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1964 rvu_npc_exact_init()
>error: uninitialized symbol 'err'.
>drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
> 1953
> 1954 dev_dbg(rvu->dev,
> 1955 "%s:Drop rule cgx=%d lmac=%d chan(val=0x%llx, mask=0x%llx\n",
> 1956 __func__, cgx_id, lmac_id, chan_val, chan_mask);
> 1957
> 1958 rc = rvu_npc_exact_save_drop_rule_chan_and_mask(rvu, table->num_drop_rules,
> 1959 chan_val, chan_mask, pcifunc);
> 1960 if (!rc) {
> 1961 dev_err(rvu->dev,
> 1962 "%s: failed to set drop info for cgx=%d, lmac=%d, chan=%llx\n",
> 1963 __func__, cgx_id, lmac_id, chan_val);
--> 1964 return err;
>"err" is uninitialized. This should be return -EINVAL or something.
Fixed by 6a605eb1d71ea8cec50bdf7151c772c599a5fb70 commit.
>Let me just send the whole list. The rest are mostly caused by no error checking. It's possibly deliberate. Hard to tell without knowing the subsystem more deeply.
>drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1232 rvu_npc_exact_del_table_entry_by_id() error: uninitialized symbol 'drop_mcam_idx'.
>drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1312 rvu_npc_exact_add_table_entry() error: uninitialized symbol 'drop_mcam_idx'.
>drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1391 rvu_npc_exact_update_table_entry() error: uninitialized symbol 'hash_index'.
>drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1428 rvu_npc_exact_promisc_disable() error: uninitialized symbol 'drop_mcam_idx'.
>drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1473 rvu_npc_exact_promisc_enable() error: uninitialized symbol 'drop_mcam_idx'.
Will fix and post patch.
>drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1964 rvu_npc_exact_init() error: uninitialized symbol 'err'.
Fixed by 6a605eb1d71ea8cec50bdf7151c772c599a5fb70 commit.
>drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h:735 otx2_mbox_alloc_msg_npc_get_secret_key() warn: struct type mismatch 'mbox_msghdr vs npc_get_secret_key_req'
I don't see any issue in the code.
>drivers/net/ethernet/marvell/octeontx2/nic/otx2_dmac_flt.c:191 otx2_dmacflt_update() error: 'rsp' dereferencing possible ERR_PTR()
>drivers/net/ethernet/marvell/octeontx2/nic/otx2_dmac_flt.c:60 otx2_dmacflt_add_pfmac() error: 'rsp' dereferencing possible ERR_PTR()
Fixed. Will post new patch.
1965 }
1966
1967 err = npc_install_mcam_drop_rule(rvu, *drop_mcam_idx,
1968 &table->counter_idx[*drop_mcam_idx],
1969 chan_val, chan_mask,
1970 exact_val, exact_mask,
1971 bcast_mcast_val, bcast_mcast_mask);
1972 if (err) {
1973 dev_err(rvu->dev,
1974 "failed to configure drop rule (cgx=%d lmac=%d)\n",
1975 cgx_id, lmac_id);
1976 return err;
1977 }
1978
1979 (*drop_mcam_idx)++;
1980 }
1981
1982 dev_info(rvu->dev, "initialized exact match table successfully\n");
1983 return 0;
1984 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [EXT] [bug report] octeontx2-af: Drop rules for NPC MCAM
2022-07-14 3:25 ` [EXT] " Ratheesh Kannoth
@ 2022-07-14 9:55 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2022-07-14 9:55 UTC (permalink / raw)
To: Ratheesh Kannoth; +Cc: kernel-janitors
On Thu, Jul 14, 2022 at 03:25:02AM +0000, Ratheesh Kannoth wrote:
> Dan,
> Thanks !!
>
> I tried to run smatch tool and could not see any of these errors ? Am I missing any step ?
> ===
> ./smatch-master/smatch_scripts/kchecker drivers/net/ethernet/marvell/octeontx2/
>
> CHECK drivers/net/ethernet/marvell/octeontx2/af/rvu_sdp.c
> CC drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.o
> CHECK drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
> AR drivers/net/ethernet/marvell/octeontx2/af/built-in.a
> CHECK drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
> CHECK drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
Hm... To see those warnings then you need the cross function DB enabled.
It takes forever (over night) to build.
./smatch-master/smatch_scripts/build_kernel_data.sh
>
> >drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h:735 otx2_mbox_alloc_msg_npc_get_secret_key() warn: struct type mismatch 'mbox_msghdr vs npc_get_secret_key_req'
> I don't see any issue in the code.
>
Sorry, this is unpublished Smatch code which was buggy. I have fixed
it now.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* [bug report] octeontx2-af: Drop rules for NPC MCAM
@ 2022-07-13 11:27 Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2022-07-13 11:27 UTC (permalink / raw)
To: rkannoth; +Cc: kernel-janitors
Hello Ratheesh Kannoth,
The patch 3571fe07a090: "octeontx2-af: Drop rules for NPC MCAM" from
Jul 8, 2022, leads to the following Smatch static checker warning:
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1232 rvu_npc_exact_del_table_entry_by_id()
error: uninitialized symbol 'drop_mcam_idx'.
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
1199 static int rvu_npc_exact_del_table_entry_by_id(struct rvu *rvu, u32 seq_id)
1200 {
1201 struct npc_exact_table_entry *entry = NULL;
1202 struct npc_exact_table *table;
1203 bool disable_cam = false;
1204 u32 drop_mcam_idx;
1205 int *cnt;
1206
1207 table = rvu->hw->table;
1208
1209 mutex_lock(&table->lock);
1210
1211 /* Lookup for entry which needs to be updated */
1212 entry = __rvu_npc_exact_find_entry_by_seq_id(rvu, seq_id);
1213 if (!entry) {
1214 dev_dbg(rvu->dev, "%s: failed to find entry for id=0x%x\n", __func__, seq_id);
1215 mutex_unlock(&table->lock);
1216 return -ENODATA;
1217 }
1218
1219 cnt = (entry->opc_type == NPC_EXACT_OPC_CAM) ? &table->cam_tbl_entry_cnt :
1220 &table->mem_tbl_entry_cnt;
1221
1222 /* delete from lists */
1223 list_del_init(&entry->list);
1224 list_del_init(&entry->glist);
1225
1226 (*cnt)--;
1227
1228 rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, entry->cgx_id, entry->lmac_id,
1229 &drop_mcam_idx, NULL, NULL, NULL);
No checks for errors
1230
1231 if (entry->cmd)
--> 1232 __rvu_npc_exact_cmd_rules_cnt_update(rvu, drop_mcam_idx, -1, &disable_cam);
Uninitialized value leads to out of bounds access
1233
1234 /* No dmac filter rules; disable drop on hit rule */
1235 if (disable_cam) {
1236 rvu_npc_enable_mcam_by_entry_index(rvu, drop_mcam_idx, NIX_INTF_RX, false);
1237 dev_dbg(rvu->dev, "%s: Disabling mcam idx %d\n",
1238 __func__, drop_mcam_idx);
1239 }
1240
1241 mutex_unlock(&table->lock);
1242
1243 rvu_npc_exact_dealloc_table_entry(rvu, entry->opc_type, entry->ways, entry->index);
1244
1245 rvu_npc_exact_free_id(rvu, seq_id);
1246
1247 dev_dbg(rvu->dev, "%s: delete entry success for id=0x%x, mca=%pM\n",
1248 __func__, seq_id, entry->mac);
1249 kfree(entry);
1250
1251 return 0;
1252 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-14 9:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 11:32 [bug report] octeontx2-af: Drop rules for NPC MCAM Dan Carpenter
2022-07-14 3:25 ` [EXT] " Ratheesh Kannoth
2022-07-14 9:55 ` Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2022-07-13 11:27 Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.