From 44616a6a19a8d707dd03fa90f656c9a72aa03549 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 21 Oct 2024 11:01:47 +0200 Subject: [PATCH] nr_psbchsim: fix segv by providing correct get_nrUE_params() When running, nr_psbchsim, we get this UBsan error: openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c:79:16: runtime error: member access within misaligned address 0x0ff4278c791c for type 'struct nrUE_params_t', which requires 8 byte alignment The problem is that the corresponding definition of get_nrUE_params() in psbchsim.c does not actually return the UE params, but void, so we might or might not get something that resembles valid data in nr_adjust_synch_ue.c. Fix this by including nr-uesoftmodem.h (that provides the correct declaration) and define it correctly. Due to type mismatches, also adapt downlink_frequency, uplink_frequency_offset, and openair_cfg (which might result in the same type of bugs). --- openair1/SIMULATION/NR_PHY/psbchsim.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/psbchsim.c b/openair1/SIMULATION/NR_PHY/psbchsim.c index 684ed6d783..ebec49a139 100644 --- a/openair1/SIMULATION/NR_PHY/psbchsim.c +++ b/openair1/SIMULATION/NR_PHY/psbchsim.c @@ -25,6 +25,7 @@ #include "common/utils/load_module_shlib.h" #include "PHY/MODULATION/nr_modulation.h" #include "NR_SL-SSB-TimeAllocation-r16.h" +#include "nr-uesoftmodem.h" void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req) { @@ -54,12 +55,13 @@ double cpuf; void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu, uint8_t *nb_dmrs_re_per_rb, uint16_t *number_dmrs_symbols) { } -uint64_t downlink_frequency[1][1]; -int32_t uplink_frequency_offset[1][1]; + +uint64_t downlink_frequency[MAX_NUM_CCs][4]; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; THREAD_STRUCT thread_struct; instance_t DUuniqInstance = 0; instance_t CUuniqInstance = 0; -openair0_config_t openair0_cfg[1]; +openair0_config_t openair0_cfg[MAX_CARDS]; RAN_CONTEXT_t RC; int oai_exit = 0; @@ -80,9 +82,11 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, return 0; } -void get_nrUE_params(void) +nrUE_params_t nrUE_params = {0}; + +nrUE_params_t *get_nrUE_params(void) { - return; + return &nrUE_params; } uint8_t check_if_ue_is_sl_syncsource() {