aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-11-05 15:25:27 -0500
committerAntonio Quartulli <ordex@autistici.org>2012-11-21 06:35:47 -0500
commite022b956c11084f3ee1c6ece523e14ac07b7c645 (patch)
tree70651b228c9761e765d4805e42b885411043cad4 /net/batman-adv
parentd81f78ec37ecad3a4cc0a71d0ea1f74994ec5cda (diff)
batman-adv: Use packing of 2 for all headers before an ethernet header
All packet headers in front of an ethernet header have to be completely divisible by 2 but not by 4 to make the payload after the ethernet header again 4 bytes boundary aligned. A packing of 2 is necessary to avoid extra padding at the end of the struct caused by a structure member which is larger than two bytes. Otherwise the structure would not fulfill the previously mentioned rule to avoid the misalignment of the payload after the ethernet header. It may also lead to leakage of information when the padding it not initialized before sending. Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/packet.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index df548ed196d3..1c5454d33f67 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -173,6 +173,18 @@ struct batadv_icmp_packet_rr {
173 uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; 173 uint8_t rr[BATADV_RR_LEN][ETH_ALEN];
174}; 174};
175 175
176/* All packet headers in front of an ethernet header have to be completely
177 * divisible by 2 but not by 4 to make the payload after the ethernet
178 * header again 4 bytes boundary aligned.
179 *
180 * A packing of 2 is necessary to avoid extra padding at the end of the struct
181 * caused by a structure member which is larger than two bytes. Otherwise
182 * the structure would not fulfill the previously mentioned rule to avoid the
183 * misalignment of the payload after the ethernet header. It may also lead to
184 * leakage of information when the padding it not initialized before sending.
185 */
186#pragma pack(2)
187
176struct batadv_unicast_packet { 188struct batadv_unicast_packet {
177 struct batadv_header header; 189 struct batadv_header header;
178 uint8_t ttvn; /* destination translation table version number */ 190 uint8_t ttvn; /* destination translation table version number */
@@ -216,7 +228,9 @@ struct batadv_bcast_packet {
216 /* "4 bytes boundary + 2 bytes" long to make the payload after the 228 /* "4 bytes boundary + 2 bytes" long to make the payload after the
217 * following ethernet header again 4 bytes boundary aligned 229 * following ethernet header again 4 bytes boundary aligned
218 */ 230 */
219} __packed; 231};
232
233#pragma pack()
220 234
221struct batadv_vis_packet { 235struct batadv_vis_packet {
222 struct batadv_header header; 236 struct batadv_header header;