Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7658556yba; Thu, 2 May 2019 13:54:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdL7MLYNz84M+jiMGEDx9SMP8xZadhOAyEx2XPZbW8N9EulTkLIwVM26DgZyFeEQXvS49p X-Received: by 2002:a62:1a8b:: with SMTP id a133mr6242738pfa.87.1556830463375; Thu, 02 May 2019 13:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556830463; cv=none; d=google.com; s=arc-20160816; b=vZ3O5IsGTbLkq06piJyWW9dOw4rjOg0YfB1TuE2ITwpTFJ3NFNGwQ/NU5a0ZRGEPod eDwB0t3Ppt7NS0eBR5KZIEI1jlcrcobT1CwjEoo96aB5/TmNFi1lEcw+gpWzrGQxDjGq E0WZFYBmuAK7CUXFzfR8xAnbNM/hxMZO4f9vBsxf1B2x7eICoCb3ji16Yp8FLyWyZyID tMko1TzyGB2xaXf4BRSFHYhJ/tB8T8b+8bEDW2HXXCtyBDQjoAJBO22pqhPNaKwh+7P1 fx15Mw8+Q+urJIUdRgdeS9HUUYViG3CgYqKVOTxoznuDgYQKYfL7/yq6VxyfVAa6xnG/ iwwQ== 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=oZ9Kyqo1j6eqcygWRHsxtyzKeL6eut80vVWiycSb8kQ=; b=Et2KLRqWZRxd+t+ewozTkXGbw28sfwRFCBQT+/Xk4jVK95JENAX2neTqN+p7IqYQw5 7+JrUmcsJaZWYw6wHWlzoHXmuW9TEQCjH/K/F3+W0ETxOwKxAWiQsj4enkCcxdI8fGH6 gXoo7nclf3lC6E9U3Nla8tNKSLrq9yLmVuNcknPWf9lDXs2ij1E+qCLzU07NmA1pUOyr 4pmoYWXanO0cJt7lGlm+U2TgBNNh/O4uBcLxuGfGYij7Tjbsd2WrGvGElYYgfenpIOMZ i+zbLJoVwQZRMAYw/+S4xrLvorhQdsxHcTaPHczmlLv5Mpm0XUo/lan0hrUylwvvgn58 ZCTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e24si95814pgv.555.2019.05.02.13.54.07; Thu, 02 May 2019 13:54:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726438AbfEBUwn (ORCPT + 99 others); Thu, 2 May 2019 16:52:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33224 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfEBUwl (ORCPT ); Thu, 2 May 2019 16:52:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA8CD3151C44; Thu, 2 May 2019 20:52:40 +0000 (UTC) Received: from jsavitz.bos.com (dhcp-17-168.bos.redhat.com [10.18.17.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14B595D9C4; Thu, 2 May 2019 20:52:39 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Thomas Gleixner , Ingo Molnar , Masami Hiramatsu , Waiman Long , Mauro Carvalho Chehab , Kristina Martsenko , Andrew Morton , Cyrill Gorcunov , Kees Cook , "Gustavo A. R. Silva" , YueHaibing , Micah Morton , Yang Shi , Jann Horn , Alexey Dobriyan , Rafael Aquini , Michael Kerrisk , Yury Norov Subject: [PATCH v2 1/2] kernel/sys: add PR_GET_TASK_SIZE option to prctl(2) Date: Thu, 2 May 2019 16:52:21 -0400 Message-Id: <1556830342-32307-2-git-send-email-jsavitz@redhat.com> In-Reply-To: <1556830342-32307-1-git-send-email-jsavitz@redhat.com> References: <1556830342-32307-1-git-send-email-jsavitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 02 May 2019 20:52:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When PR_GET_TASK_SIZE is passed to prctl, the kernel will attempt to copy the value of TASK_SIZE to the userspace address in arg2. Suggested-by: Alexey Dobriyan Signed-off-by: Joel Savitz --- include/uapi/linux/prctl.h | 3 +++ kernel/sys.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index 094bb03b9cc2..2335fe0a8db8 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -229,4 +229,7 @@ struct prctl_mm_map { # define PR_PAC_APDBKEY (1UL << 3) # define PR_PAC_APGAKEY (1UL << 4) +/* Get the process virtual memory size */ +#define PR_GET_TASK_SIZE 55 + #endif /* _LINUX_PRCTL_H */ diff --git a/kernel/sys.c b/kernel/sys.c index 12df0e5434b8..7ced7dbd035d 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2252,6 +2252,13 @@ static int propagate_has_child_subreaper(struct task_struct *p, void *data) return 1; } +static int prctl_get_tasksize(void __user * uaddr) +{ + unsigned long task_size = TASK_SIZE; + return copy_to_user(uaddr, &task_size, sizeof(unsigned long)) + ? -EFAULT : 0; +} + int __weak arch_prctl_spec_ctrl_get(struct task_struct *t, unsigned long which) { return -EINVAL; @@ -2486,6 +2493,9 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, return -EINVAL; error = PAC_RESET_KEYS(me, arg2); break; + case PR_GET_TASK_SIZE: + error = prctl_get_tasksize((void *)arg2) ; + break; default: error = -EINVAL; break; -- 2.18.1