Skip to content

Commit ae7795b

Browse files
committed
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: "Eric W. Biederman" <ebiederm@xmission.com>
1 parent 4cd2e0e commit ae7795b

27 files changed

Lines changed: 165 additions & 110 deletions

File tree

‎arch/x86/include/asm/compat.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,6 @@ static inline bool in_compat_syscall(void)
240240

241241
struct compat_siginfo;
242242
int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
243-
const siginfo_t *from, bool x32_ABI);
243+
const kernel_siginfo_t *from, bool x32_ABI);
244244

245245
#endif /* _ASM_X86_COMPAT_H */

‎drivers/usb/core/devio.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ static void async_completed(struct urb *urb)
582582
{
583583
struct async *as = urb->context;
584584
struct usb_dev_state *ps = as->ps;
585-
struct siginfo sinfo;
585+
struct kernel_siginfo sinfo;
586586
struct pid *pid = NULL;
587587
const struct cred *cred = NULL;
588588
unsigned long flags;
@@ -2599,7 +2599,7 @@ const struct file_operations usbdev_file_operations = {
25992599
static void usbdev_remove(struct usb_device *udev)
26002600
{
26012601
struct usb_dev_state *ps;
2602-
struct siginfo sinfo;
2602+
struct kernel_siginfo sinfo;
26032603

26042604
while (!list_empty(&udev->filelist)) {
26052605
ps = list_entry(udev->filelist.next, struct usb_dev_state, list);

‎fs/binfmt_elf.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,7 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
15801580
}
15811581

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

17831783
static int fill_note_info(struct elfhdr *elf, int phdrs,
17841784
struct elf_note_info *info,
1785-
const siginfo_t *siginfo, struct pt_regs *regs)
1785+
const kernel_siginfo_t *siginfo, struct pt_regs *regs)
17861786
{
17871787
struct task_struct *dump_task = current;
17881788
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)
20312031

20322032
static int fill_note_info(struct elfhdr *elf, int phdrs,
20332033
struct elf_note_info *info,
2034-
const siginfo_t *siginfo, struct pt_regs *regs)
2034+
const kernel_siginfo_t *siginfo, struct pt_regs *regs)
20352035
{
20362036
struct list_head *t;
20372037
struct core_thread *ct;

‎fs/coredump.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
536536
return err;
537537
}
538538

539-
void do_coredump(const siginfo_t *siginfo)
539+
void do_coredump(const kernel_siginfo_t *siginfo)
540540
{
541541
struct core_state core_state;
542542
struct core_name cn;

‎fs/fcntl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ static void send_sigio_to_task(struct task_struct *p,
735735
return;
736736

737737
switch (signum) {
738-
siginfo_t si;
738+
kernel_siginfo_t si;
739739
default:
740740
/* Queue a rt signal with the appropriate fd as its
741741
value. We use SI_SIGIO as the source, not

‎fs/signalfd.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static __poll_t signalfd_poll(struct file *file, poll_table *wait)
7979
* Copied from copy_siginfo_to_user() in kernel/signal.c
8080
*/
8181
static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
82-
siginfo_t const *kinfo)
82+
kernel_siginfo_t const *kinfo)
8383
{
8484
struct signalfd_siginfo new;
8585

@@ -163,7 +163,7 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
163163
return sizeof(*uinfo);
164164
}
165165

166-
static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, siginfo_t *info,
166+
static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, kernel_siginfo_t *info,
167167
int nonblock)
168168
{
169169
ssize_t ret;
@@ -215,7 +215,7 @@ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count,
215215
struct signalfd_siginfo __user *siginfo;
216216
int nonblock = file->f_flags & O_NONBLOCK;
217217
ssize_t ret, total = 0;
218-
siginfo_t info;
218+
kernel_siginfo_t info;
219219

220220
count /= sizeof(struct signalfd_siginfo);
221221
if (!count)

‎include/linux/binfmts.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct linux_binprm {
7878

7979
/* Function parameter for binfmt->coredump */
8080
struct coredump_params {
81-
const siginfo_t *siginfo;
81+
const kernel_siginfo_t *siginfo;
8282
struct pt_regs *regs;
8383
struct file *file;
8484
unsigned long limit;

‎include/linux/compat.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
452452
unsigned long bitmap_size);
453453
long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
454454
unsigned long bitmap_size);
455-
int copy_siginfo_from_user32(siginfo_t *to, const struct compat_siginfo __user *from);
456-
int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from);
455+
int copy_siginfo_from_user32(kernel_siginfo_t *to, const struct compat_siginfo __user *from);
456+
int copy_siginfo_to_user32(struct compat_siginfo __user *to, const kernel_siginfo_t *from);
457457
int get_compat_sigevent(struct sigevent *event,
458458
const struct compat_sigevent __user *u_event);
459459

‎include/linux/coredump.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr);
1717
extern int dump_align(struct coredump_params *cprm, int align);
1818
extern void dump_truncate(struct coredump_params *cprm);
1919
#ifdef CONFIG_COREDUMP
20-
extern void do_coredump(const siginfo_t *siginfo);
20+
extern void do_coredump(const kernel_siginfo_t *siginfo);
2121
#else
22-
static inline void do_coredump(const siginfo_t *siginfo) {}
22+
static inline void do_coredump(const kernel_siginfo_t *siginfo) {}
2323
#endif
2424

2525
#endif /* _LINUX_COREDUMP_H */

‎include/linux/lsm_hooks.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@
672672
* Return 0 if permission is granted.
673673
* @task_kill:
674674
* Check permission before sending signal @sig to @p. @info can be NULL,
675-
* the constant 1, or a pointer to a siginfo structure. If @info is 1 or
675+
* the constant 1, or a pointer to a kernel_siginfo structure. If @info is 1 or
676676
* SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
677677
* from the kernel and should typically be permitted.
678678
* SIGIO signals are handled separately by the send_sigiotask hook in
@@ -1606,7 +1606,7 @@ union security_list_options {
16061606
int (*task_setscheduler)(struct task_struct *p);
16071607
int (*task_getscheduler)(struct task_struct *p);
16081608
int (*task_movememory)(struct task_struct *p);
1609-
int (*task_kill)(struct task_struct *p, struct siginfo *info,
1609+
int (*task_kill)(struct task_struct *p, struct kernel_siginfo *info,
16101610
int sig, const struct cred *cred);
16111611
int (*task_prctl)(int option, unsigned long arg2, unsigned long arg3,
16121612
unsigned long arg4, unsigned long arg5);

0 commit comments

Comments
 (0)