From patchwork Thu Jan 3 18:13:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 154733 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp937083ljp; Thu, 3 Jan 2019 10:14:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Ybfu0YzThQUMdjs7wYyjctI7FpWX0bngTHg9G2DKkVVIw0v9Tz0f5/Ibt9QJqizbGU1IZ X-Received: by 2002:a62:9111:: with SMTP id l17mr49088358pfe.200.1546539245114; Thu, 03 Jan 2019 10:14:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546539245; cv=none; d=google.com; s=arc-20160816; b=DZOe4q15oiffxVBnFtmX7EWtqYviSwj56EoPg7TOoC50OYecU6ooVnPsYuE6zmhlJK EIBZEJN1a3OJKU8LfTg46jXhAapZuz+UlhVauKjXLwU9jgpqfYErkTOLxKSEIbJUx3NZ SUCAxRLaLQPQ88Y4fCT2ipPYjPuVp3U4Z926ZSWxJCZcsIaeFb64Aaov6zs10+rDOU8J e/4D86Wj/+5LazCdWWoiAbCS6LAD7I//VwINTTvVwbu+CmnUvgl4H7F6QJMMlz74sCUL XiKlI/iAt4IkXNr6uhfEWMf7OV47If9XAuUZ8++Ut00x3qVabg6wK+GBwuu7giDonBgt 460Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=OG06qj31qh4fZbr8L0CrK7e8me2BkjkHvgdVrOkI2Jc=; b=PYIvUdMLJQbwzgtKtiVtSoyZjeLgW0Kt2jEjVoo/2nL6p5WkFBzRLJnATCIZELO8t2 edcR0ro5EESDtyMFa9uZcflJsiiSAB9Z+Wu0E/zfWCKU6G85M7oddVQnNw76bXAoup6E lXmzLoxfg/W6b3QzYc2gGDEz37EnLwbJHNEr52dSNHP7luvUQ2faeiPk0WzMsUnnZmGp ID/d8KWCYYIE9UGUxzP6+BFVhDMTijFPlCzbkJKBwIfPOK/Fw0I8Uw9B6EMokwrN25MO zmpZruxOY8s+9Nd1xZ2tUtZEKrjRZIRUcRJPFFrI5//cizoHtlIsze5+8Ayl2uAAR9ng hvBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o13si4638572pgp.540.2019.01.03.10.14.04; Thu, 03 Jan 2019 10:14:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730784AbfACSOD (ORCPT + 15 others); Thu, 3 Jan 2019 13:14:03 -0500 Received: from foss.arm.com ([217.140.101.70]:54390 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730675AbfACSOC (ORCPT ); Thu, 3 Jan 2019 13:14:02 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 88F5415BE; Thu, 3 Jan 2019 10:14:02 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 572713F706; Thu, 3 Jan 2019 10:14:02 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 8242D1AE09EC; Thu, 3 Jan 2019 18:14:02 +0000 (GMT) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: Dave.Martin@arm.com, pihsun@chromium.org, Will Deacon , Subject: [PATCH 1/3] arm64: compat: Avoid sending SIGILL for unallocated syscall numbers Date: Thu, 3 Jan 2019 18:13:58 +0000 Message-Id: <1546539240-20647-2-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1546539240-20647-1-git-send-email-will.deacon@arm.com> References: <1546539240-20647-1-git-send-email-will.deacon@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The ARM Linux kernel handles the EABI syscall numbers as follows: 0 - NR_SYSCALLS-1 : Invoke syscall via syscall table NR_SYSCALLS - 0xeffff : -ENOSYS (to be allocated in future) 0xf0000 - 0xf07ff : Private syscall or -ENOSYS if not allocated > 0xf07ff : SIGILL Our compat code gets this wrong and ends up sending SIGILL in response to all syscalls greater than NR_SYSCALLS which have a value greater than 0x7ff in the bottom 16 bits. Fix this by defining the end of the ARM private syscall region and checking the syscall number against that directly. Update the comment while we're at it. Cc: Cc: Dave Martin Reported-by: Pi-Hsun Shih Signed-off-by: Will Deacon --- arch/arm64/include/asm/unistd.h | 5 +++-- arch/arm64/kernel/sys_compat.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) -- 2.1.4 diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h index b13ca091f833..be66a54ee3a1 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -40,8 +40,9 @@ * The following SVCs are ARM private. */ #define __ARM_NR_COMPAT_BASE 0x0f0000 -#define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2) -#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5) +#define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE + 2) +#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5) +#define __ARM_NR_compat_syscall_end (__ARM_NR_COMPAT_BASE + 0x800) #define __NR_compat_syscalls 399 #endif diff --git a/arch/arm64/kernel/sys_compat.c b/arch/arm64/kernel/sys_compat.c index 32653d156747..5972b7533fa0 100644 --- a/arch/arm64/kernel/sys_compat.c +++ b/arch/arm64/kernel/sys_compat.c @@ -102,12 +102,12 @@ long compat_arm_syscall(struct pt_regs *regs) default: /* - * Calls 9f00xx..9f07ff are defined to return -ENOSYS + * Calls 0xf0xxx..0xf07ff are defined to return -ENOSYS * if not implemented, rather than raising SIGILL. This * way the calling program can gracefully determine whether * a feature is supported. */ - if ((no & 0xffff) <= 0x7ff) + if (no < __ARM_NR_compat_syscall_end) return -ENOSYS; break; }