f-stack/freebsd/netinet
logwang 2aa28acdb3 Fix #114: An out of bounds of memory in netinet/libalias/alias_sctp.c.
Run with valgrind, and found this:
==2228== Invalid write of size 8
==2228==    at 0x4E05DA: AliasSctpInit (alias_sctp.c:641)
==2228==    by 0x4DE565: LibAliasInit (alias_db.c:2503)
==2228==    by 0x4E9B3B: nat44_config (ip_fw_nat.c:505)
==2228==    by 0x4E9E91: nat44_cfg (ip_fw_nat.c:599)
==2228==    by 0x4F1719: ipfw_ctl3 (ip_fw_sockopt.c:3666)
==2228==    by 0x4B9954: rip_ctloutput (raw_ip.c:659)
==2228==    by 0x447E11: sosetopt (uipc_socket.c:2505)
==2228==    by 0x44BF4D: kern_setsockopt (uipc_syscalls.c:1407)
==2228==    by 0x409F08: ff_setsockopt (ff_syscall_wrapper.c:412)
==2228==    by 0x5277AA: handle_ipfw_msg (ff_dpdk_if.c:1146)
==2228==    by 0x52788C: handle_msg (ff_dpdk_if.c:1196)
==2228==    by 0x5289B8: process_msg_ring (ff_dpdk_if.c:1213)
==2228==  Address 0x60779b0 is 4,800 bytes inside a block of size 4,802
alloc'd
==2228==    at 0x4C2ABBD: malloc (vg_replace_malloc.c:296)
==2228==    by 0x509F15: ff_malloc (ff_host_interface.c:89)
==2228==    by 0x4053BE: malloc (ff_glue.c:1021)
==2228==    by 0x4E054E: AliasSctpInit (alias_sctp.c:632)
==2228==    by 0x4DE565: LibAliasInit (alias_db.c:2503)
==2228==    by 0x4E9B3B: nat44_config (ip_fw_nat.c:505)
==2228==    by 0x4E9E91: nat44_cfg (ip_fw_nat.c:599)
==2228==    by 0x4F1719: ipfw_ctl3 (ip_fw_sockopt.c:3666)
==2228==    by 0x4B9954: rip_ctloutput (raw_ip.c:659)
==2228==    by 0x447E11: sosetopt (uipc_socket.c:2505)
==2228==    by 0x44BF4D: kern_setsockopt (uipc_syscalls.c:1407)
==2228==    by 0x409F08: ff_setsockopt (ff_syscall_wrapper.c:412)
==2228==

The error line is:
`la->sctpNatTimer.TimerQ = sn_calloc(SN_TIMER_QUEUE_SIZE, sizeof(struct
sctpTimerQ));`

Since SN_TIMER_QUEUE_SIZE is defined as SN_MAX_TIMER+2, and sn_calloc is
defined as sn_malloc(x * n) if _SYS_MALLOC_H_ is defined, the size of
calloced memory will be wrong, because the macro will be expanded to
sizeof(struct sctpTimerQ)*SN_MAX_TIMER+2.

And the memory will be out of bounds here.
```
/* Initialise circular timer Q*/
for (i = 0; i < SN_TIMER_QUEUE_SIZE; i++)
    LIST_INIT(&la->sctpNatTimer.TimerQ[i]);
```
2017-12-05 15:32:10 +08:00
..
cc freebsd: fix compiling error with gcc 6.3.1 2017-05-25 18:57:02 +08:00
khelp init 2017-04-21 18:43:26 +08:00
libalias Fix #114: An out of bounds of memory in netinet/libalias/alias_sctp.c. 2017-12-05 15:32:10 +08:00
tcp_stacks init 2017-04-21 18:43:26 +08:00
accf_data.c init 2017-04-21 18:43:26 +08:00
accf_dns.c init 2017-04-21 18:43:26 +08:00
accf_http.c init 2017-04-21 18:43:26 +08:00
icmp6.h init 2017-04-21 18:43:26 +08:00
icmp_var.h init 2017-04-21 18:43:26 +08:00
if_atm.c init 2017-04-21 18:43:26 +08:00
if_atm.h init 2017-04-21 18:43:26 +08:00
if_ether.c init 2017-04-21 18:43:26 +08:00
if_ether.h init 2017-04-21 18:43:26 +08:00
igmp.c init 2017-04-21 18:43:26 +08:00
igmp.h init 2017-04-21 18:43:26 +08:00
igmp_var.h init 2017-04-21 18:43:26 +08:00
in.c init 2017-04-21 18:43:26 +08:00
in.h init 2017-04-21 18:43:26 +08:00
in_cksum.c init 2017-04-21 18:43:26 +08:00
in_debug.c init 2017-04-21 18:43:26 +08:00
in_fib.c init 2017-04-21 18:43:26 +08:00
in_fib.h init 2017-04-21 18:43:26 +08:00
in_gif.c init 2017-04-21 18:43:26 +08:00
in_kdtrace.c init 2017-04-21 18:43:26 +08:00
in_kdtrace.h init 2017-04-21 18:43:26 +08:00
in_mcast.c init 2017-04-21 18:43:26 +08:00
in_pcb.c Fix endless loop when connect to a peer if all ports are completely used. 2017-09-11 11:01:18 +08:00
in_pcb.h init 2017-04-21 18:43:26 +08:00
in_pcbgroup.c init 2017-04-21 18:43:26 +08:00
in_proto.c init 2017-04-21 18:43:26 +08:00
in_rmx.c init 2017-04-21 18:43:26 +08:00
in_rss.c init 2017-04-21 18:43:26 +08:00
in_rss.h init 2017-04-21 18:43:26 +08:00
in_systm.h init 2017-04-21 18:43:26 +08:00
in_var.h init 2017-04-21 18:43:26 +08:00
ip.h init 2017-04-21 18:43:26 +08:00
ip6.h init 2017-04-21 18:43:26 +08:00
ip_carp.c init 2017-04-21 18:43:26 +08:00
ip_carp.h init 2017-04-21 18:43:26 +08:00
ip_divert.c init 2017-04-21 18:43:26 +08:00
ip_divert.h init 2017-04-21 18:43:26 +08:00
ip_dummynet.h init 2017-04-21 18:43:26 +08:00
ip_ecn.c init 2017-04-21 18:43:26 +08:00
ip_ecn.h init 2017-04-21 18:43:26 +08:00
ip_encap.c init 2017-04-21 18:43:26 +08:00
ip_encap.h init 2017-04-21 18:43:26 +08:00
ip_fastfwd.c init 2017-04-21 18:43:26 +08:00
ip_fw.h init 2017-04-21 18:43:26 +08:00
ip_gre.c init 2017-04-21 18:43:26 +08:00
ip_icmp.c init 2017-04-21 18:43:26 +08:00
ip_icmp.h init 2017-04-21 18:43:26 +08:00
ip_id.c init 2017-04-21 18:43:26 +08:00
ip_input.c init 2017-04-21 18:43:26 +08:00
ip_ipsec.c init 2017-04-21 18:43:26 +08:00
ip_ipsec.h init 2017-04-21 18:43:26 +08:00
ip_mroute.c init 2017-04-21 18:43:26 +08:00
ip_mroute.h init 2017-04-21 18:43:26 +08:00
ip_options.c init 2017-04-21 18:43:26 +08:00
ip_options.h init 2017-04-21 18:43:26 +08:00
ip_output.c init 2017-04-21 18:43:26 +08:00
ip_reass.c init 2017-04-21 18:43:26 +08:00
ip_var.h init 2017-04-21 18:43:26 +08:00
pim.h init 2017-04-21 18:43:26 +08:00
pim_var.h init 2017-04-21 18:43:26 +08:00
raw_ip.c init 2017-04-21 18:43:26 +08:00
sctp.h init 2017-04-21 18:43:26 +08:00
sctp_asconf.c init 2017-04-21 18:43:26 +08:00
sctp_asconf.h init 2017-04-21 18:43:26 +08:00
sctp_auth.c init 2017-04-21 18:43:26 +08:00
sctp_auth.h init 2017-04-21 18:43:26 +08:00
sctp_bsd_addr.c init 2017-04-21 18:43:26 +08:00
sctp_bsd_addr.h init 2017-04-21 18:43:26 +08:00
sctp_cc_functions.c init 2017-04-21 18:43:26 +08:00
sctp_constants.h init 2017-04-21 18:43:26 +08:00
sctp_crc32.c init 2017-04-21 18:43:26 +08:00
sctp_crc32.h init 2017-04-21 18:43:26 +08:00
sctp_dtrace_declare.h init 2017-04-21 18:43:26 +08:00
sctp_dtrace_define.h init 2017-04-21 18:43:26 +08:00
sctp_header.h init 2017-04-21 18:43:26 +08:00
sctp_indata.c init 2017-04-21 18:43:26 +08:00
sctp_indata.h init 2017-04-21 18:43:26 +08:00
sctp_input.c init 2017-04-21 18:43:26 +08:00
sctp_input.h init 2017-04-21 18:43:26 +08:00
sctp_lock_bsd.h init 2017-04-21 18:43:26 +08:00
sctp_os.h init 2017-04-21 18:43:26 +08:00
sctp_os_bsd.h init 2017-04-21 18:43:26 +08:00
sctp_output.c init 2017-04-21 18:43:26 +08:00
sctp_output.h init 2017-04-21 18:43:26 +08:00
sctp_pcb.c init 2017-04-21 18:43:26 +08:00
sctp_pcb.h init 2017-04-21 18:43:26 +08:00
sctp_peeloff.c init 2017-04-21 18:43:26 +08:00
sctp_peeloff.h init 2017-04-21 18:43:26 +08:00
sctp_ss_functions.c init 2017-04-21 18:43:26 +08:00
sctp_structs.h init 2017-04-21 18:43:26 +08:00
sctp_syscalls.c init 2017-04-21 18:43:26 +08:00
sctp_sysctl.c init 2017-04-21 18:43:26 +08:00
sctp_sysctl.h init 2017-04-21 18:43:26 +08:00
sctp_timer.c init 2017-04-21 18:43:26 +08:00
sctp_timer.h init 2017-04-21 18:43:26 +08:00
sctp_uio.h init 2017-04-21 18:43:26 +08:00
sctp_usrreq.c init 2017-04-21 18:43:26 +08:00
sctp_var.h init 2017-04-21 18:43:26 +08:00
sctputil.c init 2017-04-21 18:43:26 +08:00
sctputil.h init 2017-04-21 18:43:26 +08:00
siftr.c init 2017-04-21 18:43:26 +08:00
tcp.h init 2017-04-21 18:43:26 +08:00
tcp_debug.c init 2017-04-21 18:43:26 +08:00
tcp_debug.h init 2017-04-21 18:43:26 +08:00
tcp_fastopen.c init 2017-04-21 18:43:26 +08:00
tcp_fastopen.h init 2017-04-21 18:43:26 +08:00
tcp_fsm.h init 2017-04-21 18:43:26 +08:00
tcp_hostcache.c init 2017-04-21 18:43:26 +08:00
tcp_hostcache.h init 2017-04-21 18:43:26 +08:00
tcp_input.c init 2017-04-21 18:43:26 +08:00
tcp_lro.c init 2017-04-21 18:43:26 +08:00
tcp_lro.h init 2017-04-21 18:43:26 +08:00
tcp_offload.c init 2017-04-21 18:43:26 +08:00
tcp_offload.h init 2017-04-21 18:43:26 +08:00
tcp_output.c init 2017-04-21 18:43:26 +08:00
tcp_pcap.c init 2017-04-21 18:43:26 +08:00
tcp_pcap.h init 2017-04-21 18:43:26 +08:00
tcp_reass.c init 2017-04-21 18:43:26 +08:00
tcp_sack.c init 2017-04-21 18:43:26 +08:00
tcp_seq.h init 2017-04-21 18:43:26 +08:00
tcp_subr.c init 2017-04-21 18:43:26 +08:00
tcp_syncache.c add lvs toa option 2017-09-04 23:19:12 -04:00
tcp_syncache.h init 2017-04-21 18:43:26 +08:00
tcp_timer.c init 2017-04-21 18:43:26 +08:00
tcp_timer.h init 2017-04-21 18:43:26 +08:00
tcp_timewait.c init 2017-04-21 18:43:26 +08:00
tcp_usrreq.c add lvs toa option 2017-09-04 23:19:12 -04:00
tcp_var.h init 2017-04-21 18:43:26 +08:00
tcpip.h init 2017-04-21 18:43:26 +08:00
toecore.c init 2017-04-21 18:43:26 +08:00
toecore.h init 2017-04-21 18:43:26 +08:00
udp.h init 2017-04-21 18:43:26 +08:00
udp_usrreq.c init 2017-04-21 18:43:26 +08:00
udp_var.h init 2017-04-21 18:43:26 +08:00
udplite.h init 2017-04-21 18:43:26 +08:00