mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Luke Yang" <luke.adi@gmail.com>
To: "David Miller" <davem@davemloft.net>
Cc: samuel@sortiz.org, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix an inproper alignment accessing in irda protocol stack
Date: Tue, 11 Jul 2006 10:12:41 +0800	[thread overview]
Message-ID: <489ecd0c0607101912t4225e551sa608faa769f09064@mail.gmail.com> (raw)
In-Reply-To: <20060617.221435.48805608.davem@davemloft.net>

Hi all,

  There is another same unaligend issue in irda stack to be fixed:

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

--- linux-2.6.x/net/irda/discovery.c    2006-03-22 18:32:37.000000000 +0800
+++ ../../uClinux-dist/linux-2.6.x/net/irda/discovery.c 2006-06-30
18:07:46.000000000 +0800
@@ -38,6 +38,7 @@
 #include <net/irda/irlmp.h>

 #include <net/irda/discovery.h>
+#include <asm/unaligned.h>

 /*
  * Function irlmp_add_discovery (cachelog, discovery)
@@ -86,7 +87,7 @@
                         */
                        hashbin_remove_this(cachelog, (irda_queue_t *) node);
                        /* Check if hints bits are unchanged */
-                       if(u16ho(node->data.hints) == u16ho(new->data.hints))
+                       if(get_unaligned(node->data.hints) ==
get_unaligned(new->data.hints))
                                /* Set time of first discovery for this node */
                                new->firststamp = node->firststamp;
                        kfree(node);
@@ -280,7 +281,7 @@
                /* Mask out the ones we don't want :
                 * We want to match the discovery mask, and to get only
                 * the most recent one (unless we want old ones) */
-               if ((u16ho(discovery->data.hints) & mask) &&
+               if ((get_unaligned(discovery->data.hints) & mask) &&
                    ((old_entries) ||
                     ((jiffies - discovery->firststamp) < j_timeout)) ) {
                        /* Create buffer as needed.


Regards,
Luke Yang

On 6/18/06, David Miller <davem@davemloft.net> wrote:
> From: "Luke Yang" <luke.adi@gmail.com>
> Date: Wed, 14 Jun 2006 10:29:19 +0800
>
> > --- net/irda/irlmp.c.old        2006-06-08 14:49:20.000000000 +0800
> > +++ net/irda/irlmp.c    2006-06-14 10:00:22.000000000 +0800
> > @@ -849,7 +849,10 @@
> >         }
> >
> >         /* Construct new discovery info to be used by IrLAP, */
> > -       u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word;
> > +       irlmp->discovery_cmd.data.hints[0] = \
> > +               le16_to_cpu(irlmp->hints.word) & 0xff;
> > +       irlmp->discovery_cmd.data.hints[1] = \
> > +               (le16_to_cpu(irlmp->hints.word) & 0xff00) >> 8;
> >
> >         /*
> >          *  Set character set for device name (we use ASCII), and
>
> I decided in the end to fix this differently.
>
> We have a portable unaligned access interface, via get_unaligned() and
> put_unaligned() in asm/unaligned.h, which makes sure there is no
> penalty for platforms whose cpu does unaligned memory accesses
> transparently.
>
> diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
> index c19e9ce..57ea160 100644
> --- a/net/irda/irlmp.c
> +++ b/net/irda/irlmp.c
> @@ -44,6 +44,8 @@
>  #include <net/irda/irlmp.h>
>  #include <net/irda/irlmp_frame.h>
>
> +#include <asm/unaligned.h>
> +
>  static __u8 irlmp_find_free_slsap(void);
>  static int irlmp_slsap_inuse(__u8 slsap_sel);
>
> @@ -840,6 +842,7 @@ void irlmp_do_expiry(void)
>  void irlmp_do_discovery(int nslots)
>  {
>         struct lap_cb *lap;
> +       __u16 *data_hintsp;
>
>         /* Make sure the value is sane */
>         if ((nslots != 1) && (nslots != 6) && (nslots != 8) && (nslots != 16)){
> @@ -849,7 +852,8 @@ void irlmp_do_discovery(int nslots)
>         }
>
>         /* Construct new discovery info to be used by IrLAP, */
> -       u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word;
> +       data_hintsp = (__u16 *) irlmp->discovery_cmd.data.hints;
> +       put_unaligned(irlmp->hints.word, data_hintsp);
>
>         /*
>          *  Set character set for device name (we use ASCII), and
>


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

  reply	other threads:[~2006-07-11  2:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-08  7:15 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 [this message]
2006-07-11  3:29       ` David Miller
2006-07-11  4:19         ` Luke Yang
2006-07-11  4:33           ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=489ecd0c0607101912t4225e551sa608faa769f09064@mail.gmail.com \
    --to=luke.adi@gmail.com \
    --cc=akpm@osdl.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samuel@sortiz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®