linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Seergey Nazarov <s-nazarov@yandex.ru>
To: Ondrej Mosnacek <omosnace@redhat.com>
Cc: Linux Security Module list 
	<linux-security-module@vger.kernel.org>,
	Paul Moore <paul@paul-moore.com>
Subject: Re: [PATCH] CIPSO: Fix unaligned memory access in cipso_v4_gentag_hdr
Date: Fri, 05 Mar 2021 10:28:25 +0300	[thread overview]
Message-ID: <50bc54bc65f78b7379a9a1114b52985a9098a3fb.camel@yandex.ru> (raw)
In-Reply-To: <CAFqZXNsgVFCa-DnG5G_Ceu+oHsFszt-TQP27Wur_RJg8bG-wMQ@mail.gmail.com>

В Чт, 04/03/2021 в 22:17 +0100, Ondrej Mosnacek пишет:
> On Thu, Mar 4, 2021 at 10:09 PM Seergey Nazarov <s-nazarov@yandex.ru>
> wrote:
> > We need to use put_unaligned when writing 32-bit DOI value
> > in cipso_v4_gentag_hdr to avoid unaligned memory access.
> > 
> > Signed-off-by: Sergey Nazarov <s-nazarov@yandex.ru>
> > ---
> >  net/ipv4/cipso_ipv4.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
> > index 471d33a..28dfe40 100644
> > --- a/net/ipv4/cipso_ipv4.c
> > +++ b/net/ipv4/cipso_ipv4.c
> > @@ -1162,7 +1162,7 @@ static void cipso_v4_gentag_hdr(const struct
> > cipso_v4_doi *doi_def,
> >  {
> >         buf[0] = IPOPT_CIPSO;
> >         buf[1] = CIPSO_V4_HDR_LEN + len;
> > -       *(__be32 *)&buf[2] = htonl(doi_def->doi);
> > +       put_unaligned_be32(doi_def->doi, (__be32 *)&buf[2]);
> 
> I think you can now also drop the cast, since put_unaligned_be32()
> expects a void *.
> 
> >  }
> > 
> >  /**
> > --
> > 1.8.3.1
> > 
> > 
> 
> 
You are right, thanks!


      parent reply	other threads:[~2021-03-05  7:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 21:00 [PATCH] CIPSO: Fix unaligned memory access in cipso_v4_gentag_hdr Seergey Nazarov
2021-03-04 21:17 ` Ondrej Mosnacek
2021-03-04 21:45   ` Paul Moore
2021-03-05  7:40     ` Seergey Nazarov
2021-03-05  7:28   ` Seergey Nazarov [this message]

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=50bc54bc65f78b7379a9a1114b52985a9098a3fb.camel@yandex.ru \
    --to=s-nazarov@yandex.ru \
    --cc=linux-security-module@vger.kernel.org \
    --cc=omosnace@redhat.com \
    --cc=paul@paul-moore.com \
    /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;
as well as URLs for NNTP newsgroup(s).