laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/27249 )
Change subject: fix inter-BSC-in handover encryption
......................................................................
fix inter-BSC-in handover encryption
In the field we saw Handover Requests without any Chosen Encryption
Algorithm IE, and osmo-bsc completely failed on those. This made me
understand my mistake from when I wrote this handover code.
So far, from a BSSMAP Handover Request, we (I) used only the Chosen
Encryption Algorithm IE to pick the encryption to use on the target
lchan. That is very wrong.
Instead, figure out the intersection of permitted algorithms MSC & BSC,
and pick the best of those. Which means, actually, completely ignore the
Chosen Encryption Algorithm IE.
In the message, the permitted algorithms are passed as a bitmask. The
current code using gsm0808_dec_encrypt_info() passes this on as an
array. In order to select_best_cipher(), I could convert that array back
to a bitmask. Instead pass the bitmask on from message decoding
alongside the struct gsm0808_encrypt_info in req->ei_as_bitmask.
In handover_end(), change the condition so that we can also pass
HO_RESULT_FAIL_RR_HO_FAIL to emit a Handover Failure.
Related: SYS#5839
Change-Id: Iffedc981b60d309ed2e5decd5efedee07a757b53
---
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/handover_fsm.c
M src/osmo-bsc/osmo_bsc_bssap.c
3 files changed, 26 insertions(+), 8 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 07d141d..4fe97a2 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -270,6 +270,8 @@
struct gsm0808_channel_type ct;
struct gsm0808_speech_codec_list scl;
struct gsm0808_encrypt_info ei;
+ /* The same information as in 'ei' but as the handy bitmask as on the wire. */
+ uint8_t ei_as_bitmask;
bool kc128_present;
uint8_t kc128[16];
struct gsm_classmark classmark;
@@ -1457,4 +1459,6 @@
enum rsl_cmod_spd chan_mode_to_rsl_cmod_spd(enum gsm48_chan_mode chan_mode);
+int select_best_cipher(uint8_t msc_mask, uint8_t bsc_mask);
+
#endif /* _GSM_DATA_H */
diff --git a/src/osmo-bsc/handover_fsm.c b/src/osmo-bsc/handover_fsm.c
index 37e7417..487135b 100644
--- a/src/osmo-bsc/handover_fsm.c
+++ b/src/osmo-bsc/handover_fsm.c
@@ -490,6 +490,7 @@
LOG_HO(conn, LOGL_ERROR, "Failed to parse Encryption Information IE\n");
return false;
}
+ req->ei_as_bitmask = *e->val;
if ((e = TLVP_GET(tp, GSM0808_IE_KC_128))) {
if (e->len != 16) {
@@ -630,6 +631,7 @@
int match_idx;
struct osmo_fsm_inst *fi;
struct channel_mode_and_rate ch_mode_rate = {};
+ int chosen_a5_n;
handover_fsm_alloc(conn);
@@ -717,16 +719,28 @@
.msc_assigned_cic = req->msc_assigned_cic,
};
- if (req->chosen_encr_alg) {
- info.encr.alg_id = req->chosen_encr_alg;
- if (info.encr.alg_id > 1 && !req->ei.key_len) {
- ho_fail(HO_RESULT_ERROR, "Chosen Encryption Algorithm (Serving) reflects A5/%u"
- " but there is no key (Encryption Information)", info.encr.alg_id - 1);
+ /* Figure out the encryption algorithm */
+ chosen_a5_n = select_best_cipher(req->ei_as_bitmask, bsc_gsmnet->a5_encryption_mask);
+ if (chosen_a5_n < 0) {
+ ho_fail(HO_RESULT_FAIL_RR_HO_FAIL,
+ "There is no A5 encryption mode that both BSC and MSC permit: MSC 0x%x & BSC 0x%x = 0\n",
+ req->ei_as_bitmask, bsc_gsmnet->a5_encryption_mask);
+ return;
+ }
+ if (chosen_a5_n > 0 && !req->ei.key_len) {
+ /* There is no key. Is A5/0 permitted? */
+ if ((req->ei_as_bitmask & bsc_gsmnet->a5_encryption_mask & 0x1) == 0x1) {
+ chosen_a5_n = 0;
+ } else {
+ ho_fail(HO_RESULT_ERROR,
+ "Encryption is required, but there is no key (Encryption Information)");
return;
}
}
- if (req->ei.key_len) {
+ /* Put encryption info in the chan activation info */
+ info.encr.alg_id = ALG_A5_NR_TO_RSL(chosen_a5_n);
+ if (chosen_a5_n > 0) {
if (req->ei.key_len > sizeof(info.encr.key)) {
ho_fail(HO_RESULT_ERROR, "Encryption Information IE key length is too large: %u\n",
req->ei.key_len);
@@ -965,7 +979,7 @@
result = bsc_tx_bssmap_ho_complete(conn, ho->new_lchan);
}
/* Not 'else': above checks may still result in HO_RESULT_ERROR. */
- if (result == HO_RESULT_ERROR) {
+ if (result != HO_RESULT_OK) {
/* Return a BSSMAP Handover Failure, as described in 3GPP TS 48.008 3.1.5.2.2
* "Handover Resource Allocation Failure" */
bsc_tx_bssmap_ho_failure(conn);
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index b18627c..8acf293 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -394,7 +394,7 @@
}
/* select the best cipher permitted by the intersection of both masks */
-static int select_best_cipher(uint8_t msc_mask, uint8_t bsc_mask)
+int select_best_cipher(uint8_t msc_mask, uint8_t bsc_mask)
{
/* A5/7 ... A5/3: We assume higher is better,
* but: A5/1 is better than A5/2, which is better than A5/0 */
3 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/27249
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Iffedc981b60d309ed2e5decd5efedee07a757b53
Gerrit-Change-Number: 27249
Gerrit-PatchSet: 4
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
Attention is currently required from: osmith.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/docker-playground/+/27284 )
Change subject: ttcn3-fr-test/jenkins.sh: make use of clean_up()
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/27284
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I4624e37d5d2fa90b71b32d72067b3645f69805da
Gerrit-Change-Number: 27284
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 22 Feb 2022 11:39:18 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/27285 )
Change subject: jobs/ttcn3-testsuites.yml: add ttcn3-fr-test
......................................................................
jobs/ttcn3-testsuites.yml: add ttcn3-fr-test
Add a configuration for the job to the yml file. It looks like this job
was created manually, or the configuration was just not pushed to
gerrit.
This makes e-mail notifications consistent and fixes missing colors in
build output.
Change-Id: I14995dea0a0d223b78e20b49953d5c814c1ad4a1
---
M jobs/ttcn3-testsuites.yml
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/85/27285/1
diff --git a/jobs/ttcn3-testsuites.yml b/jobs/ttcn3-testsuites.yml
index dbf162b..5b915c7 100644
--- a/jobs/ttcn3-testsuites.yml
+++ b/jobs/ttcn3-testsuites.yml
@@ -151,6 +151,10 @@
blocking: "^(ttcn3|TTCN3-.*)-hnbgw-test.*"
timer: 40 13 * * *
disabled: true
+ - ttcn3-fr-test:
+ blocking: "^(ttcn3|TTCN3-.*)-fr-test.*"
+ timer: 40 10 * * *
+ node: hdlc
# debian-stretch latest stable
- nplab-m3ua-test-latest:
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/27285
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I14995dea0a0d223b78e20b49953d5c814c1ad4a1
Gerrit-Change-Number: 27285
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/docker-playground/+/27283 )
Change subject: ttcn3-fr-test/jenkins.sh: revert docker run --rm
......................................................................
ttcn3-fr-test/jenkins.sh: revert docker run --rm
Revert the change of adding a --rm to the "docker run" commands done in
I48b01c43fedf379b8a565eaab0369806d7831bd8.
This script runs the containers in the background, waits until they are
done, copies the logs and then removes them afterwards.
Fix for:
+ docker kill jenkins-ttcn3-fr-test-384-frnet
jenkins-ttcn3-fr-test-384-frnet
+ docker logs --timestamps jenkins-ttcn3-fr-test-384-ttcn3-fr-test
Error: No such container: jenkins-ttcn3-fr-test-384-ttcn3-fr-test
Change-Id: I56dc07820ccfa8ad6936764262a7c6c272e59c37
---
M ttcn3-fr-test/jenkins.sh
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/83/27283/1
diff --git a/ttcn3-fr-test/jenkins.sh b/ttcn3-fr-test/jenkins.sh
index 34aa740..4531e3a 100755
--- a/ttcn3-fr-test/jenkins.sh
+++ b/ttcn3-fr-test/jenkins.sh
@@ -25,7 +25,7 @@
echo Starting container with FRNET
docker run \
- --rm \
+ `# --rm is done in below` \
--cap-add=NET_RAW --cap-add=SYS_RAWIO \
$(docker_network_params $SUBNET 10) \
--ulimit core=-1 \
@@ -45,7 +45,7 @@
echo Starting container with FR testsuite
docker run \
- --rm \
+ `# --rm is done in below` \
--cap-add=NET_RAW --cap-add=SYS_RAWIO \
$(docker_network_params $SUBNET 103) \
--ulimit core=-1 \
--
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/27283
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I56dc07820ccfa8ad6936764262a7c6c272e59c37
Gerrit-Change-Number: 27283
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/docker-playground/+/27284 )
Change subject: ttcn3-fr-test/jenkins.sh: make use of clean_up()
......................................................................
ttcn3-fr-test/jenkins.sh: make use of clean_up()
Move cleaning up logic to clean_up(), so it runs as part of the
clean_up_trap if any command in the previous code fails.
For example, if the first docker container started properly, but the
second docker container failed to start: without this patch, it would
just stop the script without running the clean up code.
Change-Id: I4624e37d5d2fa90b71b32d72067b3645f69805da
---
M ttcn3-fr-test/jenkins.sh
1 file changed, 12 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/84/27284/1
diff --git a/ttcn3-fr-test/jenkins.sh b/ttcn3-fr-test/jenkins.sh
index 4531e3a..182f512 100755
--- a/ttcn3-fr-test/jenkins.sh
+++ b/ttcn3-fr-test/jenkins.sh
@@ -8,6 +8,16 @@
set_clean_up_trap
set -e
+clean_up() {
+ # kill the frnet container to avoid "You cannot remove a running container " below in 'rm'
+ docker kill ${BUILD_TAG}-frnet || true
+
+ # store execution logs for both containers
+ docker logs --timestamps ${BUILD_TAG}-ttcn3-fr-test > $VOL_BASE_DIR/fr-tester/exec.log || true
+ docker logs --timestamps ${BUILD_TAG}-frnet > $VOL_BASE_DIR/frnet/exec.log || true
+ docker container rm ${BUILD_TAG}-frnet ${BUILD_TAG}-ttcn3-fr-test
+}
+
SUBNET=26
network_create $SUBNET
@@ -25,7 +35,7 @@
echo Starting container with FRNET
docker run \
- `# --rm is done in below` \
+ `# --rm is done in clean_up()` \
--cap-add=NET_RAW --cap-add=SYS_RAWIO \
$(docker_network_params $SUBNET 10) \
--ulimit core=-1 \
@@ -45,7 +55,7 @@
echo Starting container with FR testsuite
docker run \
- `# --rm is done in below` \
+ `# --rm is done in clean_up()` \
--cap-add=NET_RAW --cap-add=SYS_RAWIO \
$(docker_network_params $SUBNET 103) \
--ulimit core=-1 \
@@ -66,10 +76,3 @@
# emulate running container in foreground, which is no longer possible as we
# must shift the net-devices into the container _after_ it is started
docker logs -f ${BUILD_TAG}-ttcn3-fr-test
-# kill the frnet container to avoid "You cannot remove a running container " below in 'rm'
-docker kill ${BUILD_TAG}-frnet
-
-# store execution logs for both containers
-docker logs --timestamps ${BUILD_TAG}-ttcn3-fr-test > $VOL_BASE_DIR/fr-tester/exec.log
-docker logs --timestamps ${BUILD_TAG}-frnet > $VOL_BASE_DIR/frnet/exec.log
-docker container rm ${BUILD_TAG}-frnet ${BUILD_TAG}-ttcn3-fr-test
--
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/27284
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I4624e37d5d2fa90b71b32d72067b3645f69805da
Gerrit-Change-Number: 27284
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange