Message ID | 166793776319.4906.4394830802759229298.tip-bot2@tip-bot2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2921411wru; Tue, 8 Nov 2022 12:04:21 -0800 (PST) X-Google-Smtp-Source: AMsMyM6zkFrnYv1XaFT9jrRfjVGOxjutVnyqIQOii8tJOpWy5m1qVi+Xyqzczdb6BcRzNuyYHwkV X-Received: by 2002:a17:907:6d0d:b0:7ad:b389:1151 with SMTP id sa13-20020a1709076d0d00b007adb3891151mr53554712ejc.655.1667937861412; Tue, 08 Nov 2022 12:04:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667937861; cv=none; d=google.com; s=arc-20160816; b=DlSqItiZX2gZWFioX0mXEcLltkHCE5wk0TI7cvGwB6UqcKQn5T5gHFHjzaYUGXif1P fWfs2MdMsbJ4LX9ZyAS+bvtCryUBWy6pIOsFCIeHa1Q5P62kWFI/6KAWzDWl3MlPs68t dn2i1j53zKSEIPTrld2Zz6pdwI+rgVDeupTQXD5MXkxAWiFm0v2NxcTpu4hsWAMQl1gj hY1sNeVEof/yfFyvtAwxeodYCxemlzL7/TYpw+W+KcUU0v1dVdpCi0erD5bdc41jOuxN 95qHLueYsjMQpanqKwwAn53txKuyS9sUCilAZobKSwNLzUuIk4knAqG3jQiPw3079DBD nZ8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=m957AOZ+7PMI2g5Y+f/g1wqY8SUIj2ZsgN/I1eKfwXQ=; b=JYlEntqOyC3UIQpT1IUjaGk4v5vdkHucw68E/IKXVTv+rQQS0PpwdUu8j6QlzEC2LZ T5jcuTyTefRTAZyfP3j5PrM4xKZRBtsUjAAap63WgqEXHnlq814Gcyv5JJfTOtDD3CWf rSeKQo/HI8fAIGnslV70l34PU4EehVPZfwM0vZKuyZ9Qp89dIXPWnHVUhJcQjRQJLucp bMWZ24B1IcJr3nvGQTAPovcIQHS3KKpEgBDdirMM/isjRkb+nBJPAZOwGtP3eSIGVgMS qN6VaB6gy5qc3wI0yYbc8Iv8XZIO18F4EUk/I0CuRLBHxWQ9qy4QTa9ssfHLxedBcbtO r5AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=um3sksbW; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg33-20020a170907a42100b0078200f886bbsi2990734ejc.361.2022.11.08.12.03.57; Tue, 08 Nov 2022 12:04:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=um3sksbW; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbiKHUCv (ORCPT <rfc822;tony84727@gmail.com> + 99 others); Tue, 8 Nov 2022 15:02:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbiKHUCs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 8 Nov 2022 15:02:48 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 740BE67F50; Tue, 8 Nov 2022 12:02:47 -0800 (PST) Date: Tue, 08 Nov 2022 20:02:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667937765; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m957AOZ+7PMI2g5Y+f/g1wqY8SUIj2ZsgN/I1eKfwXQ=; b=um3sksbWXHoJWNzO5Daa81xllF9fasZRzia2DOk4unBQLZfKahorHCk58KRrHGKvu/6icQ FAOPfJebZTrn7Dd1lJs+ODz2UmqM8hH553rX8j13SrUrArgNnpseBepurE4Fg599m7uRgl Svdh/d7Y8C7IGE1g0ZQIYZ/VcYmpIzzWjHLbc/aaCOYuFik1r0mcv5C31yNXikVsozP8Jv OEs7TulGj8LG6apLvVtKP8+jHCXYX/gzCX/MhWny1Uc9N38TMFUCBcOVaSxeF9mKYHLBHC BDsoMgRweIJY01b6Lwsic6gx+s1Xz310sJp24TYPLzzvtMbgHUGYdZD0IY8Q/A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667937765; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m957AOZ+7PMI2g5Y+f/g1wqY8SUIj2ZsgN/I1eKfwXQ=; b=Z0T8LI2LLBegBX93t7VPAeh8mmaBSJpZTreLIVLvRoG18gD5SmP4SXT/EDiB4rxG6jRpFQ SK2gEb8U8chZShAA== From: tip-bot2 for Borys =?utf-8?q?Pop=C5=82awski?= <tip-bot2@linutronix.de> Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/sgx: Add overflow check in sgx_validate_offset_length() Cc: borysp@invisiblethingslab.com, Borislav Petkov <bp@suse.de>, Jarkko Sakkinen <jarkko@kernel.org>, stable@vger.kernel.org, #@tip-bot2.tec.linutronix.de, v5.11+@tip-bot2.tec.linutronix.de, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <0d91ac79-6d84-abed-5821-4dbe59fa1a38@invisiblethingslab.com> References: <0d91ac79-6d84-abed-5821-4dbe59fa1a38@invisiblethingslab.com> MIME-Version: 1.0 Message-ID: <166793776319.4906.4394830802759229298.tip-bot2@tip-bot2> Robot-ID: <tip-bot2@linutronix.de> Robot-Unsubscribe: Contact <mailto:tglx@linutronix.de> to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748956759687570072?= X-GMAIL-MSGID: =?utf-8?q?1748959611141528052?= |
Series |
[tip:,x86/urgent] x86/sgx: Add overflow check in sgx_validate_offset_length()
|
|
Commit Message
tip-bot2 for Thomas Gleixner
Nov. 8, 2022, 8:02 p.m. UTC
The following commit has been merged into the x86/urgent branch of tip: Commit-ID: f0861f49bd946ff94fce4f82509c45e167f63690 Gitweb: https://git.kernel.org/tip/f0861f49bd946ff94fce4f82509c45e167f63690 Author: Borys Popławski <borysp@invisiblethingslab.com> AuthorDate: Wed, 05 Oct 2022 00:59:03 +02:00 Committer: Borislav Petkov <bp@suse.de> CommitterDate: Tue, 08 Nov 2022 20:34:05 +01:00 x86/sgx: Add overflow check in sgx_validate_offset_length() sgx_validate_offset_length() function verifies "offset" and "length" arguments provided by userspace, but was missing an overflow check on their addition. Add it. Fixes: c6d26d370767 ("x86/sgx: Add SGX_IOC_ENCLAVE_ADD_PAGES") Signed-off-by: Borys Popławski <borysp@invisiblethingslab.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Cc: stable@vger.kernel.org # v5.11+ Link: https://lore.kernel.org/r/0d91ac79-6d84-abed-5821-4dbe59fa1a38@invisiblethingslab.com --- arch/x86/kernel/cpu/sgx/ioctl.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c index ebe79d6..da8b8ea 100644 --- a/arch/x86/kernel/cpu/sgx/ioctl.c +++ b/arch/x86/kernel/cpu/sgx/ioctl.c @@ -356,6 +356,9 @@ static int sgx_validate_offset_length(struct sgx_encl *encl, if (!length || !IS_ALIGNED(length, PAGE_SIZE)) return -EINVAL; + if (offset + length < offset) + return -EINVAL; + if (offset + length - PAGE_SIZE >= encl->size) return -EINVAL;