Fix: check for sizeof sa_family to save sa_family in accept and connect
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 31 Aug 2016 04:18:29 +0000 (00:18 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 31 Aug 2016 15:33:10 +0000 (11:33 -0400)
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 <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h

index 22c328ac397e7205a1d09a73dc2f96ea7d1a8a9d..b262228f9a641835a287489ebd724ac27e696ee8 100644 (file)
@@ -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) {                                                                         \
This page took 0.028406 seconds and 4 git commands to generate.