|
|
7aef00 |
diff -Naur libreswan-4.3-orig/programs/pluto/connections.c libreswan-4.3/programs/pluto/connections.c
|
|
|
7aef00 |
--- libreswan-4.3-orig/programs/pluto/connections.c 2021-02-21 12:03:03.000000000 -0500
|
|
|
7aef00 |
+++ libreswan-4.3/programs/pluto/connections.c 2021-02-24 16:28:05.608119041 -0500
|
|
|
7aef00 |
@@ -2475,9 +2475,8 @@
|
|
|
7aef00 |
endpoint_in_selector(local_client, &sr->this.client) &&
|
|
|
7aef00 |
endpoint_in_selector(remote_client, &sr->that.client)
|
|
|
7aef00 |
#ifdef HAVE_LABELED_IPSEC
|
|
|
7aef00 |
- && ((sec_label.ptr == NULL &&
|
|
|
7aef00 |
- sr->this.sec_label.ptr == NULL) ||
|
|
|
7aef00 |
- /* don't call with NULL, it confuses it */
|
|
|
7aef00 |
+ && ((sec_label.ptr == NULL && sr->this.sec_label.ptr == NULL) ||
|
|
|
7aef00 |
+ hunk_eq(sec_label, sr->this.sec_label) ||
|
|
|
7aef00 |
within_range((const char *)sec_label.ptr,
|
|
|
7aef00 |
(const char *)sr->this.sec_label.ptr, logger))
|
|
|
7aef00 |
#endif
|
|
|
7aef00 |
diff -Naur libreswan-4.3-orig/programs/pluto/ikev1_spdb_struct.c libreswan-4.3/programs/pluto/ikev1_spdb_struct.c
|
|
|
7aef00 |
--- libreswan-4.3-orig/programs/pluto/ikev1_spdb_struct.c 2021-02-21 12:03:03.000000000 -0500
|
|
|
7aef00 |
+++ libreswan-4.3/programs/pluto/ikev1_spdb_struct.c 2021-02-24 16:28:59.819791102 -0500
|
|
|
7aef00 |
@@ -113,7 +113,9 @@
|
|
|
7aef00 |
return false;
|
|
|
7aef00 |
}
|
|
|
7aef00 |
|
|
|
7aef00 |
- if (!within_range(sec_label.ptr, /* we ensured NUL termination above */
|
|
|
7aef00 |
+
|
|
|
7aef00 |
+ if (!hunk_eq(sec_label, c->spd.this.sec_label) &&
|
|
|
7aef00 |
+ !within_range(sec_label.ptr, /* we ensured NUL termination above */
|
|
|
7aef00 |
(const char *)c->spd.this.sec_label.ptr, /* we ensured NUL termination earlier? */
|
|
|
7aef00 |
st->st_logger)) {
|
|
|
7aef00 |
LLOG_JAMBUF(RC_LOG_SERIOUS, st->st_logger, buf) {
|
|
|
7aef00 |
diff -Naur libreswan-4.3-orig/programs/pluto/ikev2_ts.c libreswan-4.3/programs/pluto/ikev2_ts.c
|
|
|
7aef00 |
--- libreswan-4.3-orig/programs/pluto/ikev2_ts.c 2021-02-21 12:03:03.000000000 -0500
|
|
|
7aef00 |
+++ libreswan-4.3/programs/pluto/ikev2_ts.c 2021-02-24 16:30:19.639780631 -0500
|
|
|
7aef00 |
@@ -862,7 +862,8 @@
|
|
|
7aef00 |
}
|
|
|
7aef00 |
|
|
|
7aef00 |
#ifdef HAVE_LABELED_IPSEC
|
|
|
7aef00 |
-static bool score_ends_seclabel(const struct ends *ends,
|
|
|
7aef00 |
+static bool score_ends_seclabel(const chunk_t **selected_sec_label,
|
|
|
7aef00 |
+ const struct ends *ends,
|
|
|
7aef00 |
const struct connection *d,
|
|
|
7aef00 |
const struct traffic_selectors *tsi,
|
|
|
7aef00 |
const struct traffic_selectors *tsr,
|
|
|
7aef00 |
@@ -875,6 +876,10 @@
|
|
|
7aef00 |
bool match_i = false;
|
|
|
7aef00 |
bool match_r = false;
|
|
|
7aef00 |
|
|
|
7aef00 |
+ if (selected_sec_label != NULL) {
|
|
|
7aef00 |
+ *selected_sec_label = NULL;
|
|
|
7aef00 |
+ }
|
|
|
7aef00 |
+
|
|
|
7aef00 |
for (unsigned tsi_n = 0; tsi_n < tsi->nr; tsi_n++) {
|
|
|
7aef00 |
const struct traffic_selector *cur = &tsi->ts[tsi_n];
|
|
|
7aef00 |
if (cur->ts_type == IKEv2_TS_SECLABEL) {
|
|
|
7aef00 |
@@ -883,7 +888,8 @@
|
|
|
7aef00 |
// complain loudly
|
|
|
7aef00 |
continue;
|
|
|
7aef00 |
} else {
|
|
|
7aef00 |
- if (within_range((const char *)cur->sec_label.ptr, (const char *)d->spd.this.sec_label.ptr, logger)) {
|
|
|
7aef00 |
+ if (hunk_eq(cur->sec_label, d->spd.this.sec_label) ||
|
|
|
7aef00 |
+ within_range((const char *)cur->sec_label.ptr, (const char *)d->spd.this.sec_label.ptr, logger)) {
|
|
|
7aef00 |
match_i = true;
|
|
|
7aef00 |
dbg("ikev2ts #1: received label within range of our security label");
|
|
|
7aef00 |
} else {
|
|
|
7aef00 |
@@ -902,9 +908,13 @@
|
|
|
7aef00 |
dbg("IKEv2_TS_SECLABEL but zero length cur->sec_label");
|
|
|
7aef00 |
continue;
|
|
|
7aef00 |
} else {
|
|
|
7aef00 |
- if (within_range((const char *)ends->r->sec_label.ptr, (const char *)d->spd.this.sec_label.ptr, logger)) {
|
|
|
7aef00 |
+ if (hunk_eq(ends->r->sec_label, d->spd.this.sec_label) ||
|
|
|
7aef00 |
+ within_range((const char *)ends->r->sec_label.ptr, (const char *)d->spd.this.sec_label.ptr, logger)) {
|
|
|
7aef00 |
dbg("ikev2ts #2: received label within range of our security label");
|
|
|
7aef00 |
match_r = true;
|
|
|
7aef00 |
+ if (selected_sec_label != NULL) {
|
|
|
7aef00 |
+ *selected_sec_label = &cur->sec_label;
|
|
|
7aef00 |
+ }
|
|
|
7aef00 |
} else {
|
|
|
7aef00 |
dbg("ikev2ts #2: received label not within range of our security label");
|
|
|
7aef00 |
DBG_dump_hunk("ends->r->sec_label", ends->r->sec_label);
|
|
|
7aef00 |
@@ -926,7 +936,8 @@
|
|
|
7aef00 |
return require_label == recv_label_i && match_i && match_r;
|
|
|
7aef00 |
}
|
|
|
7aef00 |
#else
|
|
|
7aef00 |
-static bool score_ends_seclabel(const struct ends *ends UNUSED,
|
|
|
7aef00 |
+static bool score_ends_seclabel(const chunk_t **selected_sec_label,
|
|
|
7aef00 |
+ const struct ends *ends UNUSED,
|
|
|
7aef00 |
const struct connection *d UNUSED,
|
|
|
7aef00 |
const struct traffic_selectors *tsi UNUSED,
|
|
|
7aef00 |
const struct traffic_selectors *tsr UNUSED,
|
|
|
7aef00 |
@@ -1030,6 +1041,7 @@
|
|
|
7aef00 |
struct best_score best_score = NO_SCORE;
|
|
|
7aef00 |
const struct spd_route *best_spd_route = NULL;
|
|
|
7aef00 |
struct connection *best_connection = c;
|
|
|
7aef00 |
+ const chunk_t *best_sec_label = NULL;
|
|
|
7aef00 |
|
|
|
7aef00 |
/* find best spd in c */
|
|
|
7aef00 |
|
|
|
7aef00 |
@@ -1042,7 +1054,8 @@
|
|
|
7aef00 |
.r = &sra->this,
|
|
|
7aef00 |
};
|
|
|
7aef00 |
|
|
|
7aef00 |
- if (!score_ends_seclabel(&ends, c, &tsi, &tsr, child->sa.st_logger)) {
|
|
|
7aef00 |
+ const chunk_t* selected_sec_label = NULL;
|
|
|
7aef00 |
+ if (!score_ends_seclabel(&selected_sec_label, &ends, c, &tsi, &tsr, child->sa.st_logger)) {
|
|
|
7aef00 |
continue;
|
|
|
7aef00 |
}
|
|
|
7aef00 |
|
|
|
7aef00 |
@@ -1060,6 +1073,7 @@
|
|
|
7aef00 |
score.tsi - tsi.ts, score.tsr - tsr.ts);
|
|
|
7aef00 |
best_score = score;
|
|
|
7aef00 |
best_spd_route = sra;
|
|
|
7aef00 |
+ best_sec_label = selected_sec_label;
|
|
|
7aef00 |
passert(best_connection == c);
|
|
|
7aef00 |
}
|
|
|
7aef00 |
}
|
|
|
7aef00 |
@@ -1143,7 +1157,8 @@
|
|
|
7aef00 |
? END_NARROWER_THAN_TS
|
|
|
7aef00 |
: END_EQUALS_TS;
|
|
|
7aef00 |
|
|
|
7aef00 |
- if (!score_ends_seclabel(&ends, d, &tsi, &tsr,
|
|
|
7aef00 |
+ const chunk_t* selected_sec_label = NULL;
|
|
|
7aef00 |
+ if (!score_ends_seclabel(&selected_sec_label, &ends, d, &tsi, &tsr,
|
|
|
7aef00 |
child->sa.st_logger))
|
|
|
7aef00 |
continue;
|
|
|
7aef00 |
|
|
|
7aef00 |
@@ -1159,6 +1174,7 @@
|
|
|
7aef00 |
best_connection = d;
|
|
|
7aef00 |
best_score = score;
|
|
|
7aef00 |
best_spd_route = sr;
|
|
|
7aef00 |
+ best_sec_label = selected_sec_label;
|
|
|
7aef00 |
}
|
|
|
7aef00 |
}
|
|
|
7aef00 |
}
|
|
|
7aef00 |
@@ -1389,6 +1405,13 @@
|
|
|
7aef00 |
*/
|
|
|
7aef00 |
update_state_connection(&child->sa, best_connection);
|
|
|
7aef00 |
|
|
|
7aef00 |
+ if (best_sec_label != NULL) {
|
|
|
7aef00 |
+ if (child->sa.st_seen_sec_label.len != 0) {
|
|
|
7aef00 |
+ free_chunk_content(&child->sa.st_seen_sec_label);
|
|
|
7aef00 |
+ }
|
|
|
7aef00 |
+ child->sa.st_seen_sec_label = clone_hunk(*best_sec_label, "st_seen_sec_label");
|
|
|
7aef00 |
+ }
|
|
|
7aef00 |
+
|
|
|
7aef00 |
child->sa.st_ts_this = ikev2_end_to_ts(&best_spd_route->this, child->sa.st_acquired_sec_label);
|
|
|
7aef00 |
child->sa.st_ts_that = ikev2_end_to_ts(&best_spd_route->that, child->sa.st_seen_sec_label);
|
|
|
7aef00 |
|
|
|
7aef00 |
@@ -1424,7 +1447,8 @@
|
|
|
7aef00 |
? END_WIDER_THAN_TS
|
|
|
7aef00 |
: END_EQUALS_TS;
|
|
|
7aef00 |
|
|
|
7aef00 |
- if (!score_ends_seclabel(&e, c, &tsi, &tsr, child->sa.st_logger))
|
|
|
7aef00 |
+ const chunk_t *selected_sec_label = NULL;
|
|
|
7aef00 |
+ if (!score_ends_seclabel(&selected_sec_label, &e, c, &tsi, &tsr, child->sa.st_logger))
|
|
|
7aef00 |
return false;
|
|
|
7aef00 |
|
|
|
7aef00 |
struct best_score best = score_ends_iprange(initiator_widening, c, &e, &tsi, &tsr;;
|
|
|
7aef00 |
@@ -1435,6 +1459,13 @@
|
|
|
7aef00 |
return false;
|
|
|
7aef00 |
}
|
|
|
7aef00 |
|
|
|
7aef00 |
+ if (selected_sec_label != NULL) {
|
|
|
7aef00 |
+ if (child->sa.st_seen_sec_label.len != 0) {
|
|
|
7aef00 |
+ free_chunk_content(&child->sa.st_seen_sec_label);
|
|
|
7aef00 |
+ }
|
|
|
7aef00 |
+ child->sa.st_seen_sec_label = clone_hunk(*selected_sec_label, "st_seen_sec_label");
|
|
|
7aef00 |
+ }
|
|
|
7aef00 |
+
|
|
|
7aef00 |
/* XXX: check conversions */
|
|
|
7aef00 |
dbg("initiator saving acceptable TSi response in this");
|
|
|
7aef00 |
ts_to_end(best.tsi, &c->spd.this, &child->sa.st_ts_this);
|
|
|
7aef00 |
@@ -1489,7 +1520,7 @@
|
|
|
7aef00 |
|
|
|
7aef00 |
enum fit fitness = END_NARROWER_THAN_TS;
|
|
|
7aef00 |
|
|
|
7aef00 |
- if (!score_ends_seclabel(&ends, c, &their_tsis, &their_tsrs,
|
|
|
7aef00 |
+ if (!score_ends_seclabel(NULL, &ends, c, &their_tsis, &their_tsrs,
|
|
|
7aef00 |
child->sa.st_logger)) {
|
|
|
7aef00 |
log_state(RC_LOG_SERIOUS, &child->sa,
|
|
|
7aef00 |
"rekey: received Traffic Selectors mismatch configured selectors for Security Label");
|
|
|
7aef00 |
diff -Naur libreswan-4.3-orig/programs/pluto/ikev2_parent.c libreswan-4.3/programs/pluto/ikev2_parent.c
|
|
|
7aef00 |
--- libreswan-4.3-orig/programs/pluto/ikev2_parent.c 2021-02-21 12:03:03.000000000 -0500
|
|
|
7aef00 |
+++ libreswan-4.3/programs/pluto/ikev2_parent.c 2021-03-01 10:31:49.667207958 -0500
|
|
|
7aef00 |
@@ -5943,8 +5943,6 @@
|
|
|
7aef00 |
* from a policy we gave the kernel, so it _should_ be within our range?
|
|
|
7aef00 |
*/
|
|
|
7aef00 |
child->sa.st_acquired_sec_label = clone_hunk(p->sec_label, "st_acquired_sec_label");
|
|
|
7aef00 |
- c->spd.this.sec_label = clone_hunk(p->sec_label, "updated conn label");
|
|
|
7aef00 |
- c->spd.that.sec_label = clone_hunk(p->sec_label, "updated conn label");
|
|
|
7aef00 |
}
|
|
|
7aef00 |
|
|
|
7aef00 |
} else {
|