linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Song Liu <song@kernel.org>, Fangrui Song <maskray@google.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
	x86@kernel.org, clang-built-linux <llvm@lists.linux.dev>,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH] x86/vmlinux: Fix linker fill bytes for ld.lld
Date: Wed, 6 Sep 2023 11:06:02 -0700	[thread overview]
Message-ID: <202309061102.DB794AD295@keescook> (raw)
In-Reply-To: <20230906175215.2236033-1-song@kernel.org>

On Wed, Sep 06, 2023 at 10:52:15AM -0700, Song Liu wrote:
> With ":text =0xcccc", ld.lld fills unused text area with 0xcccc0000.
> Example objdump -D output:
> 
> ffffffff82b04203:       00 00                   add    %al,(%rax)
> ffffffff82b04205:       cc                      int3
> ffffffff82b04206:       cc                      int3
> ffffffff82b04207:       00 00                   add    %al,(%rax)
> ffffffff82b04209:       cc                      int3
> ffffffff82b0420a:       cc                      int3
> 
> Replace it with ":text =0xcccccccc", so we get the following instead:
> 
> ffffffff82b04203:       cc                      int3
> ffffffff82b04204:       cc                      int3
> ffffffff82b04205:       cc                      int3
> ffffffff82b04206:       cc                      int3
> ffffffff82b04207:       cc                      int3
> ffffffff82b04208:       cc                      int3
> 
> gcc/ld doesn't seem to have the same issue. The generated code stays the
> same for gcc/ld.
> 
> Cc: Kees Cook <keescook@chromium.org>
> Cc: x86@kernel.org
> Signed-off-by: Song Liu <song@kernel.org>

Ah! Thanks for the catch... I wonder if ld.lld should be fixed too? My
understanding was that ":text =...." was defined as being explicitly
u16?

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

  reply	other threads:[~2023-09-06 18:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 17:52 [PATCH] x86/vmlinux: Fix linker fill bytes for ld.lld Song Liu
2023-09-06 18:06 ` Kees Cook [this message]
2023-09-06 18:16   ` Song Liu
2023-09-06 18:27     ` Fangrui Song
2023-09-06 19:58 ` Peter Zijlstra
2023-09-06 20:02   ` Song Liu
2023-09-06 21:57 ` [tip: x86/urgent] x86/build: Fix linker fill bytes quirk/incompatibility " tip-bot2 for Song Liu

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=202309061102.DB794AD295@keescook \
    --to=keescook@chromium.org \
    --cc=kernel-team@meta.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=maskray@google.com \
    --cc=song@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).