diff options
author | Koen Kooi <koen@dominion.thruhere.net> | 2012-03-19 12:31:46 +0100 |
---|---|---|
committer | Denys Dmytriyenko <denys@ti.com> | 2012-03-19 14:33:49 -0400 |
commit | ebbeb55561f15e6ebf760e5b735a92bcdcdeaca1 (patch) | |
tree | 74a53bd3d39d692d6f44e329908bd52c2408bb28 /recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.10/0001-autofs-work-around-unhappy-compat-problem-on-x86-64.patch | |
parent | 0d0e2c1e274e1885d8b5cb07421449e9d0016c2c (diff) | |
download | meta-ti-ebbeb55561f15e6ebf760e5b735a92bcdcdeaca1.tar.gz |
linux-ti335x-psp 3.2: update to v3.2.11
Also add script used to generate patches and SRC_URI
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Denys Dmytriyenko <denys@ti.com>
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.10/0001-autofs-work-around-unhappy-compat-problem-on-x86-64.patch')
-rw-r--r-- | recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.10/0001-autofs-work-around-unhappy-compat-problem-on-x86-64.patch | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.10/0001-autofs-work-around-unhappy-compat-problem-on-x86-64.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.10/0001-autofs-work-around-unhappy-compat-problem-on-x86-64.patch new file mode 100644 index 00000000..16804db8 --- /dev/null +++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.10/0001-autofs-work-around-unhappy-compat-problem-on-x86-64.patch | |||
@@ -0,0 +1,142 @@ | |||
1 | From 472122b7b0040118eae3846c9bfbb97225f1ab11 Mon Sep 17 00:00:00 2001 | ||
2 | From: Ian Kent <raven@themaw.net> | ||
3 | Date: Wed, 22 Feb 2012 20:45:44 +0800 | ||
4 | Subject: [PATCH 01/95] autofs: work around unhappy compat problem on x86-64 | ||
5 | |||
6 | commit a32744d4abae24572eff7269bc17895c41bd0085 upstream. | ||
7 | |||
8 | When the autofs protocol version 5 packet type was added in commit | ||
9 | 5c0a32fc2cd0 ("autofs4: add new packet type for v5 communications"), it | ||
10 | obvously tried quite hard to be word-size agnostic, and uses explicitly | ||
11 | sized fields that are all correctly aligned. | ||
12 | |||
13 | However, with the final "char name[NAME_MAX+1]" array at the end, the | ||
14 | actual size of the structure ends up being not very well defined: | ||
15 | because the struct isn't marked 'packed', doing a "sizeof()" on it will | ||
16 | align the size of the struct up to the biggest alignment of the members | ||
17 | it has. | ||
18 | |||
19 | And despite all the members being the same, the alignment of them is | ||
20 | different: a "__u64" has 4-byte alignment on x86-32, but native 8-byte | ||
21 | alignment on x86-64. And while 'NAME_MAX+1' ends up being a nice round | ||
22 | number (256), the name[] array starts out a 4-byte aligned. | ||
23 | |||
24 | End result: the "packed" size of the structure is 300 bytes: 4-byte, but | ||
25 | not 8-byte aligned. | ||
26 | |||
27 | As a result, despite all the fields being in the same place on all | ||
28 | architectures, sizeof() will round up that size to 304 bytes on | ||
29 | architectures that have 8-byte alignment for u64. | ||
30 | |||
31 | Note that this is *not* a problem for 32-bit compat mode on POWER, since | ||
32 | there __u64 is 8-byte aligned even in 32-bit mode. But on x86, 32-bit | ||
33 | and 64-bit alignment is different for 64-bit entities, and as a result | ||
34 | the structure that has exactly the same layout has different sizes. | ||
35 | |||
36 | So on x86-64, but no other architecture, we will just subtract 4 from | ||
37 | the size of the structure when running in a compat task. That way we | ||
38 | will write the properly sized packet that user mode expects. | ||
39 | |||
40 | Not pretty. Sadly, this very subtle, and unnecessary, size difference | ||
41 | has been encoded in user space that wants to read packets of *exactly* | ||
42 | the right size, and will refuse to touch anything else. | ||
43 | |||
44 | Reported-and-tested-by: Thomas Meyer <thomas@m3y3r.de> | ||
45 | Signed-off-by: Ian Kent <raven@themaw.net> | ||
46 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
47 | Cc: Jonathan Nieder <jrnieder@gmail.com> | ||
48 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
49 | --- | ||
50 | fs/autofs4/autofs_i.h | 1 + | ||
51 | fs/autofs4/dev-ioctl.c | 1 + | ||
52 | fs/autofs4/inode.c | 2 ++ | ||
53 | fs/autofs4/waitq.c | 22 +++++++++++++++++++--- | ||
54 | 4 files changed, 23 insertions(+), 3 deletions(-) | ||
55 | |||
56 | diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h | ||
57 | index 326dc08..308a98b 100644 | ||
58 | --- a/fs/autofs4/autofs_i.h | ||
59 | +++ b/fs/autofs4/autofs_i.h | ||
60 | @@ -110,6 +110,7 @@ struct autofs_sb_info { | ||
61 | int sub_version; | ||
62 | int min_proto; | ||
63 | int max_proto; | ||
64 | + int compat_daemon; | ||
65 | unsigned long exp_timeout; | ||
66 | unsigned int type; | ||
67 | int reghost_enabled; | ||
68 | diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c | ||
69 | index 509fe1e..56bac70 100644 | ||
70 | --- a/fs/autofs4/dev-ioctl.c | ||
71 | +++ b/fs/autofs4/dev-ioctl.c | ||
72 | @@ -385,6 +385,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp, | ||
73 | sbi->pipefd = pipefd; | ||
74 | sbi->pipe = pipe; | ||
75 | sbi->catatonic = 0; | ||
76 | + sbi->compat_daemon = is_compat_task(); | ||
77 | } | ||
78 | out: | ||
79 | mutex_unlock(&sbi->wq_mutex); | ||
80 | diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c | ||
81 | index 8179f1a..98a5695 100644 | ||
82 | --- a/fs/autofs4/inode.c | ||
83 | +++ b/fs/autofs4/inode.c | ||
84 | @@ -19,6 +19,7 @@ | ||
85 | #include <linux/parser.h> | ||
86 | #include <linux/bitops.h> | ||
87 | #include <linux/magic.h> | ||
88 | +#include <linux/compat.h> | ||
89 | #include "autofs_i.h" | ||
90 | #include <linux/module.h> | ||
91 | |||
92 | @@ -224,6 +225,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent) | ||
93 | set_autofs_type_indirect(&sbi->type); | ||
94 | sbi->min_proto = 0; | ||
95 | sbi->max_proto = 0; | ||
96 | + sbi->compat_daemon = is_compat_task(); | ||
97 | mutex_init(&sbi->wq_mutex); | ||
98 | spin_lock_init(&sbi->fs_lock); | ||
99 | sbi->queues = NULL; | ||
100 | diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c | ||
101 | index e1fbdee..6861f61 100644 | ||
102 | --- a/fs/autofs4/waitq.c | ||
103 | +++ b/fs/autofs4/waitq.c | ||
104 | @@ -90,7 +90,24 @@ static int autofs4_write(struct file *file, const void *addr, int bytes) | ||
105 | |||
106 | return (bytes > 0); | ||
107 | } | ||
108 | - | ||
109 | + | ||
110 | +/* | ||
111 | + * The autofs_v5 packet was misdesigned. | ||
112 | + * | ||
113 | + * The packets are identical on x86-32 and x86-64, but have different | ||
114 | + * alignment. Which means that 'sizeof()' will give different results. | ||
115 | + * Fix it up for the case of running 32-bit user mode on a 64-bit kernel. | ||
116 | + */ | ||
117 | +static noinline size_t autofs_v5_packet_size(struct autofs_sb_info *sbi) | ||
118 | +{ | ||
119 | + size_t pktsz = sizeof(struct autofs_v5_packet); | ||
120 | +#if defined(CONFIG_X86_64) && defined(CONFIG_COMPAT) | ||
121 | + if (sbi->compat_daemon > 0) | ||
122 | + pktsz -= 4; | ||
123 | +#endif | ||
124 | + return pktsz; | ||
125 | +} | ||
126 | + | ||
127 | static void autofs4_notify_daemon(struct autofs_sb_info *sbi, | ||
128 | struct autofs_wait_queue *wq, | ||
129 | int type) | ||
130 | @@ -147,8 +164,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi, | ||
131 | { | ||
132 | struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet; | ||
133 | |||
134 | - pktsz = sizeof(*packet); | ||
135 | - | ||
136 | + pktsz = autofs_v5_packet_size(sbi); | ||
137 | packet->wait_queue_token = wq->wait_queue_token; | ||
138 | packet->len = wq->name.len; | ||
139 | memcpy(packet->name, wq->name.name, wq->name.len); | ||
140 | -- | ||
141 | 1.7.9.4 | ||
142 | |||