All of lore.kernel.org
 help / color / mirror / Atom feed
From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Julien Grall <julien@xen.org>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>
Subject: Re: [PATCH v5 2/4] xen: common: add ability to enable stack protector
Date: Mon, 17 Feb 2025 00:59:40 +0000	[thread overview]
Message-ID: <87bjv1z8qt.fsf@epam.com> (raw)
In-Reply-To: <bbfd56fd-9109-457a-8eec-854df9ab9eee@xen.org> (Julien Grall's message of "Sat, 15 Feb 2025 09:38:16 +0000")


Hi Julien,

Julien Grall <julien@xen.org> writes:

> Hi Volodymyr,
>
> On 13/02/2025 22:00, Volodymyr Babchuk wrote:
>> diff --git a/xen/common/stack-protector.c b/xen/common/stack-protector.c
>> new file mode 100644
>> index 0000000000..286753a1b1
>> --- /dev/null
>> +++ b/xen/common/stack-protector.c
>> @@ -0,0 +1,51 @@
>> +/* SPDX-License-Identifier: GPL-2.0-only */
>> +#include <xen/init.h>
>> +#include <xen/lib.h>
>> +#include <xen/random.h>
>> +#include <xen/time.h>
>> +
>> +/*
>> + * Initial value is chosen by a fair dice roll.
>> + * It will be updated during boot process.
>> + */
>> +#if BITS_PER_LONG == 32
>> +unsigned long __ro_after_init __stack_chk_guard = 0xdd2cc927UL;
>> +#else
>> +unsigned long __ro_after_init __stack_chk_guard = 0x2d853605a4d9a09cUL;
>> +#endif
>> +
>> +/*
>> + * This function should be called from early asm or from a C function
>> + * that escapes stack canary tracking (by calling
>> + * reset_stack_and_jump() for example).
>> + */
>> +void __init asmlinkage boot_stack_chk_guard_setup(void)
>
> I am probably missing something. But what prevent the compiler to
> insert a stack guard when entering this function and checking on exit?
> Wouldn't this fail because __stack_chk_guard would be different?

Yes, you are right. I got carried away a bit this time. It is working
right now only because GCC does not emit stack checking code in this
particular function. With "-fstack-protector-all" it panics, as expected.

> IOW, shouldn't this function be a static always inline like it used to be?

Yes, I am going to make it inline in the next version.


-- 
WBR, Volodymyr

  reply	other threads:[~2025-02-17  1:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-13 22:00 [PATCH v5 for-4.20(?) 0/4] Add/enable stack protector Volodymyr Babchuk
2025-02-13 22:00 ` [PATCH v5 1/4] common: remove -fno-stack-protector from EMBEDDED_EXTRA_CFLAGS Volodymyr Babchuk
2025-02-14  8:02   ` Jan Beulich
2025-02-13 22:00 ` [PATCH v5 4/4] CHANGELOG.md: Mention stack-protector feature Volodymyr Babchuk
2025-02-13 22:00 ` [PATCH v5 3/4] xen: arm: enable stack protector feature Volodymyr Babchuk
2025-02-15  9:46   ` Julien Grall
2025-02-13 22:00 ` [PATCH v5 2/4] xen: common: add ability to enable stack protector Volodymyr Babchuk
2025-02-14  8:05   ` Jan Beulich
2025-02-15  9:38   ` Julien Grall
2025-02-17  0:59     ` Volodymyr Babchuk [this message]
2025-02-13 23:18 ` [PATCH v5 for-4.20(?) 0/4] Add/enable " Andrew Cooper
2025-02-14  0:34   ` Volodymyr Babchuk
2025-02-14  0:38     ` Andrew Cooper

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=87bjv1z8qt.fsf@epam.com \
    --to=volodymyr_babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.