Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7573813yba; Thu, 2 May 2019 12:15:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5O5IDbX/flIoqowAxa/3/Ekn4WZfuJqoRU8cjVDJqWWQLk7p1IziXFgepHuPmKbVyqhJV X-Received: by 2002:a17:902:5a42:: with SMTP id f2mr5581165plm.135.1556824544840; Thu, 02 May 2019 12:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556824544; cv=none; d=google.com; s=arc-20160816; b=frsY9JNu+7KzVCUoRSUgfICOmVqynv7xTYAhzENq7Z8ZZ1XMyMkz9bLlBKvt1mkK9E 86uDN+SzdP7cq9d2Z2TvrpXZpKe1rSlVFiXeaEMgPJUUMsDJzpyqj9yjrc69pGjyyGi5 vY+0YOi72eQnWSYU8fsF/265+su7ZEyNsQKM3WES90vRirnX8UlfoGuvGwlzeDOoZlVo iF7KoOrRCL2But5pthC9Q0Nckhx/yKN9S/MGKA7tlSg4LbuDxAwDztOsJh8nB3l18vBY ziaqJ5K5ldSmFYv5SffUjSlj/vJOFHjHQk7rDo+ZSU3Bb51jsKb74gpUU9Op8TurTU5s JjLA== 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=vWuWL7ybXXOXqBSlFyEUycQmfax+Aj6ELxBH/naFMdQ=; b=ecRlWEyT7nUhUUFDCooRN+s7uXR29cY4Pwxgaw5MyJ4d/VhzWtUWUT4AviyXlQeSEC 8r4B8FdpHIZNKBdnnR5tc+Iti3YVHiXXpyS2UB6/lS+LKw5+hxalEKSOCMAiAeMw0rd1 ZokfeKgkQBVfJysOE0jaKXDGeZDJZlQo4kY36gp7cgfWdiQWuN+9MTzy0W7shnRzmEx+ ARKX9h3al09S8GH3OW4I5f+Aalv9p3OnIwx7QT5qHiDrefxY7QU5EmELO4ukS4bm2GzN SmqNGAbOuR6e+BcM2Io+E5kTVY5r5grBgJz9XWTSkfN9mQeKTgo44El8hWFzcKyMtr/J +KUw== 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 s5si44832144pfm.234.2019.05.02.12.15.29; Thu, 02 May 2019 12:15:44 -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 S1726414AbfEBTOa (ORCPT + 99 others); Thu, 2 May 2019 15:14:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45078 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfEBTOa (ORCPT ); Thu, 2 May 2019 15:14:30 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFD405944C; Thu, 2 May 2019 19:14:29 +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 B50CF1001E86; Thu, 2 May 2019 19:14:24 +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 Subject: [PATCH 1/2] kernel/sys: add PR_GET_TASK_SIZE option to prctl(2) Date: Thu, 2 May 2019 15:13:10 -0400 Message-Id: <1556824391-24060-2-git-send-email-jsavitz@redhat.com> In-Reply-To: <1556824391-24060-1-git-send-email-jsavitz@redhat.com> References: <1556824391-24060-1-git-send-email-jsavitz@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 02 May 2019 19:14:30 +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 long task_size = TASK_SIZE; + return copy_to_user(uaddr, &task_size, sizeof(unsigned long 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