All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@sigma-star.at>
To: Nikolaus Funk <nikolaus.funk@sigmatek.at>,
	xenomai@lists.linux.dev,
	Florian Bezdeka <florian.bezdeka@siemens.com>
Cc: Richard Weinberger <richard@nod.at>,
	Johannes Kirchmair <johannes.kirchmair@sigmatek.at>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Lorenz Kofler <lorenz@sigma-star.at>
Subject: Re: [PATCH 4/5] arm64: dovetail: Helper functions for signal frame setup and restore
Date: Tue, 08 Apr 2025 15:16:15 +0200	[thread overview]
Message-ID: <32233504.Lj2Plt8kZL@anvil> (raw)
In-Reply-To: <82af204c390c6e18089310abb3531556971754cf.camel@siemens.com>

On Dienstag, 8. April 2025 15:05 Florian Bezdeka wrote:
> > +	if (regs->sp & 15)
> > +		goto out;
> 
> - Where is this magic 15 coming from?

The stack needs to be word aligned.
This was taken from the Linux side.

> - return -EFAULT; would also work and save us one label.

Ok.

> 
> > +
> > +	frame = (struct rt_sigframe __user *)regs->sp;
> > +
> > +	pagefault_disable();
> > +
> > +	if (!access_ok(frame, sizeof (*frame)))
> > +		goto out_pfe;
> > +
> > +	if (restore_sigframe(regs, frame, &ua_state))
> > +		goto out_pfe;
> > +
> > +	restore_user_access_state(&ua_state);
> > +
> > +	ret = 0;
> > +
> > +out_pfe:
> > +	pagefault_enable();
> > +out:
> > +	return ret;
> > +}
> > +
> > +static int dovetail_restore_32_rt_signal_frame(struct pt_regs *regs)
> > +{
> > +	struct compat_rt_sigframe __user *frame;
> > +	int ret = 0;

That should be pre-initialized to -EFAULT. :-S

> > +	if (regs->sp & 7)

Given this a second thought, the check should inspect ->compat_sp, no ->sp.

> > +		goto out;
> 
> Same as above. 
> - Magic 7

The stack needs to be word aligned.

> - Is the error reporting really correct here? We would return 0.

Yes.

Thanks,
//richard

-- 
​​​​​sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y



  reply	other threads:[~2025-04-08 13:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08 12:34 [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Nikolaus Funk
2025-04-08 12:34 ` [PATCH 1/5] arm: dovetail: Fix user mode UND exception handling Nikolaus Funk
2025-04-08 12:34 ` [PATCH 2/5] x86: dovetail: Helper functions for signal frame setup and restore Nikolaus Funk
2025-04-08 12:34 ` [PATCH 3/5] arm64: dovetail: Allow early return from traps Nikolaus Funk
2025-04-08 12:58   ` Florian Bezdeka
2025-04-08 13:24     ` Richard Weinberger
2025-04-08 17:06   ` Jan Kiszka
2025-04-09  9:47     ` Richard Weinberger
2025-04-09 14:25       ` Jan Kiszka
2025-04-08 12:34 ` [PATCH 4/5] arm64: dovetail: Helper functions for signal frame setup and restore Nikolaus Funk
2025-04-08 13:05   ` Florian Bezdeka
2025-04-08 13:16     ` Richard Weinberger [this message]
2025-04-08 12:34 ` [PATCH 5/5] arm: " Nikolaus Funk
2025-04-08 13:12   ` Florian Bezdeka
2025-04-08 13:18     ` Richard Weinberger
2025-04-08 16:58 ` [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Jan Kiszka
2025-04-08 17:55   ` Richard Weinberger

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=32233504.Lj2Plt8kZL@anvil \
    --to=richard@sigma-star.at \
    --cc=florian.bezdeka@siemens.com \
    --cc=jan.kiszka@siemens.com \
    --cc=johannes.kirchmair@sigmatek.at \
    --cc=lorenz@sigma-star.at \
    --cc=nikolaus.funk@sigmatek.at \
    --cc=richard@nod.at \
    --cc=xenomai@lists.linux.dev \
    /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.