mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'hpa@zytor.com'" <hpa@zytor.com>,
	Ian Rogers <irogers@google.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "Borislav Petkov" <bp@alien8.de>,
	"x86@kernel.org" <x86@kernel.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	"Josh Poimboeuf" <jpoimboe@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Numfor Mbiziwo-Tiapo <nums@google.com>
Subject: RE: [PATCH v2] x86/insn, tools/x86: Fix some potential undefined behavior.
Date: Fri, 16 Oct 2020 08:47:33 +0000	[thread overview]
Message-ID: <ba2fdf7e25f3476ca4a48b48065614f0@AcuMS.aculab.com> (raw)
In-Reply-To: <5E711F64-A9BF-48EC-83A3-3C644D80F848@zytor.com>

From: hpa@zytor.com
> Sent: 15 October 2020 22:35
> >Don't perform unaligned loads in __get_next and __peek_nbyte_next as
> >these are forms of undefined behavior.
...
> > #define __get_next(t, insn)	\
> >-	({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; })
> >+	({ t r; memcpy(&r, insn->next_byte, sizeof(t)); insn->next_byte += sizeof(t); r; })

Interesting other idea.
Can you add an 'aligned(1)' into the '*(t *)' cast?
I think '*(t aligned(1) *)' is the right cast.
(gcc seems to accept it either size of the type.)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  parent reply	other threads:[~2020-10-16  8:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 16:12 Ian Rogers
2020-10-15 21:34 ` hpa
2020-10-15 21:47   ` Ian Rogers
2020-10-16  8:24     ` David Laight
2020-10-16  8:47   ` David Laight [this message]
2020-10-16  9:37   ` Peter Zijlstra
2020-10-16  1:33 ` Masami Hiramatsu

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=ba2fdf7e25f3476ca4a48b48065614f0@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=irogers@google.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nums@google.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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

Powered by JetHome