From: Florian Fainelli <florian.fainelli@broadcom.com>
To: stable@vger.kernel.org
Cc: Tiwei Bie <tiwei.btw@antgroup.com>,
Johannes Berg <johannes.berg@intel.com>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Richard Weinberger <richard@nod.at>,
Anton Ivanov <anton.ivanov@cambridgegreys.com>,
Johannes Berg <johannes@sipsolutions.net>,
Brendan Higgins <brendan.higgins@linux.dev>,
David Gow <david@davidgow.net>, Rae Moar <raemoar63@gmail.com>,
Kees Cook <kees@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-um@lists.infradead.org (open list:USER-MODE LINUX (UML)),
linux-kernel@vger.kernel.org (open list),
linux-kselftest@vger.kernel.org (open list:KERNEL UNIT TESTING
FRAMEWORK (KUnit)),
kunit-dev@googlegroups.com (open list:KERNEL UNIT TESTING
FRAMEWORK (KUnit)),
bcm-kernel-feedback-list@broadcom.com
Subject: [PATCH stable 6.12 9/9] um: Preserve errno within signal handler
Date: Fri, 24 Jul 2026 14:41:19 -0700 [thread overview]
Message-ID: <20260724214119.1066665-10-florian.fainelli@broadcom.com> (raw)
In-Reply-To: <20260724214119.1066665-1-florian.fainelli@broadcom.com>
From: Tiwei Bie <tiwei.btw@antgroup.com>
commit f68b2d5a907b53eed99cf2efcaaae116df73c298 upstream
We rely on errno to determine whether a syscall has failed, so we
need to ensure that accessing errno is async-signal-safe. Currently,
we preserve the errno in sig_handler_common(), but it doesn't cover
every possible case. Let's do it in hard_handler() instead, which
is the signal handler we actually register.
Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
Link: https://patch.msgid.link/20260106001228.1531146-2-tiwei.btw@antgroup.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
[florian: hard_handler() in 6.12 retains the to_irq_stack/from_irq_stack
loop from before the upstream SMP refactoring; errno save/restore is wrapped
around that loop rather than replacing sig_handler_common's existing save/restore]
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
arch/um/os-Linux/signal.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index b11ed66c8bb0..94abc9e3ec7e 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -190,6 +190,7 @@ static void hard_handler(int sig, siginfo_t *si, void *p)
{
ucontext_t *uc = p;
mcontext_t *mc = &uc->uc_mcontext;
+ int save_errno = errno;
unsigned long pending = 1UL << sig;
do {
@@ -227,6 +228,8 @@ static void hard_handler(int sig, siginfo_t *si, void *p)
if (!nested)
pending = from_irq_stack(nested);
} while (pending);
+
+ errno = save_errno;
}
void set_handler(int sig)
--
2.34.1
next prev parent reply other threads:[~2026-07-24 21:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 21:41 [PATCH stable 6.12 0/9] Kunit backports for older systems Florian Fainelli
2026-07-24 21:41 ` [PATCH stable 6.12 1/9] um: Add os_set_pdeathsig helper function Florian Fainelli
2026-07-24 21:41 ` [PATCH stable 6.12 2/9] um: Set parent death signal for winch thread/process Florian Fainelli
2026-07-24 21:41 ` [PATCH stable 6.12 3/9] um: Use os_set_pdeathsig helper in " Florian Fainelli
2026-07-24 21:41 ` [PATCH stable 6.12 4/9] um: Set parent-death signal for ubd io thread/process Florian Fainelli
2026-07-24 21:41 ` [PATCH stable 6.12 5/9] um: Set parent-death signal for write_sigio thread/process Florian Fainelli
2026-07-24 21:41 ` [PATCH stable 6.12 6/9] um: Set parent death signal for userspace process Florian Fainelli
2026-07-24 21:41 ` [PATCH stable 6.12 7/9] kunit: tool: Terminate kernel under test on SIGINT Florian Fainelli
2026-07-24 21:41 ` [PATCH stable 6.12 8/9] kunit: tool: skip stty when stdin is not a tty Florian Fainelli
2026-07-24 21:41 ` Florian Fainelli [this message]
2026-07-30 12:38 ` [PATCH stable 6.12 0/9] Kunit backports for older systems Greg KH
2026-07-30 16:07 ` Florian Fainelli
2026-07-31 2:39 ` Sasha Levin
2026-07-31 23:16 ` Florian Fainelli
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=20260724214119.1066665-10-florian.fainelli@broadcom.com \
--to=florian.fainelli@broadcom.com \
--cc=anton.ivanov@cambridgegreys.com \
--cc=axboe@kernel.dk \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=brendan.higgins@linux.dev \
--cc=david@davidgow.net \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=kees@kernel.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=raemoar63@gmail.com \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--cc=tiwei.btw@antgroup.com \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®