OSDN Git Service

signal: Introduce clear_siginfo
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 24 Jul 2017 20:28:56 +0000 (15:28 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Fri, 12 Jan 2018 20:21:06 +0000 (14:21 -0600)
Unfortunately struct siginfo has holes both in the common part of the
structure, in the union members, and in the lack of padding of the
union members.  The result of those wholes is that the C standard does
not guarantee those bits will be initialized.  As struct siginfo is
for communication between the kernel and userspace that is a problem.

Add the helper function clear_siginfo that is guaranteed to clear all of
the bits in struct siginfo so when the structure is copied there is no danger
of copying old kernel data and causing a leak of information from kernel
space to userspace.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
include/linux/signal.h

index 8037b50..87abf0c 100644 (file)
@@ -16,6 +16,11 @@ static inline void copy_siginfo(struct siginfo *to, const struct siginfo *from)
        memcpy(to, from, sizeof(*to));
 }
 
+static inline void clear_siginfo(struct siginfo *info)
+{
+       memset(info, 0, sizeof(*info));
+}
+
 int copy_siginfo_to_user(struct siginfo __user *to, const struct siginfo *from);
 
 enum siginfo_layout {