On Fri, Dec 12, 2014 at 09:11:36AM -0800, David Daney wrote: > Please state how this patch effects binary compatibility with > previous releases of the kernel. Hi David, the kernel returns a random value in the field si_stime. With the patch applied, the correct value is present in the field. This is the only change visible in userspace, because copy_siginfo() is used just for coping done in kernel. To the userspace data are copried by a different function - copy_siginfo_to_user(), which copies field by field, so information leakage caused by this change is not possible. Here is an output from a program (attached), which illustrates the issue: X86_64: usage.ru_stime 1000 ms info->si_stime 1000 ms (64) MIPS (Octeon) with the patch applied: usage.ru_stime 1000 ms info->si_stime 1000 ms (64) MIPS (Octeon) without the patch (3 executions): usage.ru_stime 1000 ms info->si_stime 5532471680 ms (20f9e1c0) usage.ru_stime 1000 ms info->si_stime 5532484000 ms (20f9e690) usage.ru_stime 1000 ms info->si_stime 5532484640 ms (20f9e6d0) Regards, Petr
// // Fork a child, which spends 1 second in system and print // stime obtained from getrusage and stime received in siginfo // of the SIGCHLD // #include <sys/resource.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/wait.h> #include <stdlib.h> #include <signal.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> void handler(int sig, siginfo_t *info, void *context) { printf("info->si_stime %ld ms (%lx)\n", 1000 * info->si_stime / sysconf(_SC_CLK_TCK), info->si_stime); } int main(int argc, char *argv[]) { struct sigaction act = { .sa_sigaction = handler, .sa_flags = SA_SIGINFO }; sigaction(SIGCHLD, &act, NULL); if (fork()) { wait(NULL); } else { struct rusage usage; do { int fd = open("/proc/self/maps", O_RDONLY); char buf[4096]; read(fd, buf, sizeof buf); close(fd); getrusage(RUSAGE_SELF, &usage); } while (usage.ru_stime.tv_sec < 1); printf("usage.ru_stime %ld ms\n", 1000 * usage.ru_stime.tv_sec + usage.ru_stime.tv_usec / 1000); } return 0; }