From patchwork Fri Feb 22 12:53:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10825895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD84213B5 for ; Fri, 22 Feb 2019 12:53:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BF8B323D1 for ; Fri, 22 Feb 2019 12:53:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9013032462; Fri, 22 Feb 2019 12:53:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30A45323D1 for ; Fri, 22 Feb 2019 12:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727283AbfBVMxv (ORCPT ); Fri, 22 Feb 2019 07:53:51 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34860 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727284AbfBVMxt (ORCPT ); Fri, 22 Feb 2019 07:53:49 -0500 Received: by mail-wr1-f66.google.com with SMTP id t18so2276652wrx.2 for ; Fri, 22 Feb 2019 04:53:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2tCXxaQ0AcT215cB6TyMBJl5HSukg9TNH5t025IrNLw=; b=B3gwK58HnJ85CmTL2efZvH+J/Nm20KCnydLNY0dw7gbtvGIUGcldP8npiWTUpDXgKz /u11H7eQqGQOsrUx9Bjjx9CGJcxvqjtgzrsVE+c4Cnr2aH4wSMA3cBw28f4m5dvZcDtW dE9QsCl+18tkcm6KtqrSMoS1/n9nvYZMf6UFWkly4U8pHmTr2bgB/2tzCG5OvgHPbq1p LygIpIzOhXUWhS3SS/cArJu5XyCYKaSFAA2Xlb21EPCN/ry2nFAF1xMDOUEnala+awoK ndjVy074STqch02YUSBKRqql7aX75kVTJAVZrchuqsIoYuA52Cu849nBt6+cAxrGpU8H 43FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2tCXxaQ0AcT215cB6TyMBJl5HSukg9TNH5t025IrNLw=; b=om0aSeffpt6e4aN0T8q2HZCCt2GwgEEZCLfOpzOV2AsawShaml1LzmmxrFNX0HKry8 kP/hOGw1FGsFdJ1Reaz6sepNGA7YGy67F3Cj9IDHBf8bIBztSB2BZgIy+V2ZGMPK2tCy cNBsVXYjE2+FIy4+u5hz3B0VTlIaDM0472ZsBDUtMSAtw4XB5BAn9n6NXKsCOean7qyp VTP9vF8bUhG/TV6C5eIzr92ba2WvtbnHTy7/dD1ryJeBw5jmXcUDFovTZoTC8iliN9df fZpX/E8J32BvHGJhteDLaxo31ZDy2snHQ9R3n76wpTO3gcCpOpYfO8KB6Pp7Dx5eqVeX 8EUg== X-Gm-Message-State: AHQUAuabCng/dOok83Gn0qbymBnToUqwu1JXK/KH3dyiJ3tHgdglYIl/ DRvDyxEd/CRcB/ZYtq52O9YDAQ== X-Google-Smtp-Source: AHgI3IYJ4JqjThJgosMpQUX8CWU96fplWtblPpUxW7NKKKm/ffsucHxns87xgSXmASXlP8q7nFWW4A== X-Received: by 2002:adf:ed0f:: with SMTP id a15mr2881069wro.249.1550840027447; Fri, 22 Feb 2019 04:53:47 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:13:8ce:d7fa:9f4c:492]) by smtp.gmail.com with ESMTPSA id o14sm808209wrp.34.2019.02.22.04.53.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 04:53:46 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy , Andrey Konovalov Subject: [PATCH v10 09/12] kernel, arm64: untag user pointers in prctl_set_mm* Date: Fri, 22 Feb 2019 13:53:21 +0100 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e-goog In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP prctl_set_mm() and prctl_set_mm_map() use provided user pointers for vma lookups, which can only by done with untagged pointers. Untag user pointers in these functions. Signed-off-by: Andrey Konovalov --- kernel/sys.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kernel/sys.c b/kernel/sys.c index f7eb62eceb24..12910be94b7f 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1992,6 +1992,18 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data if (copy_from_user(&prctl_map, addr, sizeof(prctl_map))) return -EFAULT; + prctl_map->start_code = untagged_addr(prctl_map.start_code); + prctl_map->end_code = untagged_addr(prctl_map.end_code); + prctl_map->start_data = untagged_addr(prctl_map.start_data); + prctl_map->end_data = untagged_addr(prctl_map.end_data); + prctl_map->start_brk = untagged_addr(prctl_map.start_brk); + prctl_map->brk = untagged_addr(prctl_map.brk); + prctl_map->start_stack = untagged_addr(prctl_map.start_stack); + prctl_map->arg_start = untagged_addr(prctl_map.arg_start); + prctl_map->arg_end = untagged_addr(prctl_map.arg_end); + prctl_map->env_start = untagged_addr(prctl_map.env_start); + prctl_map->env_end = untagged_addr(prctl_map.env_end); + error = validate_prctl_map(&prctl_map); if (error) return error; @@ -2105,6 +2117,8 @@ static int prctl_set_mm(int opt, unsigned long addr, opt != PR_SET_MM_MAP_SIZE))) return -EINVAL; + addr = untagged_addr(addr); + #ifdef CONFIG_CHECKPOINT_RESTORE if (opt == PR_SET_MM_MAP || opt == PR_SET_MM_MAP_SIZE) return prctl_set_mm_map(opt, (const void __user *)addr, arg4);