Received: by 10.213.65.68 with SMTP id h4csp2277017imn; Thu, 5 Apr 2018 12:03:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx48q6ewwy+tJFPzk74ycZpVNtjA6OXc0AE2keBLzhu71AiSy7ODbMrdI+5N2GYELSgej2gFS X-Received: by 10.98.153.204 with SMTP id t73mr18071035pfk.121.1522954998283; Thu, 05 Apr 2018 12:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522954998; cv=none; d=google.com; s=arc-20160816; b=uDZQbCnlUmil+3cJznuilBTSTaIV8uwfg54aY67aqNIob5i8Dgc6Lu+D8wqMza9eRx eNlSa8bEfp6WhjdzpWkKdGx3PZuuiLxVt74/hCXcWymT/PuOpKh1Q3guqh72ZtMQTZXp FWCeTTaxr5ZSmwsb7YYv2ASXhiKNnhn8Dq6McIMXzXrO2o+rf3sy3UUEfAS5/mGwhSCo Q1go9ERhQO1uJ893n654ilyPmDKrleb0Kp1QDI/YTL6E2KkBbgYnP2XeobJiSUr9G/pU OEfdLisYE4a5bgw13lYsr1rma0nHwWAIw6PZRimSR7eh3LDnohYt2kGgt5lYZJk4+iDf csFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=0w5VN7oTv0LiWMnIrcgFIW5qIu4rwjCwFSqcr4mMtIM=; b=RL57ZsK7mg7yOoOuM0j6cMSEyEijHkVjhwjRXFDlziVT5IQhPEw+v5838dlcVq6rcM h8aodr0yXAM2Oh2M4lztCLX3NgpRlFnyyiHWG0Xp+v3z8wEFl4gJ9zCPZgZbcBgFyaoh iwET6qrH+FKpaISiyDtp8BtOFdJmjaDvHVd5UPBXGFpZimHuDVQbOMotcb0q9OxWAPmX o7KoRGHJVJOwg6Lueia1bTE+bNqh8A8wfzQZSY6xSwcacXNuMjG/9U4NkzdvaerMSbqs wBz7wbzsWNwae9Qc10SRq41e+AmpbTgn+IkEur7qFJmULoipkEMLWvLKZpYtpM91kq7E AEPQ== 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=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si6593662plo.55.2018.04.05.12.02.58; Thu, 05 Apr 2018 12:03:18 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752318AbeDETAM (ORCPT + 99 others); Thu, 5 Apr 2018 15:00:12 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:60535 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752274AbeDETAJ (ORCPT ); Thu, 5 Apr 2018 15:00:09 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0T-jhgN4_1522954792; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T-jhgN4_1522954792) by smtp.aliyun-inc.com(127.0.0.1); Fri, 06 Apr 2018 03:00:01 +0800 Subject: Re: [PATCH v2] prctl: Deprecate non PR_SET_MM_MAP operations To: Cyrill Gorcunov , LKML Cc: Michal Hocko , Randy Dunlap , Andrey Vagin , Andrew Morton , Pavel Emelyanov , Michael Kerrisk References: <20180405182651.GM15783@uranus.lan> From: Yang Shi Message-ID: Date: Thu, 5 Apr 2018 11:59:48 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180405182651.GM15783@uranus.lan> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/5/18 11:26 AM, Cyrill Gorcunov wrote: > An ability to manipulate mm_struct fields was introduced in > sake of CRIU in first place. Later we provide more suitable > and safe operation PR_SET_MM_MAP where all fields to be modifed > are passed in one structure which allows us to make more detailed > verification. > > Still old interface remains present for compatibility reason > though CRIU itself already switched to PR_SET_MM_MAP on its > own long ago. > > Googling didn't reveal some other users of this operation > so I think it should be safe to remove this interface. > > v2: > - Improve warning message > - Drop redundant args check > > CC: Andrey Vagin > CC: Andrew Morton > CC: Pavel Emelyanov > CC: Michael Kerrisk > CC: Yang Shi > CC: Michal Hocko > Signed-off-by: Cyrill Gorcunov Acked-by: Yang Shi > --- > kernel/sys.c | 151 ----------------------------------------------------------- > 1 file changed, 2 insertions(+), 149 deletions(-) > > Index: linux-ml.git/kernel/sys.c > =================================================================== > --- linux-ml.git.orig/kernel/sys.c > +++ linux-ml.git/kernel/sys.c > @@ -2053,163 +2053,16 @@ static int prctl_set_mm_map(int opt, con > } > #endif /* CONFIG_CHECKPOINT_RESTORE */ > > -static int prctl_set_auxv(struct mm_struct *mm, unsigned long addr, > - unsigned long len) > -{ > - /* > - * This doesn't move the auxiliary vector itself since it's pinned to > - * mm_struct, but it permits filling the vector with new values. It's > - * up to the caller to provide sane values here, otherwise userspace > - * tools which use this vector might be unhappy. > - */ > - unsigned long user_auxv[AT_VECTOR_SIZE]; > - > - if (len > sizeof(user_auxv)) > - return -EINVAL; > - > - if (copy_from_user(user_auxv, (const void __user *)addr, len)) > - return -EFAULT; > - > - /* Make sure the last entry is always AT_NULL */ > - user_auxv[AT_VECTOR_SIZE - 2] = 0; > - user_auxv[AT_VECTOR_SIZE - 1] = 0; > - > - BUILD_BUG_ON(sizeof(user_auxv) != sizeof(mm->saved_auxv)); > - > - task_lock(current); > - memcpy(mm->saved_auxv, user_auxv, len); > - task_unlock(current); > - > - return 0; > -} > - > static int prctl_set_mm(int opt, unsigned long addr, > unsigned long arg4, unsigned long arg5) > { > - struct mm_struct *mm = current->mm; > - struct prctl_mm_map prctl_map; > - struct vm_area_struct *vma; > - int error; > - > - if (arg5 || (arg4 && (opt != PR_SET_MM_AUXV && > - opt != PR_SET_MM_MAP && > - opt != PR_SET_MM_MAP_SIZE))) > - return -EINVAL; > - > #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); > #endif > > - if (!capable(CAP_SYS_RESOURCE)) > - return -EPERM; > - > - if (opt == PR_SET_MM_EXE_FILE) > - return prctl_set_mm_exe_file(mm, (unsigned int)addr); > - > - if (opt == PR_SET_MM_AUXV) > - return prctl_set_auxv(mm, addr, arg4); > - > - if (addr >= TASK_SIZE || addr < mmap_min_addr) > - return -EINVAL; > - > - error = -EINVAL; > - > - down_write(&mm->mmap_sem); > - vma = find_vma(mm, addr); > - > - prctl_map.start_code = mm->start_code; > - prctl_map.end_code = mm->end_code; > - prctl_map.start_data = mm->start_data; > - prctl_map.end_data = mm->end_data; > - prctl_map.start_brk = mm->start_brk; > - prctl_map.brk = mm->brk; > - prctl_map.start_stack = mm->start_stack; > - prctl_map.arg_start = mm->arg_start; > - prctl_map.arg_end = mm->arg_end; > - prctl_map.env_start = mm->env_start; > - prctl_map.env_end = mm->env_end; > - prctl_map.auxv = NULL; > - prctl_map.auxv_size = 0; > - prctl_map.exe_fd = -1; > - > - switch (opt) { > - case PR_SET_MM_START_CODE: > - prctl_map.start_code = addr; > - break; > - case PR_SET_MM_END_CODE: > - prctl_map.end_code = addr; > - break; > - case PR_SET_MM_START_DATA: > - prctl_map.start_data = addr; > - break; > - case PR_SET_MM_END_DATA: > - prctl_map.end_data = addr; > - break; > - case PR_SET_MM_START_STACK: > - prctl_map.start_stack = addr; > - break; > - case PR_SET_MM_START_BRK: > - prctl_map.start_brk = addr; > - break; > - case PR_SET_MM_BRK: > - prctl_map.brk = addr; > - break; > - case PR_SET_MM_ARG_START: > - prctl_map.arg_start = addr; > - break; > - case PR_SET_MM_ARG_END: > - prctl_map.arg_end = addr; > - break; > - case PR_SET_MM_ENV_START: > - prctl_map.env_start = addr; > - break; > - case PR_SET_MM_ENV_END: > - prctl_map.env_end = addr; > - break; > - default: > - goto out; > - } > - > - error = validate_prctl_map(&prctl_map); > - if (error) > - goto out; > - > - switch (opt) { > - /* > - * If command line arguments and environment > - * are placed somewhere else on stack, we can > - * set them up here, ARG_START/END to setup > - * command line argumets and ENV_START/END > - * for environment. > - */ > - case PR_SET_MM_START_STACK: > - case PR_SET_MM_ARG_START: > - case PR_SET_MM_ARG_END: > - case PR_SET_MM_ENV_START: > - case PR_SET_MM_ENV_END: > - if (!vma) { > - error = -EFAULT; > - goto out; > - } > - } > - > - mm->start_code = prctl_map.start_code; > - mm->end_code = prctl_map.end_code; > - mm->start_data = prctl_map.start_data; > - mm->end_data = prctl_map.end_data; > - mm->start_brk = prctl_map.start_brk; > - mm->brk = prctl_map.brk; > - mm->start_stack = prctl_map.start_stack; > - mm->arg_start = prctl_map.arg_start; > - mm->arg_end = prctl_map.arg_end; > - mm->env_start = prctl_map.env_start; > - mm->env_end = prctl_map.env_end; > - > - error = 0; > -out: > - up_write(&mm->mmap_sem); > - return error; > + pr_warn_once("PR_SET_MM_* has been removed. Use PR_SET_MM_MAP instead\n"); > + return -EINVAL; > } > > #ifdef CONFIG_CHECKPOINT_RESTORE