Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp595906img; Mon, 18 Mar 2019 09:54:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzR1BJKzK6CqdrE6IZbuNsF2vXPW8RscgIQMGYITd7Wtiollpk098M5OZGcLFkQ+FDceAsf X-Received: by 2002:a63:2bd5:: with SMTP id r204mr18812461pgr.48.1552928096394; Mon, 18 Mar 2019 09:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552928096; cv=none; d=google.com; s=arc-20160816; b=dE7SPyLOzs1iOdS1ZsE7yCKy8KXL5yExmSuXNbsDKMMacfCUipIG1pLm/c9IsEgDl9 yyJuc7gu3kz04iYknX9KyHcrgksbEoO0fMgnmrEcP72jlBqpbYxqijunn117PS1hI282 wNiwR1z1I/CYwEUCFKDwLD8EFjZCCj0pPTkOicKPd/ZqfYWcr68CevQ+ifW34/6UZEgA oqY5/AKhGzgTMTFCN9h4YVMngwT8/p9QhMjSHRKUT+Dw52QMBq2oQg7CfZLl6yFgAAKf xGK/Te82CFVQdu7DRdT8fDpwHtmigB82/T5p48BdAiuxsPFhfP/p0p6dMLrmHnF4IGBN U7Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Vs0GZwImU6CsIFzm114RTXl1boU0bAYEV2fL9XPHMXI=; b=o8HAxNWWJi5CLdK4Oa45IORmrucuhX7ipBwv2g9Utq/duY2nYUuYdKGVOL1fC+UdIw 5PkXjcug5Iht0WfeM36tZwNJFbKq8t8BAK0alBZm89a76Jw2HTksDXRtVkV1SmgUxPOM U5hmqemJH3drHgzjABReozxKJkzB3upvrn4pQMxdz460t2ZCIwnEIYNZvIRPcmoF0BWt Z4p1d4cgb9QTYh5dQ0AjuoSJPQQBzcVxcl6Em54wLo5bq0y8iA28Qe+2uCs7khw6sqrH i6nBWdXjKwa1Mqd6L5zn/9sJ4NRUMaqaM0IFmnaoX2jufpHg70IVoIAiX79UmZBGZbo5 o2kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vhygi2in; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c15si9327939pga.465.2019.03.18.09.54.41; Mon, 18 Mar 2019 09:54:56 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=vhygi2in; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727779AbfCRQxO (ORCPT + 99 others); Mon, 18 Mar 2019 12:53:14 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:32786 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726907AbfCRQxN (ORCPT ); Mon, 18 Mar 2019 12:53:13 -0400 Received: by mail-pf1-f196.google.com with SMTP id i19so11677442pfd.0 for ; Mon, 18 Mar 2019 09:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Vs0GZwImU6CsIFzm114RTXl1boU0bAYEV2fL9XPHMXI=; b=vhygi2inIY6QcoMUgdkRT9Nhi0bhC4doWtBXddCRepRu/Td+bIk+Vbe8EZn4ZeJ8jF Y2qpNC1dZoVWnQ3xz7Nw7zSQp/FvsAG0Mek+QVyTz7cIULVbIRBatVy3ph8oxnjZDvXj WwriDsizH4FtV3nQUnWVGkBnVci2/xZITRCJh69AV7aHHRlRas8vRIgSpMHTyU/NG3la 0ngh5cQYgDcmAYshLWMtVg5K/robxWQboPv3FXrNJ25FlCTlfdzPmYV5pquOqJbVCfPa X34Yrfpq2gV+vNusESF32Kv1JqOd45AEM8y6dtjMDqjgEquUQPk4an4fl0N6gqH80Dro o5BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Vs0GZwImU6CsIFzm114RTXl1boU0bAYEV2fL9XPHMXI=; b=FbrG1Q7igNbpeu/KlKlBDEbL7LB/C2IKyhhkmjNkrp56M7p/DNUv9NrJ6mg+ooonVA HjwKmSV/S/jdbW4qaANLgyxW/IeVrHwrZe2IsUD8OXIwUQC6sWWHC+Uq8Dljc+ZnOdJO G7rmtPRQlLoiaGiKwhybMTfHwmoaYDWsy7+0VtK5uhcZnafYKlH8aNWK4XNVWgwmye4R ajgxrc7kS3+ie702GpsWl0acqttUMxKuQ9tUQC0tfeqp15GJdf7GSzXZs9/8hxGP5H3F Z5LvpO4ItEaEX4BG94j0651E+3XegONRGBFmdnU5upC/ntFTQqm+5Hk9jVmUPLMLZMWI hrNA== X-Gm-Message-State: APjAAAVyextAQE8CsPBc/9yjIAAp6i0JZQiTI93LdOtL4hcUJZ6kE1BO d8KVdEBD+/HXZiWgJ/RR560hiBRZPG94nlMZAETsmA== X-Received: by 2002:a63:fd03:: with SMTP id d3mr18189137pgh.359.1552927991651; Mon, 18 Mar 2019 09:53:11 -0700 (PDT) MIME-Version: 1.0 References: <201903170317.IWsOYXBe%lkp@intel.com> In-Reply-To: <201903170317.IWsOYXBe%lkp@intel.com> From: Andrey Konovalov Date: Mon, 18 Mar 2019 17:53:00 +0100 Message-ID: Subject: Re: [PATCH v11 09/14] kernel, arm64: untag user pointers in prctl_set_mm* To: kbuild test robot Cc: kbuild-all@01.org, 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 , Eric Dumazet , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , Linux ARM , "open list:DOCUMENTATION" , Linux Memory Management List , linux-arch , netdev , bpf , "open list:KERNEL SELFTEST FRAMEWORK" , LKML , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 16, 2019 at 8:32 PM kbuild test robot wrote: > > Hi Andrey, > > Thank you for the patch! Yet something to improve: > > [auto build test ERROR on linus/master] > [also build test ERROR on v5.0 next-20190306] > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] > > url: https://github.com/0day-ci/linux/commits/Andrey-Konovalov/uaccess-add-untagged_addr-definition-for-other-arches/20190317-015913 > config: x86_64-randconfig-x012-201911 (attached as .config) > compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 > reproduce: > # save the attached .config to linux build tree > make ARCH=x86_64 > > All errors (new ones prefixed by >>): > > kernel/sys.c: In function 'prctl_set_mm_map': > >> kernel/sys.c:1996:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->start_code = untagged_addr(prctl_map.start_code); > ^~ > kernel/sys.c:1997:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->end_code = untagged_addr(prctl_map.end_code); > ^~ > kernel/sys.c:1998:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->start_data = untagged_addr(prctl_map.start_data); > ^~ > kernel/sys.c:1999:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->end_data = untagged_addr(prctl_map.end_data); > ^~ > kernel/sys.c:2000:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->start_brk = untagged_addr(prctl_map.start_brk); > ^~ > kernel/sys.c:2001:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->brk = untagged_addr(prctl_map.brk); > ^~ > kernel/sys.c:2002:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->start_stack = untagged_addr(prctl_map.start_stack); > ^~ > kernel/sys.c:2003:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->arg_start = untagged_addr(prctl_map.arg_start); > ^~ > kernel/sys.c:2004:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->arg_end = untagged_addr(prctl_map.arg_end); > ^~ > kernel/sys.c:2005:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->env_start = untagged_addr(prctl_map.env_start); > ^~ > kernel/sys.c:2006:11: error: invalid type argument of '->' (have 'struct prctl_mm_map') > prctl_map->env_end = untagged_addr(prctl_map.env_end); > ^~ > > vim +1996 kernel/sys.c Right, I didn't have the related config options enabled when I did the testing... > > 1974 > 1975 #ifdef CONFIG_CHECKPOINT_RESTORE > 1976 static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data_size) > 1977 { > 1978 struct prctl_mm_map prctl_map = { .exe_fd = (u32)-1, }; > 1979 unsigned long user_auxv[AT_VECTOR_SIZE]; > 1980 struct mm_struct *mm = current->mm; > 1981 int error; > 1982 > 1983 BUILD_BUG_ON(sizeof(user_auxv) != sizeof(mm->saved_auxv)); > 1984 BUILD_BUG_ON(sizeof(struct prctl_mm_map) > 256); > 1985 > 1986 if (opt == PR_SET_MM_MAP_SIZE) > 1987 return put_user((unsigned int)sizeof(prctl_map), > 1988 (unsigned int __user *)addr); > 1989 > 1990 if (data_size != sizeof(prctl_map)) > 1991 return -EINVAL; > 1992 > 1993 if (copy_from_user(&prctl_map, addr, sizeof(prctl_map))) > 1994 return -EFAULT; > 1995 > > 1996 prctl_map->start_code = untagged_addr(prctl_map.start_code); > 1997 prctl_map->end_code = untagged_addr(prctl_map.end_code); > 1998 prctl_map->start_data = untagged_addr(prctl_map.start_data); > 1999 prctl_map->end_data = untagged_addr(prctl_map.end_data); > 2000 prctl_map->start_brk = untagged_addr(prctl_map.start_brk); > 2001 prctl_map->brk = untagged_addr(prctl_map.brk); > 2002 prctl_map->start_stack = untagged_addr(prctl_map.start_stack); > 2003 prctl_map->arg_start = untagged_addr(prctl_map.arg_start); > 2004 prctl_map->arg_end = untagged_addr(prctl_map.arg_end); > 2005 prctl_map->env_start = untagged_addr(prctl_map.env_start); > 2006 prctl_map->env_end = untagged_addr(prctl_map.env_end); > 2007 > 2008 error = validate_prctl_map(&prctl_map); > 2009 if (error) > 2010 return error; > 2011 > 2012 if (prctl_map.auxv_size) { > 2013 memset(user_auxv, 0, sizeof(user_auxv)); > 2014 if (copy_from_user(user_auxv, > 2015 (const void __user *)prctl_map.auxv, > 2016 prctl_map.auxv_size)) > 2017 return -EFAULT; > 2018 > 2019 /* Last entry must be AT_NULL as specification requires */ > 2020 user_auxv[AT_VECTOR_SIZE - 2] = AT_NULL; > 2021 user_auxv[AT_VECTOR_SIZE - 1] = AT_NULL; > 2022 } > 2023 > 2024 if (prctl_map.exe_fd != (u32)-1) { > 2025 error = prctl_set_mm_exe_file(mm, prctl_map.exe_fd); > 2026 if (error) > 2027 return error; > 2028 } > 2029 > 2030 /* > 2031 * arg_lock protects concurent updates but we still need mmap_sem for > 2032 * read to exclude races with sys_brk. > 2033 */ > 2034 down_read(&mm->mmap_sem); > 2035 > 2036 /* > 2037 * We don't validate if these members are pointing to > 2038 * real present VMAs because application may have correspond > 2039 * VMAs already unmapped and kernel uses these members for statistics > 2040 * output in procfs mostly, except > 2041 * > 2042 * - @start_brk/@brk which are used in do_brk but kernel lookups > 2043 * for VMAs when updating these memvers so anything wrong written > 2044 * here cause kernel to swear at userspace program but won't lead > 2045 * to any problem in kernel itself > 2046 */ > 2047 > 2048 spin_lock(&mm->arg_lock); > 2049 mm->start_code = prctl_map.start_code; > 2050 mm->end_code = prctl_map.end_code; > 2051 mm->start_data = prctl_map.start_data; > 2052 mm->end_data = prctl_map.end_data; > 2053 mm->start_brk = prctl_map.start_brk; > 2054 mm->brk = prctl_map.brk; > 2055 mm->start_stack = prctl_map.start_stack; > 2056 mm->arg_start = prctl_map.arg_start; > 2057 mm->arg_end = prctl_map.arg_end; > 2058 mm->env_start = prctl_map.env_start; > 2059 mm->env_end = prctl_map.env_end; > 2060 spin_unlock(&mm->arg_lock); > 2061 > 2062 /* > 2063 * Note this update of @saved_auxv is lockless thus > 2064 * if someone reads this member in procfs while we're > 2065 * updating -- it may get partly updated results. It's > 2066 * known and acceptable trade off: we leave it as is to > 2067 * not introduce additional locks here making the kernel > 2068 * more complex. > 2069 */ > 2070 if (prctl_map.auxv_size) > 2071 memcpy(mm->saved_auxv, user_auxv, sizeof(user_auxv)); > 2072 > 2073 up_read(&mm->mmap_sem); > 2074 return 0; > 2075 } > 2076 #endif /* CONFIG_CHECKPOINT_RESTORE */ > 2077 > > --- > 0-DAY kernel test infrastructure Open Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation