Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2841082pxj; Mon, 10 May 2021 11:57:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdHvveB+vlEjuroISesWickD9kW+vGY2Gr3PSLlY8tOkizFnfOeAfQjSuYaUmcxLYtwGTE X-Received: by 2002:a17:906:54f:: with SMTP id k15mr8939438eja.27.1620673077817; Mon, 10 May 2021 11:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620673077; cv=none; d=google.com; s=arc-20160816; b=chuuZO11Nz3i5Lv9P33RYV2vfv18jkSazeZmKL9yNjVjJvT5wqRNM5/nK2x6GCr+UG VB9zE0717IYezUt6qzQ2cNWGQPjahZKGz4dG8q+L1ogWxUoeyGQL/1Hw9cLdSF/yAOB8 9fJeSXiT4IaJukHdvYA8gbc0foSldlz1wBshI/J8t2PJeuojo87pr9G612cHhql5ZnvU MV8CD23bFen3OTsf72C2L8VKlgq3z+BgosEJr56qFXkE9HTZYRPXnoP8UMALAxiudDNx eyZ8QjHePDuNQv60mQH1f7vx4NbHlB+2YTkO/sXH9FwVZwH1A2GPeBabljzqBu3AHpum zSjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=JHPMbGMh79H+cjWsMsA8mi8L+qKBD13Dnd8qkFhJLEs=; b=CrAt17LqBWqDGjKWgoRHMOKxBtCMRA7zlQv9J1tng8QW70aPSqZ1oVmg71/NJLrgbJ oj6blY4IA34pNwwLR7Miv4Y4oHpLEqldaWojE3eZo5Yq+RVKfeWcfCLCFUxxufTIlTlF bDEflt5R++Yrryt3VDYyhnFkBKlBwDV/FA/9aiYKmWHG36sarNhL19f+dp40OtZbcsD7 PE9q3TLt+lBiaDNeY0Z8pJCuvg4AcUHT7gYn2q8y6pA2thIeKjFcxHdvtNMT0RKCZ8AD hEAbvgxW1FU9vRmFzTnld8RUBeEXnyYivjkVGgZkRJe4yyKj9XO2ze2RIEIxcgYcYGed M8ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2021042801 header.b=orfPQg52; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs19si13974359ejc.707.2021.05.10.11.57.34; Mon, 10 May 2021 11:57:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2021042801 header.b=orfPQg52; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233153AbhEJSyy (ORCPT + 99 others); Mon, 10 May 2021 14:54:54 -0400 Received: from terminus.zytor.com ([198.137.202.136]:37861 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232789AbhEJSyq (ORCPT ); Mon, 10 May 2021 14:54:46 -0400 Received: from tazenda.hos.anvin.org ([IPv6:2601:646:8602:8be0:7285:c2ff:fefb:fd4]) (authenticated bits=0) by mail.zytor.com (8.16.1/8.15.2) with ESMTPSA id 14AIrNli2459085 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 10 May 2021 11:53:33 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 14AIrNli2459085 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2021042801; t=1620672813; bh=JHPMbGMh79H+cjWsMsA8mi8L+qKBD13Dnd8qkFhJLEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=orfPQg52ynpp6lA+HdEOWMgTL2lQkJdgEz6MT3x5zJoJjPJtPRzPSr4venJ9IFAuv 5KM+DSSWXtmqopsxBIeo8cFVPZn4RCS0c19Q6yXwebUBaa/2DIlZerazHIK0psKHKb GE68TArtjQEDH9vRCapm1QdUTXZi1ARZ3/ucE2GqOD5wW93rMJMWIgj9sTxIb9CbYZ n2yH14KoCC5zJ9TAxtSPPg2oGxcifC4+QCHd89SNCiHbLFrtQrvCAGUcF/iRRNWS0O hKRJmCXuFFoSExA9Tic6QCpvUGz7vjAG5t9xWoqdl50iNFdbYTalTLMH01QyI7oh/H 731/8EmOnBCNQ== From: "H. Peter Anvin" To: Ingo Molnar , Thomas Gleixner , Borislav Petkov , Andy Lutomirski Cc: "H. Peter Anvin" , Linux Kernel Mailing List Subject: [RFC v2 PATCH 6/7] x86/regs: syscall_get_nr() returns -1 for a non-system call Date: Mon, 10 May 2021 11:53:15 -0700 Message-Id: <20210510185316.3307264-7-hpa@zytor.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510185316.3307264-1-hpa@zytor.com> References: <20210510185316.3307264-1-hpa@zytor.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org syscall_get_nr() is defined to return -1 for a non-system call or a ptrace/seccomp restart; not just any arbitrary number. See comment in for the official definition of this function. Signed-off-by: H. Peter Anvin --- arch/x86/kernel/ptrace.c | 2 +- arch/x86/kernel/signal.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 87a4143aa7d7..4c208ea3bd9f 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -911,7 +911,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 value) * syscall with TS_COMPAT still set. */ regs->orig_ax = value; - if (syscall_get_nr(child, regs) >= 0) + if (syscall_get_nr(child, regs) != -1) child->thread_info.status |= TS_I386_REGS_POKED; break; diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index a06cb107c0e8..e12779a2714d 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -713,7 +713,7 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs) save_v86_state((struct kernel_vm86_regs *) regs, VM86_SIGNAL); /* Are we from a system call? */ - if (syscall_get_nr(current, regs) >= 0) { + if (syscall_get_nr(current, regs) != -1) { /* If so, check system call restarting.. */ switch (syscall_get_error(current, regs)) { case -ERESTART_RESTARTBLOCK: @@ -793,7 +793,7 @@ void arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal) } /* Did we come from a system call? */ - if (syscall_get_nr(current, regs) >= 0) { + if (syscall_get_nr(current, regs) != -1) { /* Restart the system call - no handlers present */ switch (syscall_get_error(current, regs)) { case -ERESTARTNOHAND: -- 2.31.1