mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix an inproper alignment accessing in irda protocol stack
@ 2006-06-08  7:15 Luke Yang
  2006-06-08  7:30 ` Andrew Morton
  2006-06-14  2:29 ` Luke Yang
  0 siblings, 2 replies; 11+ messages in thread
From: Luke Yang @ 2006-06-08  7:15 UTC (permalink / raw)
  To: samuel, Andrew Morton, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1335 bytes --]

Hi all,

 For "struct irda_device_info" in irda.h:
struct irda_device_info {
	__u32       saddr;    /* Address of local interface */
	__u32       daddr;    /* Address of remote device */
	char        info[22]; /* Description */
	__u8        charset;  /* Charset used for description */
	__u8        hints[2]; /* Hint bits */
};
   The "hints" member aligns at the third byte of a word, an odd
address. So if we visit "hints" as a short in irlmp.c:

    u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word;

  will cause alignment problem on some machines. Architectures with
strict alignment rules do not allow 16-bit read on an odd address.

Signed-off-by: Luke Yang <luke.adi@gmail.com>

 irlmp.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

--- net/irda/irlmp.c.old        2006-06-08 14:49:20.000000000 +0800
+++ net/irda/irlmp.c    2006-06-08 14:54:29.000000000 +0800
@@ -849,7 +849,8 @@
        }

        /* Construct new discovery info to be used by IrLAP, */
-       u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word;
+       irlmp->discovery_cmd.data.hints[0] = irlmp->hints.word & 0xff;
+       irlmp->discovery_cmd.data.hints[1] = (irlmp->hints.word & 0xff00) >> 8;

        /*
         *  Set character set for device name (we use ASCII), and

-- 
Best regards,
Luke Yang
luke.adi@gmail.com

[-- Attachment #2: irlmp_alignment_fixing.patch --]
[-- Type: text/x-patch, Size: 470 bytes --]

--- net/irda/irlmp.c.old	2006-06-08 14:49:20.000000000 +0800
+++ net/irda/irlmp.c	2006-06-08 14:54:29.000000000 +0800
@@ -849,7 +849,8 @@
 	}
 
 	/* Construct new discovery info to be used by IrLAP, */
-	u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word;
+	irlmp->discovery_cmd.data.hints[0] = irlmp->hints.word & 0xff;
+	irlmp->discovery_cmd.data.hints[1] = (irlmp->hints.word & 0xff00) >> 8;
 
 	/*
 	 *  Set character set for device name (we use ASCII), and

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-07-11  4:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-08  7:15 [PATCH] Fix an inproper alignment accessing in irda protocol stack Luke Yang
2006-06-08  7:30 ` Andrew Morton
2006-06-09  3:45   ` Luke Yang
2006-06-09  5:01     ` David Miller
2006-06-14  2:29 ` Luke Yang
2006-06-14  3:42   ` David Miller
2006-06-18  5:14   ` David Miller
2006-07-11  2:12     ` Luke Yang
2006-07-11  3:29       ` David Miller
2006-07-11  4:19         ` Luke Yang
2006-07-11  4:33           ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®