Synopsis: Crash if disabling a host that isn't checked if others are checked.
Category:  system
Environment:
    System      : OpenBSD 5.7
Details : OpenBSD 5.7-current (GENERIC.MP) #970: Fri May 1 09:48:23 MDT 2015 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP

    Architecture: OpenBSD.amd64
    Machine     : amd64

Description:
Configure relayd as a layer 7 relay with multiple 'forward to' tables. Configure the tables to check host availability on all but 1 of the tables. With relayd running, disable the host in the unchecked table with relayctl and relayd will exit abnormally.

How-To-Repeat:
    Run relayd with the following config:
-----
webhost1="10.0.0.1"
webhost2="10.0.0.2"
webhost3="10.0.0.3"

table <webhosts1> { $webhost1 }
table <webhosts2> { $webhost2 }
table <webhosts3> { $webhost3 }
table <fallback> { 127.0.0.1 }

http protocol https {
    match request header append "X-Forwarded-For" value "$REMOTE_ADDR"
    match request header append "X-Forwarded-By" \
        value "$SERVER_ADDR:$SERVER_PORT"
    match request header set "Connection" value "close"

    tcp { nodelay, sack, socket buffer 65536, backlog 128 }

}

relay wwwtls {
    listen on 127.0.0.1 port 80
    protocol https

    forward to <webhosts1> port http check http "/" code 200
    forward to <webhosts2> port http check http "/" code 200
    forward to <webhosts3> port http
}
-----
With relayd running, disable host 3 with 'relayctl host disable 3' and relayd will shutdown.

GDB capture:
(gdb) set args -df /etc/relayd.conf
(gdb) file /usr/sbin/relayd
Reading symbols from /usr/sbin/relayd...done.
(gdb) run
Starting program: /usr/sbin/relayd -df /etc/relayd.conf
startup
[New process 16024]
protocol 1: name https
        flags: used, relay flags:
        tcp flags: nodelay, sack, socket buffer size
        type: http
match request header append "X-Forwarded-For" value "$REMOTE_ADDR" match request header append "X-Forwarded-By" value "$SERVER_ADDR:$SERVER_PORT"
                match request header set "Connection" value "close"
adding 1 hosts from table webhosts1:80
adding 1 hosts from table webhosts1:80
adding 1 hosts from table webhosts2:80
adding 1 hosts from table webhosts3:80 (no check)
adding 1 hosts from table webhosts2:80
adding 1 hosts from table webhosts3:80 (no check)
adding 1 hosts from table webhosts1:80
adding 1 hosts from table webhosts2:80
adding 1 hosts from table webhosts3:80 (no check)
host 10.0.0.1, check http code (202ms), state unknown -> down, availability 0.00% host 10.0.0.2, check http code (202ms), state unknown -> down, availability 0.00%
fatal: hce_dispatch_pfe: desynchronized
pfe exiting, pid 6507
lost child: hce exited abnormally

Program received signal SIGTERM, Terminated.
0x00001303e6dcaa0a in kill () at <stdin>:2
2       <stdin>: No such file or directory.
        in <stdin>
Current language:  auto; currently asm
(gdb) ca exiting, pid 6184
ca exiting, pid 30053
relay exiting, pid 18225
relay exiting, pid 12293
ca exiting, pid 246
relay exiting, pid 25046

(gdb) bt
#0  0x00001303e6dcaa0a in kill () at <stdin>:2
#1  0x000013014871d195 in proc_kill (ps=0x1304360d4800) at proc.c:133
#2 0x00001301487295de in parent_shutdown (env=0x1303874ed000) at relayd.c:409 #3 0x000013014872a59f in parent_sig_handler (sig=Variable "sig" is not available.
) at relayd.c:122
#4 0x00001303eaeac218 in event_base_loop (base=0x1303874f8400, flags=Variable "flags" is not available.
) at /usr/src/lib/libevent/event.c:350
#5  0x000013014872a3cd in main (argc=Variable "argc" is not available.
) at relayd.c:278


Fix:
    The workaround is to add the check to all tables.

dmesg:
OpenBSD 5.7-current (GENERIC.MP) #970: Fri May  1 09:48:23 MDT 2015
    dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4242014208 (4045MB)
avail mem = 4109598720 (3919MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.5 @ 0xfcfa0 (38 entries)
bios0: vendor American Megatrends Inc. version "206" date 02/14/2011
bios0: ASUSTeK Computer Inc. P50IJ
acpi0 at bios0: rev 2
acpi0: ATKG checksum error
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC MCFG SLIC ECDT DBGP BOOT OEMB HPET GSCI ATKG SSDT acpi0: wakeup devices USB0(S3) USB1(S3) USB2(S3) USB5(S3) EUSB(S3) USB3(S3) USB4(S3) USB6(S3) USBE(S3) HDAC(S3) P0P1(S3) P0P3(S3) P0P5(S3) P0P6(S3) P0P7(S4) GLAN(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Pentium(R) Dual-Core CPU T4500 @ 2.30GHz, 2194.80 MHz
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,XSAVE,NXE,LONG,LAHF,PERF
cpu0: 1MB 64b/line 4-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 199MHz
cpu0: mwait min=64, max=64, C-substates=0.2.2.2.0, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Pentium(R) Dual-Core CPU T4500 @ 2.30GHz, 2194.51 MHz
cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,XSAVE,NXE,LONG,LAHF,PERF
cpu1: 1MB 64b/line 4-way L2 cache
cpu1: smt 0, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 24 pins
acpimcfg0 at acpi0 addr 0xe0000000, bus 0-255
acpiec0 at acpi0
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 2 (P0P2)
acpiprt2 at acpi0: bus -1 (P0P3)
acpiprt3 at acpi0: bus 3 (P0P7)
acpicpu0 at acpi0: C3, C2, C1, PSS
acpicpu1 at acpi0: C3, C2, C1, PSS
acpitz0 at acpi0: critical temperature is 111 degC
acpiac0 at acpi0: AC unit online
acpibat0 at acpi0: BAT0 model "F82--22" serial   type LIon oem "ASUSTEK"
acpiasus at acpi0 not configured
acpibtn0 at acpi0: SLPB
acpibtn1 at acpi0: LID_
cpu0: Enhanced SpeedStep 2194 MHz: speeds: 2300, 1600, 1200 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel GM45 Host" rev 0x09
vga1 at pci0 dev 2 function 0 "Intel GM45 Video" rev 0x09
intagp0 at vga1
agp0 at intagp0: aperture at 0xd0000000, size 0x10000000
inteldrm0 at vga1
drm0 at inteldrm0
inteldrm0: 1366x768
wsdisplay0 at vga1 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel GM45 Video" rev 0x09 at pci0 dev 2 function 1 not configured
uhci0 at pci0 dev 26 function 0 "Intel 82801I USB" rev 0x03: apic 2 int 16 uhci1 at pci0 dev 26 function 1 "Intel 82801I USB" rev 0x03: apic 2 int 21 uhci2 at pci0 dev 26 function 2 "Intel 82801I USB" rev 0x03: apic 2 int 19 ehci0 at pci0 dev 26 function 7 "Intel 82801I USB" rev 0x03: apic 2 int 18
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
azalia0 at pci0 dev 27 function 0 "Intel 82801I HD Audio" rev 0x03: msi
azalia0: codecs: VIA/0x0397
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel 82801I PCIE" rev 0x03
pci1 at ppb0 bus 1
ppb1 at pci0 dev 28 function 1 "Intel 82801I PCIE" rev 0x03
pci2 at ppb1 bus 2
athn0 at pci2 dev 0 function 0 "Atheros AR9285" rev 0x01: apic 2 int 17
athn0: AR9285 rev 2 (1T1R), ROM rev 13, address 1c:4b:d6:c6:cb:7e
ppb2 at pci0 dev 28 function 5 "Intel 82801I PCIE" rev 0x03: msi
pci3 at ppb2 bus 3
ale0 at pci3 dev 0 function 0 "Attansic Technology L1E" rev 0xb0: AR8121, msi, address 48:5b:39:6e:d9:c1
atphy0 at ale0 phy 0: F1 10/100/1000 PHY, rev. 9
uhci3 at pci0 dev 29 function 0 "Intel 82801I USB" rev 0x03: apic 2 int 23 uhci4 at pci0 dev 29 function 1 "Intel 82801I USB" rev 0x03: apic 2 int 19 uhci5 at pci0 dev 29 function 2 "Intel 82801I USB" rev 0x03: apic 2 int 18 ehci1 at pci0 dev 29 function 7 "Intel 82801I USB" rev 0x03: apic 2 int 23
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb3 at pci0 dev 30 function 0 "Intel 82801BAM Hub-to-PCI" rev 0x93
pci4 at ppb3 bus 4
pcib0 at pci0 dev 31 function 0 "Intel 82801IBM LPC" rev 0x03
ahci0 at pci0 dev 31 function 2 "Intel 82801I AHCI" rev 0x03: msi, AHCI 1.2
ahci0: port 0: 3.0Gb/s
ahci0: port 1: 1.5Gb/s
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 0 lun 0: <ATA, WDC WD3200BEVT-8, 01.0> SCSI3 0/direct fixed naa.50014ee6aabb8053
sd0: 305245MB, 512 bytes/sector, 625142448 sectors
cd0 at scsibus1 targ 1 lun 0: <HL-DT-ST, DVDRAM GT32N, AS01> ATAPI 5/cdrom removable
usb2 at uhci0: USB revision 1.0
uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci1: USB revision 1.0
uhub3 at usb3 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb4 at uhci2: USB revision 1.0
uhub4 at usb4 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb5 at uhci3: USB revision 1.0
uhub5 at usb5 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb6 at uhci4: USB revision 1.0
uhub6 at usb6 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb7 at uhci5: USB revision 1.0
uhub7 at usb7 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
pms0: Elantech Touchpad, version 2, firmware 0x40101
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
uvideo0 at uhub0 port 3 configuration 1 interface 0 "Sonix Technology Co., Ltd. USB 2.0 Camera" rev 2.00/12.11 addr 2
video0 at uvideo0
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 005> SCSI2 0/direct fixed
sd1: 204804MB, 512 bytes/sector, 419440493 sectors
root on sd1a (31ab7a6141794c2c.a) swap on sd1b dump on sd1b

Reply via email to