Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp68683pxj; Thu, 20 May 2021 04:46:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqYdx4w8dEGZjHwb53b2+tAINcsWoQhwId2fmH2kahe6tkbz/zsoWP/PQpW+hiFI8TN0Zi X-Received: by 2002:a17:907:3f28:: with SMTP id hq40mr4307106ejc.283.1621511194123; Thu, 20 May 2021 04:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621511194; cv=none; d=google.com; s=arc-20160816; b=bAqUSK+M5B34uegjnnDQsOMVoabNgwzbkGZ2c6XvXp2JxS1hVMH0PuFnesjWMt82K+ HvsAvHnSsHLCsLjCqqJG8eOnzzFsMjI6jPo+SvuH5xDQJUkqIncicd0/Ne5qfWvZaJ++ BINI0Q6Dwg17tQgvVU25gXyCa22Fj6oMAninns/8fRwLqU5bKZiLdNa1MTNztLtCovpF rSybyGBoAsGEBQs/OvEXDn7SqP3NgLKHCGT7Q+KDtcWdVH6OoBMJi4PziKL88jiwzq+L Z2xK8MPMs4yeO5/D5tuMS3+YHozPTGXVNlx4c1kd0/PdfJzB1apBBhRImjS/G4NQavby qnEw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IDcs415xD06B1+GmIYVVl2R1k7mdbEVpREv97/Vr9+Y=; b=Jh3/qJIsPTvUprx93FBjG2PQDipN0z69p5WD/QPS6gisz7HnnVnPPHPkOfwRlJKSfd MkwKSWfo47N/U4UQxg2YVEcltnlefA563uOzJ4Q5779XtlwU/jv2mK4sf8hWz07wVSur fdh+BjpGfR3/g6PW20pSXIrPD4Iu27QG/OxMHoTuC00KZk7HsuIIXePEJEOA3pH8iSGq 4YMIUD96lvpiWB6SUdHY47i0oXWaBoeWdynzK402d9iyQqSCyPtWI7DUfPJnAoynE+Jr 5qlJkJOhQkNatyb7pFUSCc8+RDPc9ZaoJPMgkQqP93DFH0sLQQ2XtoPFscSjc8sfNe1B 62pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UoPOCzsB; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k15si1913234eds.247.2021.05.20.04.46.10; Thu, 20 May 2021 04:46:34 -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=@linuxfoundation.org header.s=korg header.b=UoPOCzsB; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240064AbhETLnB (ORCPT + 99 others); Thu, 20 May 2021 07:43:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:41740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239734AbhETLWM (ORCPT ); Thu, 20 May 2021 07:22:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CDAEC613E9; Thu, 20 May 2021 10:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505496; bh=IcjHdlf9KxllRu2dQjiU+p5/Nicq0fCb64u7Ewrsj1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UoPOCzsBbSI3oJWpmVqW6kGQDgro+cBdOqXFANSwt1Qo5GSIqCbZ1mtZCHyhOFOe/ i9rDF0T8C0tJz8G9ZUQkI+NazxfXm3aKxBsX0tSMtv3ELAToGpBSiqhsC1GT/Lx9Tp 4FZrfIKzaG17M++ONz0vbS22E9MRPILvBmHtof2o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shahab Vahedi , Vineet Gupta Subject: [PATCH 4.4 162/190] ARC: entry: fix off-by-one error in syscall number validation Date: Thu, 20 May 2021 11:23:46 +0200 Message-Id: <20210520092107.524217122@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vineet Gupta commit 3433adc8bd09fc9f29b8baddf33b4ecd1ecd2cdc upstream. We have NR_syscall syscalls from [0 .. NR_syscall-1]. However the check for invalid syscall number is "> NR_syscall" as opposed to >=. This off-by-one error erronesously allows "NR_syscall" to be treated as valid syscall causeing out-of-bounds access into syscall-call table ensuing a crash (holes within syscall table have a invalid-entry handler but this is beyond the array implementing the table). This problem showed up on v5.6 kernel when testing glibc 2.33 (v5.10 kernel capable, includng faccessat2 syscall 439). The v5.6 kernel has NR_syscalls=439 (0 to 438). Due to the bug, 439 passed by glibc was not handled as -ENOSYS but processed leading to a crash. Link: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/issues/48 Reported-by: Shahab Vahedi Cc: Signed-off-by: Vineet Gupta Signed-off-by: Greg Kroah-Hartman --- arch/arc/kernel/entry.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -181,7 +181,7 @@ tracesys: ; Do the Sys Call as we normally would. ; Validate the Sys Call number - cmp r8, NR_syscalls + cmp r8, NR_syscalls - 1 mov.hi r0, -ENOSYS bhi tracesys_exit @@ -264,7 +264,7 @@ ENTRY(EV_Trap) ;============ Normal syscall case ; syscall num shd not exceed the total system calls avail - cmp r8, NR_syscalls + cmp r8, NR_syscalls - 1 mov.hi r0, -ENOSYS bhi ret_from_system_call