Skip to content

Commit 5ff05c0

Browse files
committed
Merge !1678: misc 5.x backports
2 parents 5a76478 + 4a7461e commit 5ff05c0

File tree

17 files changed

+66
-84
lines changed

17 files changed

+66
-84
lines changed

.gitlab-ci.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ variables:
2020
# IMAGE_TAG is a Git branch/tag name from https://gitlab.nic.cz/knot/knot-resolver-ci
2121
# In general, keep it pointing to a tag - use a branch only for development.
2222
# More info in the knot-resolver-ci repository.
23-
IMAGE_TAG: 'v20240506'
23+
IMAGE_TAG: 'v20250324'
2424
IMAGE_PREFIX: '$CI_REGISTRY/knot/knot-resolver-ci'
2525

2626
image: $IMAGE_PREFIX/debian12-knot_3_3:$IMAGE_TAG
@@ -325,12 +325,10 @@ trivial_checks: # aggregated to save some processing
325325
- ci/no_assert_check.sh
326326
- ci/deckard_commit_check.sh
327327

328-
lint:other:
328+
lint:luacheck:
329329
<<: *sanity
330330
script:
331331
- meson build_ci_lint &>/dev/null
332-
- ninja -C build_ci* pylint
333-
- ninja -C build_ci* flake8
334332
- ninja -C build_ci* luacheck
335333

336334
lint:pedantic:
@@ -873,6 +871,10 @@ pkg:make-archive:
873871
- apkg build-dep
874872
- apkg make-archive
875873

874+
pkg:debian-13:
875+
<<: *pkg_test_deb
876+
image: $CI_REGISTRY/packaging/apkg/full/debian-13
877+
876878
pkg:debian-12:
877879
<<: *pkg_test_deb
878880
<<: *enable_repo_build
@@ -883,6 +885,10 @@ pkg:debian-11:
883885
<<: *enable_repo_build
884886
image: $CI_REGISTRY/packaging/apkg/full/debian-11
885887

888+
pkg:ubuntu-25.04:
889+
<<: *pkg_test_deb
890+
image: $CI_REGISTRY/packaging/apkg/full/ubuntu-25.04
891+
886892
pkg:ubuntu-24.04:
887893
<<: *pkg_test_deb
888894
image: $CI_REGISTRY/packaging/apkg/full/ubuntu-24.04

NEWS

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ Bugfixes
55
--------
66
- daemon/http: DoH stream got stuck after returning an error code (!1652)
77

8+
Improvements
9+
------------
10+
- tests: disable problematic config.http test (#925, !1678)
11+
- validator: accept a confusing NODATA proof with insecure delegation (!1678)
12+
13+
Bugfixes
14+
--------
15+
- stats: request latency was very incorrect in some cases (!1678)
16+
817

918
Knot Resolver 5.7.4 (2024-07-23)
1019
================================

daemon/lua/kres-gen-32.lua

+1
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ typedef struct zs_scanner {
634634
uint8_t addr[16];
635635
_Bool long_string;
636636
_Bool comma_list;
637+
_Bool pending_backslash;
637638
uint8_t *dname;
638639
uint32_t *dname_length;
639640
uint32_t dname_tmp_length;

doc/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
extensions = ['sphinx.ext.todo', 'sphinx.ext.viewcode', 'breathe']
1717

1818
theme_major = sphinx_rtd_theme.__version__.partition('.')[0]
19-
if theme_major == '2':
19+
if theme_major >= '2':
2020
extensions.append('sphinxcontrib.jquery')
2121

2222
# Breathe configuration

lib/dnssec/nsec.c

+14-5
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,16 @@ int kr_nsec_bitmap_nodata_check(const uint8_t *bm, uint16_t bm_size, uint16_t ty
161161
break;
162162
default:
163163
/* Parent-side delegation record isn't authoritative for non-DS;
164-
* see RFC6840 4.1. */
164+
* see RFC6840 4.1.
165+
*
166+
* Additionally, we signal if the NODATA would belong
167+
* to an *insecure* child zone.
168+
*/
165169
if (dnssec_nsec_bitmap_contains(bm, bm_size, KNOT_RRTYPE_NS)
166170
&& !dnssec_nsec_bitmap_contains(bm, bm_size, KNOT_RRTYPE_SOA)) {
167-
return NO_PROOF;
171+
return dnssec_nsec_bitmap_contains(bm, bm_size, KNOT_RRTYPE_DS)
172+
? NO_PROOF
173+
: KNOT_EDOWNGRADED;
168174
}
169175
/* LATER(opt): perhaps short-circuit test if we repeat it here. */
170176
}
@@ -218,9 +224,12 @@ int kr_nsec_negative(const ranked_rr_array_t *rrrs, uint32_t qry_uid,
218224
&& kr_rank_test(rrrs->at[i]->rank, KR_RANK_SECURE);
219225
if (!ok) continue;
220226
const int covers = nsec_covers(nsec, sname);
221-
if (covers == abs(EEXIST)
222-
&& no_data_response_check_rrtype(nsec, stype) == 0) {
223-
return PKT_NODATA; // proven NODATA by matching NSEC
227+
if (covers == abs(EEXIST)) {
228+
int ret = no_data_response_check_rrtype(nsec, stype);
229+
if (ret == 0)
230+
return PKT_NODATA; // proven NODATA by matching NSEC
231+
if (ret == KNOT_EDOWNGRADED)
232+
return ret;
224233
}
225234
if (covers != 0) continue;
226235

lib/dnssec/nsec.h

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include "lib/layer/iterate.h"
1010

11+
#define KNOT_EDOWNGRADED (KNOT_ERROR_MIN - 1)
12+
1113
/**
1214
* Check bitmap that child names are contained in the same zone.
1315
* @note see RFC6840 4.1.
@@ -25,6 +27,7 @@ int kr_nsec_children_in_zone_check(const uint8_t *bm, uint16_t bm_size);
2527
* @param owner NSEC record owner.
2628
* @note This includes special checks for zone cuts, e.g. from RFC 6840 sec. 4.
2729
* @return 0, abs(ENOENT) (no proof), kr_error(EINVAL)
30+
* KNOT_EDOWNGRADED: special case where the RR would be in an insecure child zone.
2831
*/
2932
int kr_nsec_bitmap_nodata_check(const uint8_t *bm, uint16_t bm_size, uint16_t type, const knot_dname_t *owner);
3033

@@ -44,6 +47,7 @@ int kr_nsec_wildcard_answer_response_check(const knot_pkt_t *pkt, knot_section_t
4447
* @param rrrs list of RRs to search; typically kr_request::auth_selected
4548
* @param qry_uid only consider NSECs from this packet, for better efficiency
4649
* @return negative error code, or PKT_NXDOMAIN | PKT_NODATA (both for NXDOMAIN)
50+
* KNOT_EDOWNGRADED: special case where the RR would be in an insecure child zone.
4751
*/
4852
int kr_nsec_negative(const ranked_rr_array_t *rrrs, uint32_t qry_uid,
4953
const knot_dname_t *sname, uint16_t stype);

lib/dnssec/nsec3.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ int kr_nsec3_name_error_response_check(const knot_pkt_t *pkt, knot_section_t sec
507507
* @param sname Name to be checked.
508508
* @param stype Type to be checked.
509509
* @return 0 or error code.
510+
* KNOT_EDOWNGRADED: special case where the RR would be in an insecure child zone.
510511
* @note This does NOT check the opt-out case if type is DS;
511512
* see RFC 5155 8.6.
512513
*/
@@ -528,8 +529,9 @@ static int nodata_find(const knot_pkt_t *pkt, knot_section_t section_id,
528529

529530
const uint8_t *bm = knot_nsec3_bitmap(nsec3->rrs.rdata);
530531
uint16_t bm_size = knot_nsec3_bitmap_len(nsec3->rrs.rdata);
531-
if (kr_nsec_bitmap_nodata_check(bm, bm_size, type, nsec3->owner) == kr_ok())
532-
return kr_ok();
532+
int ret = kr_nsec_bitmap_nodata_check(bm, bm_size, type, nsec3->owner);
533+
if (ret == kr_ok() || ret == KNOT_EDOWNGRADED)
534+
return ret;
533535
}
534536

535537
return kr_error(ENOENT);
@@ -602,8 +604,8 @@ int kr_nsec3_no_data(const knot_pkt_t *pkt, knot_section_t section_id,
602604
{
603605
/* DS record may be also matched by an existing NSEC3 RR. */
604606
int ret = nodata_find(pkt, section_id, sname, stype);
605-
if (ret == 0) {
606-
/* Satisfies RFC5155 8.5 and 8.6, both first paragraph. */
607+
if (ret == 0 || ret == KNOT_EDOWNGRADED) {
608+
/* If 0, satisfies RFC5155 8.5 and 8.6, both first paragraph. */
607609
return ret;
608610
}
609611

lib/dnssec/nsec3.h

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ int kr_nsec3_wildcard_answer_response_check(const knot_pkt_t *pkt, knot_section_
8787
* @return 0 or error code:
8888
* DNSSEC_NOT_FOUND - neither ds nor nsec records
8989
* were not found.
90+
* KNOT_EDOWNGRADED - special case where
91+
* the RR would be in an insecure child zone.
9092
* KNOT_ERANGE - denial of existence can't be proven
9193
* due to opt-out, otherwise - bogus.
9294
*/

lib/layer/validate.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ static bool maybe_downgrade_nsec3(const ranked_rr_array_entry_t *e, struct kr_qu
144144
return true;
145145
}
146146

147-
#define KNOT_EDOWNGRADED (KNOT_ERROR_MIN - 1)
148-
149147
static int validate_section(kr_rrset_validation_ctx_t *vctx, struct kr_query *qry,
150148
knot_mm_t *pool)
151149
{
@@ -1271,6 +1269,12 @@ static int validate(kr_layer_t *ctx, knot_pkt_t *pkt)
12711269
* we must continue, validate NSEC\NSEC3 and
12721270
* call update_parent_keys() to mark
12731271
* parent queries as insecure */
1272+
} else if (ret == KNOT_EDOWNGRADED) { // either NSEC3 or NSEC
1273+
VERBOSE_MSG(qry, "<= DNSSEC downgraded by a weird proof confusing NODATA with insecure delegation\n");
1274+
qry->flags.DNSSEC_WANT = false;
1275+
qry->flags.DNSSEC_INSECURE = true;
1276+
rank_records(qry, true, KR_RANK_INSECURE, qry->sname);
1277+
mark_insecure_parents(qry);
12741278
} else {
12751279
VERBOSE_MSG(qry, "<= bad NODATA proof\n");
12761280
kr_request_set_extended_error(req, KNOT_EDNS_EDE_NSEC_MISS, "AHXI");

lib/rplan.c

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ static struct kr_query *kr_rplan_push_query(struct kr_rplan *rplan,
157157
qry->request = rplan->request;
158158

159159
gettimeofday(&qry->timestamp, NULL);
160+
if (!parent) // start of kr_request; let's make the stamp more precise
161+
uv_update_time(uv_default_loop());
160162
qry->timestamp_mono = kr_now();
161163
qry->creation_time_mono = parent ? parent->creation_time_mono : qry->timestamp_mono;
162164
kr_zonecut_init(&qry->zone_cut, (const uint8_t *)"", rplan->pool);

lib/rplan.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct kr_query {
9898
* ancestor if it is a subquery. */
9999
uint64_t timestamp_mono; /**< Time of query created or time of
100100
* query to upstream resolver (milliseconds). */
101-
struct timeval timestamp; /**< Real time for TTL+DNSSEC checks (.tv_sec only). */
101+
struct timeval timestamp; /**< Creation real time. For TTL+DNSSEC checks we use .tv_sec only. */
102102
struct kr_zonecut zone_cut;
103103
struct kr_layer_pickle *deferred;
104104

meson.build

-18
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,6 @@ install_data(
278278
message('--- lint dependencies ---')
279279
clangtidy = find_program('clang-tidy', required: false)
280280
luacheck = find_program('luacheck', required: false)
281-
flake8 = find_program('flake8', required: false)
282-
pylint_run = find_program('scripts/run-pylint.sh')
283281
message('-------------------------')
284282

285283
if clangtidy.found()
@@ -306,22 +304,6 @@ if luacheck.found()
306304
)
307305
endif
308306

309-
if flake8.found()
310-
run_target(
311-
'flake8',
312-
command: [
313-
flake8,
314-
'--max-line-length=100',
315-
meson.source_root() / 'tests' / 'pytests',
316-
],
317-
)
318-
endif
319-
320-
run_target(
321-
'pylint',
322-
command: pylint_run,
323-
)
324-
325307

326308
# Summary message
327309
# NOTE: ternary operator in format() not supported

modules/http/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ lua_mod_src += [
1919
]
2020

2121
config_tests += [
22-
['http', files('http.test.lua')],
22+
#['http', files('http.test.lua')], # https://gitlab.nic.cz/knot/knot-resolver/-/issues/925
2323
['http.doh', files('http_doh.test.lua')],
2424
['http.tls', files('test_tls/tls.test.lua'), ['skip_asan']],
2525
]

modules/stats/stats.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,14 @@ static int collect(kr_layer_t *ctx)
248248
collect_answer(data, param->answer);
249249
/* Count cached and unresolved */
250250
if (rplan->resolved.len > 0) {
251-
/* Histogram of answer latency. */
252-
struct kr_query *first = rplan->resolved.at[0];
253-
uint64_t elapsed = kr_now() - first->timestamp_mono;
251+
/* Histogram of answer latency.
252+
*
253+
* We update the notion of time. Once per .finish isn't that expensive.
254+
* defer_* also updates this if active, but not in ideal moment for stats.
255+
*/
256+
uv_update_time(uv_default_loop());
257+
uint64_t elapsed = kr_now() - rplan->initial->creation_time_mono;
258+
254259
stat_const_add(data, metric_answer_sum_ms, elapsed);
255260
if (elapsed <= 1) {
256261
stat_const_add(data, metric_answer_1ms, 1);

scripts/run-pylint.sh

-12
This file was deleted.

tests/integration/deckard

Submodule deckard updated from b5b3386 to cc478cc

tests/pytests/pylintrc

-32
This file was deleted.

0 commit comments

Comments
 (0)