]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.39/patches.fixes/taskstats-align
Imported linux-2.6.27.39 suse/xen patches.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.fixes / taskstats-align
1 From: Jeff Mahoney <jeffm@suse.com>
2 Subject: [PATCH] delayacct: align to 8 byte boundary on 64-bit systems
3 References: bnc#492547 bnc#448410
4
5 prepare_reply sets up an skb for the response. If I understand it correctly,
6 the payload contains:
7
8 +--------------------------------+
9 | genlmsghdr - 4 bytes |
10 +--------------------------------+
11 | NLA header - 4 bytes | /* Aggregate header */
12 +-+------------------------------+
13 | | NLA header - 4 bytes | /* PID header */
14 | +------------------------------+
15 | | pid/tgid - 4 bytes |
16 | +------------------------------+
17 | | NLA header - 4 bytes | /* stats header */
18 | + -----------------------------+ <- oops. aligned on 4 byte boundary
19 | | struct taskstats - 328 bytes |
20 +-+------------------------------+
21
22 The start of the taskstats struct must be 8 byte aligned on IA64 (and other
23 systems with 8 byte alignment rules for 64-bit types) or runtime alignment
24 warnings will be issued.
25
26 This patch pads the pid/tgid field out to sizeof(long), which forces
27 the alignment of taskstats. The getdelays userspace code is ok with this
28 since it assumes 32-bit pid/tgid and then honors that header's length field.
29
30 An array is used to avoid exposing kernel memory contents to userspace in the
31 response.
32
33 Signed-off-by: Jeff Mahoney <jeffm@suse.com>
34 ---
35 kernel/taskstats.c | 8 +++++++-
36 1 file changed, 7 insertions(+), 1 deletion(-)
37
38 --- a/kernel/taskstats.c
39 +++ b/kernel/taskstats.c
40 @@ -362,6 +362,12 @@ static struct taskstats *mk_reply(struct
41 struct nlattr *na, *ret;
42 int aggr;
43
44 + /* If we don't pad, we end up with alignment on a 4 byte boundary.
45 + * This causes lots of runtime warnings on systems requiring 8 byte
46 + * alignment */
47 + u32 pids[2] = { pid, 0 };
48 + int pid_size = ALIGN(sizeof(pid), sizeof(long));
49 +
50 aggr = (type == TASKSTATS_TYPE_PID)
51 ? TASKSTATS_TYPE_AGGR_PID
52 : TASKSTATS_TYPE_AGGR_TGID;
53 @@ -369,7 +375,7 @@ static struct taskstats *mk_reply(struct
54 na = nla_nest_start(skb, aggr);
55 if (!na)
56 goto err;
57 - if (nla_put(skb, type, sizeof(pid), &pid) < 0)
58 + if (nla_put(skb, type, pid_size, pids) < 0)
59 goto err;
60 ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats));
61 if (!ret)