Commit ae7795bc authored by Eric W. Biederman's avatar Eric W. Biederman
Browse files

signal: Distinguish between kernel_siginfo and siginfo



Linus recently observed that if we did not worry about the padding
member in struct siginfo it is only about 48 bytes, and 48 bytes is
much nicer than 128 bytes for allocating on the stack and copying
around in the kernel.

The obvious thing of only adding the padding when userspace is
including siginfo.h won't work as there are sigframe definitions in
the kernel that embed struct siginfo.

So split siginfo in two; kernel_siginfo and siginfo.  Keeping the
traditional name for the userspace definition.  While the version that
is used internally to the kernel and ultimately will not be padded to
128 bytes is called kernel_siginfo.

The definition of struct kernel_siginfo I have put in include/signal_types.h

A set of buildtime checks has been added to verify the two structures have
the same field offsets.

To make it easy to verify the change kernel_siginfo retains the same
size as siginfo.  The reduction in size comes in a following change.

Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 4cd2e0e7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -240,6 +240,6 @@ static inline bool in_compat_syscall(void)

struct compat_siginfo;
int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
		const siginfo_t *from, bool x32_ABI);
		const kernel_siginfo_t *from, bool x32_ABI);

#endif /* _ASM_X86_COMPAT_H */
+2 −2
Original line number Diff line number Diff line
@@ -582,7 +582,7 @@ static void async_completed(struct urb *urb)
{
	struct async *as = urb->context;
	struct usb_dev_state *ps = as->ps;
	struct siginfo sinfo;
	struct kernel_siginfo sinfo;
	struct pid *pid = NULL;
	const struct cred *cred = NULL;
	unsigned long flags;
@@ -2599,7 +2599,7 @@ const struct file_operations usbdev_file_operations = {
static void usbdev_remove(struct usb_device *udev)
{
	struct usb_dev_state *ps;
	struct siginfo sinfo;
	struct kernel_siginfo sinfo;

	while (!list_empty(&udev->filelist)) {
		ps = list_entry(udev->filelist.next, struct usb_dev_state, list);
+3 −3
Original line number Diff line number Diff line
@@ -1580,7 +1580,7 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
}

static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
		const siginfo_t *siginfo)
		const kernel_siginfo_t *siginfo)
{
	mm_segment_t old_fs = get_fs();
	set_fs(KERNEL_DS);
@@ -1782,7 +1782,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,

static int fill_note_info(struct elfhdr *elf, int phdrs,
			  struct elf_note_info *info,
			  const siginfo_t *siginfo, struct pt_regs *regs)
			  const kernel_siginfo_t *siginfo, struct pt_regs *regs)
{
	struct task_struct *dump_task = current;
	const struct user_regset_view *view = task_user_regset_view(dump_task);
@@ -2031,7 +2031,7 @@ static int elf_note_info_init(struct elf_note_info *info)

static int fill_note_info(struct elfhdr *elf, int phdrs,
			  struct elf_note_info *info,
			  const siginfo_t *siginfo, struct pt_regs *regs)
			  const kernel_siginfo_t *siginfo, struct pt_regs *regs)
{
	struct list_head *t;
	struct core_thread *ct;
+1 −1
Original line number Diff line number Diff line
@@ -536,7 +536,7 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
	return err;
}

void do_coredump(const siginfo_t *siginfo)
void do_coredump(const kernel_siginfo_t *siginfo)
{
	struct core_state core_state;
	struct core_name cn;
+1 −1
Original line number Diff line number Diff line
@@ -735,7 +735,7 @@ static void send_sigio_to_task(struct task_struct *p,
		return;

	switch (signum) {
		siginfo_t si;
		kernel_siginfo_t si;
		default:
			/* Queue a rt signal with the appropriate fd as its
			   value.  We use SI_SIGIO as the source, not 
Loading