Project

General

Profile

Actions

Bug #13868

open

connstat could handle opthdr lenght 0 better

Added by Sebastian Wiedenroth 4 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

I have a zone that acts as a NAT gateway. When I call `connstat` it starts to print some data and then fails:

[root@gw-upstream ~]# connstat -4
LADDR                     LPORT RADDR                     RPORT STATE
127.0.0.1                 4999  0.0.0.0                   0     LISTEN
connstat: failed to realloc() buffer: Error 0
connstat: failed to fetch and print connection info
[root@gw-upstream ~]# connstat -6
LADDR                     LPORT RADDR                     RPORT STATE
connstat: failed to realloc() buffer: Error 0
connstat: failed to fetch and print connection info
[root@gw-upstream ~]# 

That happens because in [1] it is trying to

realloc(dbuf.buf, hdr->len)
and hdr->len (a struct opthdr) is 0.

[1] https://github.com/illumos/illumos-gate/blob/76e6cd87e3c5c67bcf83c6a51c5fc85ce41e031a/usr/src/cmd/connstat/connstat_mib.c#L141

[root@gw-upstream ~]# dtrace -n '
> pid$target::realloc:entry  {printf("ptr=%x size=%x", arg0, arg1)}
> pid$target::realloc:return {printf("%x %x\n", arg1, errno)}
> ' -c connstat 

dtrace: description '
pid$target::realloc:entry  ' matched 6 probes
LADDR                     LPORT RADDR                     RPORT STATE
127.0.0.1                 4999  0.0.0.0                   0     LISTEN
connstat: failed to realloc() buffer: Error 0
connstat: failed to fetch and print connection info
dtrace: pid 55517 has exited
CPU     ID                    FUNCTION:NAME
  3  88004                    realloc:entry ptr=0 size=e4
  3  88007                   realloc:return 8085e48 0

  3  88004                    realloc:entry ptr=8085e48 size=b0
  3  88007                   realloc:return 8086f08 0

  3  88004                    realloc:entry ptr=8086f08 size=20
  3  88007                   realloc:return 8081fb0 0

  3  88004                    realloc:entry ptr=8081fb0 size=0
  3  88007                   realloc:return 0 0

I'm not yet sure why len is 0.

No data to display

Actions

Also available in: Atom PDF