Bug 1298866

Summary: backport request for Bug 52315 - NULL pointer in log.c caused by ap_send_interim_response() in protocol.c
Product: Red Hat Enterprise Linux 6 Reporter: Patrick <pbajenez>
Component: httpdAssignee: Luboš Uhliarik <luhliari>
Status: CLOSED ERRATA QA Contact: Petr Šplíchal <psplicha>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 6.7CC: agrimm, bnater, dmasirka, jkaluza, jorton, mfrodl, ohudlick, psplicha
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: httpd-2.2.15-52.el6 Doc Type: Bug Fix
Doc Text:
Previously, when writing an error message about an incorrect HTTP interim response code to a log file, the httpd daemon used a NULL pointer instead of a pointer to the real request. As a consequence, httpd could terminate unexpectedly with a segmentation fault if the back-end server sent incorrect interim response code. With this update, the correct HTTP request pointer is passed to the httpd logging code, and httpd no longer crashes in this scenario.
Story Points: ---
Clone Of:
: 1300707 (view as bug list) Environment:
Last Closed: 2016-05-10 21:37:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1277547, 1300707    
Attachments:
Description Flags
Sanitized httpd configuration none

Description Patrick 2016-01-15 09:53:32 UTC
Description of problem:

We have a customer facing the following issue in production with httpd-2.2.15
https://bz.apache.org/bugzilla/show_bug.cgi?id=52315

this was fixed in httpd-2.2.22

Version-Release number of selected component (if applicable):

httpd-2.2.15

Comment 3 Andy Grimm 2016-01-15 14:10:11 UTC
backtrace:

#0  ap_log_rerror (file=0x7fb549d86870 "/builddir/build/BUILD/httpd-2.2.15/server/protocol.c", line=1679, level=7, status=0, r=0x0, fmt=0x7fb549d86840 "Status is %d - not sending interim response")
    at /usr/src/debug/httpd-2.2.15/server/log.c:737
#1  0x00007fb549d5f6f7 in ap_send_interim_response (r=0x7fb2a0002978, send_headers=1) at /usr/src/debug/httpd-2.2.15/server/protocol.c:1679
#2  0x00007fb5447c4b35 in ap_proxy_http_process_response (p=0x7fb2a00028f8, r=<value optimized out>, backend=0x7fb54b2673f8, origin=0x7fb2a0008bb8, conf=0x7fb54b2a0238, server_portstr=0x7fb53cc0baa0 "")
    at /usr/src/debug/httpd-2.2.15/modules/proxy/mod_proxy_http.c:1667
#3  0x00007fb5447c5e7e in proxy_http_handler (r=0x7fb2a0002978, worker=<value optimized out>, conf=0x7fb53cc0ba88, url=0x7fb2a00070a0 "/recordEvent/delivery_success", 
    proxyname=0x7fb2a00008e8 "\310\375~8\265\177", proxyport=35768) at /usr/src/debug/httpd-2.2.15/modules/proxy/mod_proxy_http.c:2045
#4  0x00007fb544bd51ca in proxy_run_scheme_handler (r=0x7fb2a0002978, worker=0x7fb54b2a0410, conf=0x7fb54b2a0238, url=0x7fb2a0006c2e "http://127.12.24.129:8080/recordEvent/delivery_success", proxyhost=0x0, 
    proxyport=0) at /usr/src/debug/httpd-2.2.15/modules/proxy/mod_proxy.c:2408
#5  0x00007fb544bd97d7 in proxy_handler (r=0x7fb2a0002978) at /usr/src/debug/httpd-2.2.15/modules/proxy/mod_proxy.c:1029
#6  0x00007fb549d6d7d0 in ap_run_handler (r=0x7fb2a0002978) at /usr/src/debug/httpd-2.2.15/server/config.c:158
#7  0x00007fb549d7108e in ap_invoke_handler (r=0x7fb2a0002978) at /usr/src/debug/httpd-2.2.15/server/config.c:376
#8  0x00007fb549d7c4c0 in ap_process_request (r=0x7fb2a0002978) at /usr/src/debug/httpd-2.2.15/modules/http/http_request.c:282
#9  0x00007fb549d79308 in ap_process_http_connection (c=0x7fb5387f0060) at /usr/src/debug/httpd-2.2.15/modules/http/http_core.c:190
#10 0x00007fb549d752d8 in ap_run_process_connection (c=0x7fb5387f0060) at /usr/src/debug/httpd-2.2.15/server/connection.c:43
#11 0x00007fb549d82122 in process_socket (thd=0x7fb54b2d57c8, dummy=<value optimized out>) at /usr/src/debug/httpd-2.2.15/server/mpm/worker/worker.c:544
#12 worker_thread (thd=0x7fb54b2d57c8, dummy=<value optimized out>) at /usr/src/debug/httpd-2.2.15/server/mpm/worker/worker.c:894
#13 0x00007fb548616a51 in start_thread (arg=0x7fb53cc0c700) at pthread_create.c:301
#14 0x00007fb54836393d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

Comment 4 Andy Grimm 2016-01-15 14:34:54 UTC
Created attachment 1115171 [details]
Sanitized httpd configuration

Comment 6 Andy Grimm 2016-01-15 18:27:57 UTC
FWIW, I currently have worked around the bug with:

SetEnv proxy-interim-response Suppress

As you might expect, this results in a large number of errors in the logs due to the bogus status line we discussed (HTTP/1.1 12501 unknown):

[Fri Jan 15 13:21:44 2016] [error] [client 52.89.28.21] (20014)Internal error: proxy: error reading status line from remote server 127.12.24.129
[Fri Jan 15 13:21:44 2016] [error] [client 52.89.28.21] proxy: Error reading from remote server returned by /recordEvent/delivery_created

But at least it doesn't crash.

Comment 7 Jan Kaluža 2016-01-18 14:42:45 UTC
The backtrace really looks like to be caused by the Bug 52315 from httpd bugzilla. I'm also able to reproduce it with httpd in RHEL6.

I'm not sure what to do with the Internal error. Apache httpd should send only valid HTTP responses back to the client and status code 12501 is not valid HTTP status code. Therefore httpd prints the error to error_log and sends 502 Proxy Error to the client.

It's clear that it is the backend application sending invalid response here, so for this bugreport, we are going to fix only the crash. I think it is up to backend application developers to fix the application.

Comment 17 errata-xmlrpc 2016-05-10 21:37:21 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-0841.html