ionic: Add robust udata support and zero-initialize udata structs Read the IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA flag from core_support into ctx->robust_udata during context allocation. This allows the provider to detect whether the kernel supports forward/backward compatible udata handling, which is a prerequisite for safely using extended request structs in future verb extensions. Also zero-initialize uionic_qp, uionic_qp_resp, and uionic_ah_resp stack variables to prevent stack garbage from leaking into the kernel via ioctl buffers. Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
diff --git a/providers/ionic/ionic.c b/providers/ionic/ionic.c index 6451aab..17b27c0 100644 --- a/providers/ionic/ionic.c +++ b/providers/ionic/ionic.c
@@ -78,6 +78,9 @@ ctx->sq_expdb = !!(resp.expdb_qtypes & IONIC_EXPDB_SQ); ctx->rq_expdb = !!(resp.expdb_qtypes & IONIC_EXPDB_RQ); + ctx->robust_udata = !!(verbs_get_device(ibdev)->core_support & + IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA); + mask = (1u << ctx->pg_shift) - 1; ctx->dbpage_page = ionic_map_device(1u << ctx->pg_shift, cmd_fd, resp.dbell_offset & ~mask);
diff --git a/providers/ionic/ionic.h b/providers/ionic/ionic.h index cb1a8da..e556df3 100644 --- a/providers/ionic/ionic.h +++ b/providers/ionic/ionic.h
@@ -102,6 +102,7 @@ uint8_t expdb_mask; bool sq_expdb; bool rq_expdb; + bool robust_udata; void *dbpage_page; uint64_t *dbpage;
diff --git a/providers/ionic/ionic_verbs.c b/providers/ionic/ionic_verbs.c index 1aa08f5..1159cec 100644 --- a/providers/ionic/ionic_verbs.c +++ b/providers/ionic/ionic_verbs.c
@@ -2140,8 +2140,8 @@ { struct ionic_ctx *ctx = to_ionic_ctx(ibctx); struct ionic_pd *pd = to_ionic_pd(ex->pd); - struct uionic_qp_resp resp; - struct uionic_qp req; + struct uionic_qp_resp resp = {}; + struct uionic_qp req = {}; struct ionic_qp *qp; struct ionic_cq *cq; int rc; @@ -3386,7 +3386,7 @@ struct ibv_ah_attr *attr) { struct ibv_pd *root_ibpd = to_ionic_root_ibpd(ibpd); - struct uionic_ah_resp resp; + struct uionic_ah_resp resp = {}; struct ionic_ah *ah; int rc;