From: Lukas Wunner <lukas@wunner.de>
To: Ralf Baechle <ralf@linux-mips.org>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-mips@vger.kernel.org, Stefan Berger <stefanb@linux.ibm.com>,
linux-crypto@vger.kernel.org
Subject: Mips handling of signed integer overflows
Date: Mon, 22 Jul 2024 16:05:12 +0200 [thread overview]
Message-ID: <Zp5nGEBD41jBnw6B@wunner.de> (raw)
Dear Mips maintainers,
back in 2006, commit 36ccf1c0e391 ("[MIPS] Make integer overflow
exceptions in kernel mode fatal.") forced the kernel to panic on
integer overflows.
But three years later in 2009, commit 68df3755e383 ("Add '-fwrapv'
to gcc CFLAGS") ensured that integer overflows are not undefined
behavior and instead force wraparound.
I assume this means that the compiler uses non-trapping instructions
for addition/subtraction on Mips. Consequently, calling die_if_kernel()
from do_ov() in arch/mips/kernel/traps.c should no longer be necessary
as it can never happen.
Can you confirm or deny this?
I came across this because ecdsa_get_signature_rs() in crypto/ecdsa.c
performs a subtraction which may lead to a signed integer overflow:
https://lore.kernel.org/all/Zp5b7ZQaXfGbkCVC@wunner.de/
If gcc ignores -fno-strict-overflow on Mips and raises an exception,
the kernel would panic in ecdsa_get_signature_rs() for a sufficiently
large ASN.1-encoded integer.
Thanks,
Lukas
next reply other threads:[~2024-07-22 14:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 14:05 Lukas Wunner [this message]
2024-07-22 14:59 ` Mips handling of signed integer overflows Maciej W. Rozycki
2024-07-28 16:26 ` Lukas Wunner
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=Zp5nGEBD41jBnw6B@wunner.de \
--to=lukas@wunner.de \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=ralf@linux-mips.org \
--cc=stefanb@linux.ibm.com \
--cc=tsbogend@alpha.franken.de \
/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