From nobody Sun Feb 8 20:32:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF706EB64DC for ; Mon, 10 Jul 2023 21:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231138AbjGJVIU (ORCPT ); Mon, 10 Jul 2023 17:08:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbjGJVIO (ORCPT ); Mon, 10 Jul 2023 17:08:14 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEA2ABF; Mon, 10 Jul 2023 14:08:12 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-307d58b3efbso4901456f8f.0; Mon, 10 Jul 2023 14:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689023291; x=1691615291; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wREkc9/s2frBQXho8+/CmRUkUf/FKLAaYC6JcuNeuKw=; b=AOa/4+nDWhX8zfxWmovYsSScEa4jmw+KEHo/LrsK1V7QSZ0S/i8tBBN8oW0o4Cmkw5 BUVboHgy9+V0i2v912vrXnZLoh9g2PIIIDCQDMaptj23UBAsOLGiJgZTuDfP76nwsuR7 DkQJbjyxIMMu/JV8x6yjPnl5u4B1KISE7UeIxLU/fAXSCx4nD0cNx+sNKor8Hl9ADzoE 5MCtaaMRf+FW9k0avTPTyRBY8HeBsGDe55mof7iodo3DzK9zgw5GiQrjlWbIWtlPBMkm zPpjtTI0Nh5jXIkF+BX4W9peDNuRTr+QUmdCQGv+ScNTXkmpdQUKXiA5OmraFaej2H9M UfcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689023291; x=1691615291; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wREkc9/s2frBQXho8+/CmRUkUf/FKLAaYC6JcuNeuKw=; b=deE/bKX6I4fDT2FShZkUd1zcVsMLRJTKfe8aTRW/ABl5+ovG4Rf4ZqbCrS8oXJ/PNp wdZRyOrb7BFYMGlb4l1VdGsAJLhrkuhXwyn89maYDzzRyo1Yz7OSpifRe4oi+eQBwdBt 5cJM3PgxS3EBJT6VnTk3SrEmkbFA7LlrSMJGzQ+tYIk3vm4S13/wzhgP7z1ZsSyatiJZ 1RtaM5hXfdVEmtlhoHnErr6U39fkgKPjBzuPJcnpSNszqGbQNOEh5wnE4MiqqZoF8plh gC6efNjaPg5YPsXza3Td50riz4gcvFDyvIjXr+VI81giSKyt85lYw6q3A7+7WkM4kzBE 72uQ== X-Gm-Message-State: ABy/qLb3UKM9miJpV/D8gUZVb7SD9rWqwI7SuuNncD++fBLumXLkRDTQ kx//DI2QS8a6Wd7y0bQ2cexazyaE5sgLgA== X-Google-Smtp-Source: APBJJlHYBAcwrGSqDfxFbssGAqXTqJroNEjE/qAl+zAEuxHi7EuOR7UuLqv3UPiQ6thnN1dT7+FuxQ== X-Received: by 2002:a5d:6b47:0:b0:314:152d:f8db with SMTP id x7-20020a5d6b47000000b00314152df8dbmr10481002wrw.58.1689023290492; Mon, 10 Jul 2023 14:08:10 -0700 (PDT) Received: from localhost (cpc1-brnt4-2-0-cust862.4-2.cable.virginm.net. [86.9.131.95]) by smtp.gmail.com with ESMTPSA id p5-20020a5d4e05000000b003143d80d11dsm364606wrt.112.2023.07.10.14.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 14:08:09 -0700 (PDT) From: Stafford Horne To: LKML Cc: Rich Felker , Stafford Horne , Szabolcs Nagy , Jonas Bonn , Stefan Kristiansson , linux-openrisc@vger.kernel.org Subject: [PATCH v4] openrisc: Union fpcsr and oldmask in sigcontext to unbreak userspace ABI Date: Mon, 10 Jul 2023 22:08:03 +0100 Message-Id: <20230710210805.131666-1-shorne@gmail.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With commit 27267655c531 ("openrisc: Support floating point user api") I added an entry to the struct sigcontext which caused an unwanted change to the userspace ABI. To fix this we use the previously unused oldmask field space for the floating point fpcsr state. We do this with a union to restore the ABI back to the pre kernel v6.4 ABI and keep API compatibility. This does mean if there is some code somewhere that is setting oldmask in an OpenRISC specific userspace sighandler it would end up setting the floating point register status, but I think it's unlikely as oldmask was never functional before. Fixes: 27267655c531 ("openrisc: Support floating point user api") Reported-by: Szabolcs Nagy Closes: https://lore.kernel.org/openrisc/20230626213840.GA1236108@port70.ne= t/ Signed-off-by: Stafford Horne --- Changes since v3: - Fix typos in commit message - Add back change log Changes since v2: - Don't use a struct in sigcontext as hinted by Rich Felker Changes since v1: - Rather than revert the change, just use the oldmask slot for fpu state. arch/openrisc/include/uapi/asm/sigcontext.h | 6 ++++-- arch/openrisc/kernel/signal.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/openrisc/include/uapi/asm/sigcontext.h b/arch/openrisc/in= clude/uapi/asm/sigcontext.h index ca585e4af6b8..e7ffb58ff58f 100644 --- a/arch/openrisc/include/uapi/asm/sigcontext.h +++ b/arch/openrisc/include/uapi/asm/sigcontext.h @@ -28,8 +28,10 @@ =20 struct sigcontext { struct user_regs_struct regs; /* needs to be first */ - struct __or1k_fpu_state fpu; - unsigned long oldmask; + union { + unsigned long fpcsr; + unsigned long oldmask; /* unused */ + }; }; =20 #endif /* __ASM_OPENRISC_SIGCONTEXT_H */ diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c index 4664a18f0787..2e7257a433ff 100644 --- a/arch/openrisc/kernel/signal.c +++ b/arch/openrisc/kernel/signal.c @@ -50,7 +50,7 @@ static int restore_sigcontext(struct pt_regs *regs, err |=3D __copy_from_user(regs, sc->regs.gpr, 32 * sizeof(unsigned long)); err |=3D __copy_from_user(®s->pc, &sc->regs.pc, sizeof(unsigned long)); err |=3D __copy_from_user(®s->sr, &sc->regs.sr, sizeof(unsigned long)); - err |=3D __copy_from_user(®s->fpcsr, &sc->fpu.fpcsr, sizeof(unsigned l= ong)); + err |=3D __copy_from_user(®s->fpcsr, &sc->fpcsr, sizeof(unsigned long)= ); =20 /* make sure the SM-bit is cleared so user-mode cannot fool us */ regs->sr &=3D ~SPR_SR_SM; @@ -113,7 +113,7 @@ static int setup_sigcontext(struct pt_regs *regs, struc= t sigcontext __user *sc) err |=3D __copy_to_user(sc->regs.gpr, regs, 32 * sizeof(unsigned long)); err |=3D __copy_to_user(&sc->regs.pc, ®s->pc, sizeof(unsigned long)); err |=3D __copy_to_user(&sc->regs.sr, ®s->sr, sizeof(unsigned long)); - err |=3D __copy_to_user(&sc->fpu.fpcsr, ®s->fpcsr, sizeof(unsigned lon= g)); + err |=3D __copy_to_user(&sc->fpcsr, ®s->fpcsr, sizeof(unsigned long)); =20 return err; } --=20 2.39.1