lkml.org 
[lkml]   [2012]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] coredump: add a new elf note with siginfo fields of the signal
On 09/13, Denys Vlasenko wrote:
>
> This patch adds a new elf note, NT_SIGINFO, which contains
> the remaining fields of siginfo_t.

I can't really comment this patch, but...

> +struct coredump_siginfo {
> +/* int csi_signo; in prstatus.pr_info.si_signo instead */
> +/* int csi_errno; in prstatus.pr_info.si_errno */
> +/* int csi_code; in prstatus.pr_info.si_code */
> + int csi_pid; /* PID of sending process */
> + int csi_uid; /* Real UID of sending process */
> +/* int csi_status; SIGCHLD never kills, field isn't meaningful */
> +/* clock_t csi_utime; SIGCHLD never kills, field isn't meaningful */
> +/* clock_t csi_stime; SIGCHLD never kills, field isn't meaningful */
> + void *csi_ptr; /* union with si_int */
> + int csi_tid; /* POSIX.1b timers */
> + int csi_overrun; /* POSIX.1b timers */
> + long csi_band; /* SIGIO/POLL: band event */
> + int csi_fd; /* SIGIO/POLL: file descriptor */
> + void *csi_addr; /* SEGV/BUS: address which caused fault */
> + int csi_trapno; /* SEGV/BUS */
> + int csi_addr_lsb; /* SEGV/BUS: least significant bit of address */
> + /* Can be extended in the future, if siginfo_t is extended */
> +};
> +
> +static void fill_siginfo_note(struct memelfnote *note, struct coredump_siginfo *data, siginfo_t *siginfo)
> +{
> + data->csi_pid = siginfo->si_pid;
> + data->csi_uid = siginfo->si_uid;
> + data->csi_ptr = siginfo->si_ptr;
> + data->csi_overrun = siginfo->si_overrun;
> + data->csi_tid = siginfo->si_tid;
> + data->csi_band = siginfo->si_band;
> + data->csi_fd = siginfo->si_fd;
> + data->csi_addr = siginfo->si_addr;
> +#ifdef __ARCH_SI_TRAPNO
> + data->csi_trapno = siginfo->si_trapno;
> +#endif
> + /* Prevent signed short->int expansion: */
> + data->csi_addr_lsb = (unsigned short)siginfo->si_addr_lsb;
> +
> + fill_note(note, "CORE", NT_SIGINFO, sizeof(*data), data);
> +}

I can't understand the layout. struct siginfo is union, for example
si_overrun only makes sense if si_code = SI_TIMER.

Not sure this is right. I think fill_siginfo_note() should either do
memcpy() and let userspace to decode this (raw) info, or this layout
should be unified with copy_siginfo_to_user().

Note also that we do not expose the upper bits of si_code to user-space,
probably coredump should do the same, I dunno.

Oleg.



\
 
 \ /
  Last update: 2012-09-13 18:21    [W:2.625 / U:1.208 seconds]
©2003-2014 Jasper Spaans. Advertise on this site