From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9212C46470 for ; Wed, 15 May 2019 12:16:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5FF320675 for ; Wed, 15 May 2019 12:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557922585; bh=/GiRHCDd7UvnSNp2ErYbr0bu740Lmd9tFFpzKHOnqnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QOYy3YQBZoNfsrlY9QvOmSgMYTOLtdnNKtC4mxbBSCDSYoJScM4UFRpmmeSHchpv8 uLeQecoRV1MNOotzXRNXa0XKeusctSFrETOZerl/n0ZHxDWmJng3bsU2mkueOqiXdW uYhYkkqXkuA2nQ74vGy1zUwALF8y3ro6PViNfJtc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727382AbfEOLCd (ORCPT ); Wed, 15 May 2019 07:02:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:59786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727945AbfEOLCb (ORCPT ); Wed, 15 May 2019 07:02:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BEEFB2173C; Wed, 15 May 2019 11:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918150; bh=/GiRHCDd7UvnSNp2ErYbr0bu740Lmd9tFFpzKHOnqnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aK/IRKLO8bGaZC0Onju0ZjluUTn0O13fYBIHuZ8hahNK4nPL7HXo3tLT9bX8sKt2d GN4vtb66LZ8v3odnCWZtHkwCbp9QEI62GFBRyHdia2Sa0w1MYQfKBcxsBMHZLPZRjJ blCnEcj/oXsO2s4z2ElJo1xaV8zgMM2X41euNUas= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aurelien Jarno , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paul Burton , Ralf Baechle , James Hogan , linux-mips@vger.kernel.org Subject: [PATCH 4.4 004/266] MIPS: scall64-o32: Fix indirect syscall number load Date: Wed, 15 May 2019 12:51:51 +0200 Message-Id: <20190515090722.830915313@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090722.696531131@linuxfoundation.org> References: <20190515090722.696531131@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Aurelien Jarno commit 79b4a9cf0e2ea8203ce777c8d5cfa86c71eae86e upstream. Commit 4c21b8fd8f14 (MIPS: seccomp: Handle indirect system calls (o32)) added indirect syscall detection for O32 processes running on MIPS64, but it did not work correctly for big endian kernel/processes. The reason is that the syscall number is loaded from ARG1 using the lw instruction while this is a 64-bit value, so zero is loaded instead of the syscall number. Fix the code by using the ld instruction instead. When running a 32-bit processes on a 64 bit CPU, the values are properly sign-extended, so it ensures the value passed to syscall_trace_enter is correct. Recent systemd versions with seccomp enabled whitelist the getpid syscall for their internal processes (e.g. systemd-journald), but call it through syscall(SYS_getpid). This fix therefore allows O32 big endian systems with a 64-bit kernel to run recent systemd versions. Signed-off-by: Aurelien Jarno Cc: # v3.15+ Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Paul Burton Cc: Ralf Baechle Cc: James Hogan Cc: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/mips/kernel/scall64-o32.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/mips/kernel/scall64-o32.S +++ b/arch/mips/kernel/scall64-o32.S @@ -126,7 +126,7 @@ trace_a_syscall: subu t1, v0, __NR_O32_Linux move a1, v0 bnez t1, 1f /* __NR_syscall at offset 0 */ - lw a1, PT_R4(sp) /* Arg1 for __NR_syscall case */ + ld a1, PT_R4(sp) /* Arg1 for __NR_syscall case */ .set pop 1: jal syscall_trace_enter