diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2018-07-07 21:51:09 +0100 |
---|---|---|
committer | Holger Freyther <holger@freyther.de> | 2018-07-11 21:13:11 +0000 |
commit | 6d49b049ee304f1ea0e4801df61e69713b01f0f8 (patch) | |
tree | 3ffca58aced050916dc0f4d6c62c7a6354aa53b9 /src/host/layer23/src/mobile/gsm48_mm.c | |
parent | c36dc296321af23b171903fd0ad3cf8d7e552ab2 (diff) |
Move from libc random() to osmo_get_rand_id
When starting multiple mobile in the same second, the libc random number
generator will be seeded to exactly the same value.
The random bits inside the RACH request(s) will be exactly the same
across multiple mobile and when the channel fails they all pick the same
randomized back-off timing.
Use stronger random numbers and replace all calls to random(2) with
osmo_get_rand_id. Add a fallback to try random().
Change-Id: Ie0cc64663cd4b90c027b79545dc5d3ac9d87b9dd
Diffstat (limited to 'src/host/layer23/src/mobile/gsm48_mm.c')
-rw-r--r-- | src/host/layer23/src/mobile/gsm48_mm.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/host/layer23/src/mobile/gsm48_mm.c b/src/host/layer23/src/mobile/gsm48_mm.c index a7af1f5c..a36e7e86 100644 --- a/src/host/layer23/src/mobile/gsm48_mm.c +++ b/src/host/layer23/src/mobile/gsm48_mm.c @@ -30,6 +30,7 @@ #include <osmocom/core/utils.h> #include <osmocom/gsm/gsm48.h> #include <osmocom/core/talloc.h> +#include <osmocom/gsm/gsm_utils.h> #include <osmocom/bb/common/logging.h> #include <osmocom/bb/common/osmocom_data.h> @@ -2099,7 +2100,9 @@ static int gsm48_mm_sysinfo(struct osmocom_ms *ms, struct msgb *msg) mm->t3212.timeout.tv_sec = current_time.tv_sec + (t % s->t3212); } else { - uint32_t rand = random(); + uint32_t rand; + if (osmo_get_rand_id((uint8_t *) &rand, sizeof(rand)) != 0) + rand = random(); LOGP(DMM, LOGL_INFO, "New T3212 while timer is not " "running (value %d)\n", s->t3212); |