From: Jérémie Galarneau Date: Wed, 31 Aug 2016 04:18:29 +0000 (-0400) Subject: Fix: check for sizeof sa_family to save sa_family in accept and connect X-Git-Tag: v2.9.0-rc1~22 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5a561ac39cd77ecda3fbdb2bfaafac56b174225c;p=lttng-modules.git Fix: check for sizeof sa_family to save sa_family in accept and connect The check of addrlen >= sizeof(struct sockaddr) is too restrictive and causes sa_family to not be saved in the case of AF_UNIX sockets as the addrlen returned by the syscall may be only sizeof(short). Individual checks per socket family are performed anyhow in the switch case, making this safe. Signed-off-by: Jérémie Galarneau Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h b/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h index 22c328ac..b262228f 100644 --- a/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h +++ b/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h @@ -14,7 +14,7 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(connect, TP_code_pre( sc_in( memset(tp_locvar, 0, sizeof(*tp_locvar)); - if (addrlen < sizeof(struct sockaddr)) + if (addrlen < sizeof(tp_locvar->sa_family)) goto skip_code; (void) get_user(tp_locvar->sa_family, &uservaddr->sa_family); switch (tp_locvar->sa_family) { @@ -66,7 +66,7 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(connect, (void) get_user(tp_locvar->uaddr_len, upeer_addrlen); \ ) \ sc_out( \ - if (tp_locvar->uaddr_len < sizeof(struct sockaddr)) \ + if (tp_locvar->uaddr_len < sizeof(tp_locvar->sa_family)) \ goto skip_code; \ (void) get_user(tp_locvar->sa_family, &upeer_sockaddr->sa_family); \ switch (tp_locvar->sa_family) { \