Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7686868yba; Thu, 2 May 2019 14:26:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJtx7D1Wd/d+1OctdrlMROL5JxnMfZR1Fxav1bDYxv12tlJWU0mJBcSWDUQKufafhKyK7e X-Received: by 2002:a17:902:704c:: with SMTP id h12mr6134151plt.270.1556832366405; Thu, 02 May 2019 14:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556832366; cv=none; d=google.com; s=arc-20160816; b=uBp51H/yfp5vwWpptK+Qz5Gtjs2q5SKXTdJz73gmCNoUEM/K/kMXC+xlvShfA79atw b41zEKxpMQF31rOfL5gwOAK8xImvo+z+aC1Y+tlArqfQkGqw1/8O0UucJJSYZbH8DKL7 kVRldmKdEFZCjuHBXB6HuIHE1CNhGMMIjOlvEij/Pk2WTj6dq/aY1HnsHr4Q3teK7SJ7 DmJvEvdIFCT3rybvAWecg5a0dXn5K1IZ1FsGtFn3B1U08cEpXakgGDUxLmww6FrIRIbh VqGjANp92MPvwhk3e03VAG6+CCDtVvMJDDj+Snu5sHndKHIBIjje71TntSmke5G9uAvR rEIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=NKq2LjCSgvO2+EmOrbk8dEaJcQ0yaLE1sd3bt8zH3k8=; b=CGFSqgKVDfbAmiBF4Hm0deeZHwYSi7fK/n2tNauE4TCyT9fmfVot439mk/ZDAIfslk OA1O+ni08OevVHtFVFzl9KEsmCesHf3MCm5z7zhfnTCJrzMKFYX4D0X2AmvsbPx1HN6D Q5S+Z/5cEHWef4NRNl3VB26J2IbTLacF2krssET1UibwQoV0lmAfBXbyN0RN0ljRaNgm 5Le8bF71rQzEQG9Sxq9JFyZGzBdE7Qfyn8FcDse7MFfdl67Tl0vdIB2RrghjGVpEuHBt D0fD7Uz7mZgLuq3V6SLIwMDfaewpoEqAmC64nXEmz9LsqWCwMotNzms+D3NRkwLQ/HfQ sOVQ== 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 35si290404pld.6.2019.05.02.14.25.50; Thu, 02 May 2019 14:26:06 -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 S1726209AbfEBVY7 (ORCPT + 99 others); Thu, 2 May 2019 17:24:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36244 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfEBVY7 (ORCPT ); Thu, 2 May 2019 17:24:59 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2611308620F; Thu, 2 May 2019 21:24:58 +0000 (UTC) Received: from x230.aquini.net (dhcp-17-61.bos.redhat.com [10.18.17.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7D7419C4F; Thu, 2 May 2019 21:24:53 +0000 (UTC) Date: Thu, 2 May 2019 17:24:52 -0400 From: Rafael Aquini To: Joel Savitz Cc: linux-kernel@vger.kernel.org, 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 , Michael Kerrisk , Yury Norov Subject: Re: [PATCH v2 1/2] kernel/sys: add PR_GET_TASK_SIZE option to prctl(2) Message-ID: <20190502212451.GA13077@x230.aquini.net> References: <1556830342-32307-1-git-send-email-jsavitz@redhat.com> <1556830342-32307-2-git-send-email-jsavitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1556830342-32307-2-git-send-email-jsavitz@redhat.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 02 May 2019 21:24:59 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 02, 2019 at 04:52:21PM -0400, Joel Savitz wrote: > 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; Minor pick: I would keep the all of the ternary statement above in the same line, to help on improving readability (even though it bursts a little longer than 80 columns of text) > +} > + > 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 >