On 2.8.2019 13.45, James via dovecot wrote: > My auth process is dumping core. This happens several times per day > but dovecot can operate normally for hours between errors. > > The crash occurs in src/auth/auth-policy.c, line 356: > > t@1 (l@1) program terminated by signal SEGV (no mapping at the fault > address) > Current function is auth_policy_parse_response > 356 context->request->policy_refusal = FALSE; > > ...context->request is null. Add markers to the code... > > } > if (context->request == NULL) fprintf(stderr, > "2222222222222222222222222222 context->request == NULL\n"); > i_stream_unref(&context->payload); > > if (context->request == NULL) fprintf(stderr, > "1111111111111111111111111111 context->request == NULL\n"); > if (context->parse_error) { > context->result = (context->set->policy_reject_on_fail ? -1 : 0); > } > > if (context->request == NULL) fprintf(stderr, > "AAAAAAAAAAAAAAAAAAAAAAAAAAAA context->request == NULL\n"); > context->request->policy_refusal = FALSE; > > if (context->result < 0) { > > ...gives at the time of the crash... > > Aug 1 14:25:44 mailhost dovecot: [ID 702911 mail.error] auth: Error: > 1111111111111111111111111111 context->request == NULL > Aug 1 14:25:44 mailhost dovecot: [ID 702911 mail.error] auth: Error: > AAAAAAAAAAAAAAAAAAAAAAAAAAAA context->request == NULL > > ...so context->result is not null before the call (no 222) to > i_stream_unref but is after. > > > > dovecot.conf has: > > auth_policy_server_url = http://policyserver.lan/ > auth_policy_server_timeout_msecs = 3000 > auth_policy_hash_nonce = Ohr9phaeSeip2Pahaez2raiGohxoo5Ia > auth_policy_request_attributes = remote=%{rip} > auth_policy_check_before_auth = yes > auth_policy_check_after_auth = yes > auth_policy_report_after_auth = yes > > > To simplify the problem I used a dummy policy server, in nginx.conf: > > location / { > default_type application/json; > return 200 "{\"status\":0,\"msg\":\"accepted\"}"; > } > > however no matter what rubbish a policy server sends back it should > not cause dovecot to crash. > > I've tried 32 and 64 bit and two compilers (gcc and SunStudio), all > result in crashes. Adding: > keepalive_timeout 0; > ...to nginx.conf appears to reduce the crashes. It happens with a > variety of users and with debug output I see no pattern. > > > > James. >
Hi! There is an easy fix for this, attached. Aki
>From 760452dacb6da1209c79765ed8ad51144e9d9dcf Mon Sep 17 00:00:00 2001 From: Aki Tuomi <aki.tu...@open-xchange.com> Date: Tue, 6 Aug 2019 08:44:18 +0300 Subject: [PATCH] auth: Do not unref policy payload too early This can cause the context to be free'd too early leading to crashes. --- src/auth/auth-policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth/auth-policy.c b/src/auth/auth-policy.c index 9efc81330..6318db8bf 100644 --- a/src/auth/auth-policy.c +++ b/src/auth/auth-policy.c @@ -347,7 +347,6 @@ void auth_policy_parse_response(struct policy_lookup_ctx *context) else if (context->parse_state == POLICY_RESULT) context->parse_error = FALSE; } - i_stream_unref(&context->payload); if (context->parse_error) { context->result = (context->set->policy_reject_on_fail ? -1 : 0); @@ -376,6 +375,7 @@ void auth_policy_parse_response(struct policy_lookup_ctx *context) } auth_policy_callback(context); + i_stream_unref(&context->payload); } static -- 2.11.0