From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 656B2C433EF for ; Fri, 15 Jul 2022 14:04:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 860D79401EA; Fri, 15 Jul 2022 10:04:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 80FA89401E5; Fri, 15 Jul 2022 10:04:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B11F9401EA; Fri, 15 Jul 2022 10:04:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5BF3F9401E5 for ; Fri, 15 Jul 2022 10:04:15 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2E0D31532 for ; Fri, 15 Jul 2022 14:04:15 +0000 (UTC) X-FDA: 79689503670.14.A260335 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) by imf10.hostedemail.com (Postfix) with ESMTP id BF7DCC00B2 for ; Fri, 15 Jul 2022 14:04:14 +0000 (UTC) Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-31cf1adbf92so47899887b3.4 for ; Fri, 15 Jul 2022 07:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tZbUeRm/9AH1INImc98b+lXwt9te6SiwEwSsvsXtU7U=; b=HrpsJWtwmQ9ekYvTdwtF/WY3dLb3MVo6tgR6xzAnu14ueeErPHm3YXgq8kEywRoQT9 ngt1eXmRmHLFlhpB8EsyrRFALa3HB5bR2w9S1BiGH9XkYA0iuWdFq/sK0OXq/HoBGYZP +HmlwDp+tDA3tqrcKWVhlTZzyz6veoXD9T/aD/rNGXWnXU759JQdSqW2atxZpLUqG5zu qS069+qHp6uEe0+SpNnCRrM3iiLy/kCOvG5VXCeVuTToSG+GGdqUpgtNnCLF4D6E4ElF cfZo/AEBGV/LvHrQtDLFds6ma3xCbjLgTAvYEP4tmkiV95v7JrNlQ8y36QVRfY/wd0qd 0aEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tZbUeRm/9AH1INImc98b+lXwt9te6SiwEwSsvsXtU7U=; b=reo8myKny1jFJhZzKK+0QKqSLv4NUo5yg3LsS8uPj7Tjjaisy560hUR0pIUu6iZqbd hJ0QTlT17xIBX1t+R2kLfs+CVNN8sOizChwcqbtNPQpBA/dcha/k8HKrX3xPh92BCJ3R cLYAFQgvETXogjxabAhEhNC9csi5D4552EzpKQk1Hz2D+phJ6r0na1guVA0zy3rkrhHR rzIj9fblWudg9WlzmX64HOBItxP64XtQuIiSP2YspgqNX++GDNpiwg9F4REOT2l2Bot4 FaXnjWC9ncoAIuWtUCMh9xMbJ84gGXSjNGEO/I388xhpKMSmEhKZ+p5bjyNOVocMKf2/ L1MA== X-Gm-Message-State: AJIora/lo2A3jDarWNUuqiHXY+to2vc4pQSsoFNqGgvyYYrImQYzluLs Dyzkct09Raq9WjF4uer4xBtg3K11rVjPplWwIjVbeQ== X-Google-Smtp-Source: AGRyM1vTNqLvRPyP2fz5KJ0hzxm0vxoa0EEduLZWOubVw12iZfuJZc0tNKha49W5RL8bGrDLwWHnIVzDHwzR/npabys= X-Received: by 2002:a81:e0b:0:b0:31c:1b57:2509 with SMTP id 11-20020a810e0b000000b0031c1b572509mr16488605ywo.461.1657893853623; Fri, 15 Jul 2022 07:04:13 -0700 (PDT) MIME-Version: 1.0 References: <20220701142310.2188015-5-glider@google.com> <202207021129.palrTLrL-lkp@intel.com> In-Reply-To: <202207021129.palrTLrL-lkp@intel.com> From: Alexander Potapenko Date: Fri, 15 Jul 2022 16:03:37 +0200 Message-ID: Subject: Re: [PATCH v4 04/45] x86: asm: instrument usercopy in get_user() and __put_user_size() To: kernel test robot Cc: kbuild-all@lists.01.org, Alexander Viro , Alexei Starovoitov , Andrew Morton , Linux Memory Management List , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657893854; a=rsa-sha256; cv=none; b=6XE10/1PJA17+9g1uuWwk2hazZTOsiXGlWrVCU+xw08D0Sqkzi2ZVaprR7IWTCo1Gl9MSX j9vz40rnzFqj+wZ4FjfZElJCiUKa7zWo0HwkKcaVKnfwUJM292ZFQm2IOuI+xkyZlDv0i5 C+CeGuOK7kHupoWQNb05ylCk1fZnPKU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=HrpsJWtw; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of glider@google.com designates 209.85.128.182 as permitted sender) smtp.mailfrom=glider@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657893854; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tZbUeRm/9AH1INImc98b+lXwt9te6SiwEwSsvsXtU7U=; b=UoFnZhgyPmH8jQFOBI6b84DKzpFfgKBpEsK11i0i6qDezOflx2wo6M6sGGEV6fDjH7IeIQ dw6HWkWbDfzvYd0QGgCyIHySAGDe9EfPjYwB1gOdyP9GIIqDTgU+SrnyrlN66dy0nz9WLC LffO8GSMCln5DX2KmOM8AOaBr4NANgE= X-Stat-Signature: tycawom69mxuou6af4ieswcaiicq6pgs X-Rspam-User: X-Rspamd-Queue-Id: BF7DCC00B2 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=HrpsJWtw; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of glider@google.com designates 209.85.128.182 as permitted sender) smtp.mailfrom=glider@google.com X-Rspamd-Server: rspam11 X-HE-Tag: 1657893854-637922 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Jul 2, 2022 at 5:47 AM kernel test robot wrote: > > Hi Alexander, > > I love your patch! Perhaps something to improve: > > [auto build test WARNING on masahiroy-kbuild/for-next] > [also build test WARNING on linus/master v5.19-rc4 next-20220701] > [cannot apply to tip/x86/core tip/x86/mm] > [If your patch is applied to the wrong git tree, kindly drop us a note. > And when submitting patch, we suggest to use '--base' as documented in > https://git-scm.com/docs/git-format-patch] > > url: https://github.com/intel-lab-lkp/linux/commits/Alexander-Potapenko/Add-KernelMemorySanitizer-infrastructure/20220701-222712 > base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next > config: i386-randconfig-s002 (https://download.01.org/0day-ci/archive/20220702/202207021129.palrTLrL-lkp@intel.com/config) > compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 > reproduce: > # apt-get install sparse > # sparse version: v0.6.4-39-gce1a6720-dirty > # https://github.com/intel-lab-lkp/linux/commit/0ca0e4029535365a65588446ba55a952ca186079 > git remote add linux-review https://github.com/intel-lab-lkp/linux > git fetch --no-tags linux-review Alexander-Potapenko/Add-KernelMemorySanitizer-infrastructure/20220701-222712 > git checkout 0ca0e4029535365a65588446ba55a952ca186079 > # save the config file > mkdir build_dir && cp config build_dir/.config > make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash arch/x86/kernel/ mm/ > > If you fix the issue, kindly add following tag where applicable > Reported-by: kernel test robot > > > sparse warnings: (new ones prefixed by >>) > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned long long [usertype] * @@ > arch/x86/kernel/signal.c:360:9: sparse: expected void const volatile [noderef] __user *ptr > arch/x86/kernel/signal.c:360:9: sparse: got unsigned long long [usertype] * > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > >> arch/x86/kernel/signal.c:360:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user *to @@ got unsigned long long [usertype] * @@ > arch/x86/kernel/signal.c:360:9: sparse: expected void [noderef] __user *to > arch/x86/kernel/signal.c:360:9: sparse: got unsigned long long [usertype] * > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:360:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned long long [usertype] * @@ > arch/x86/kernel/signal.c:420:9: sparse: expected void const volatile [noderef] __user *ptr > arch/x86/kernel/signal.c:420:9: sparse: got unsigned long long [usertype] * > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user *to @@ got unsigned long long [usertype] * @@ > arch/x86/kernel/signal.c:420:9: sparse: expected void [noderef] __user *to > arch/x86/kernel/signal.c:420:9: sparse: got unsigned long long [usertype] * > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:420:9: sparse: sparse: cast removes address space '__user' of expression > arch/x86/kernel/signal.c:953:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct lockdep_map const *lock @@ got struct lockdep_map [noderef] __rcu * @@ > arch/x86/kernel/signal.c:953:9: sparse: expected struct lockdep_map const *lock > arch/x86/kernel/signal.c:953:9: sparse: got struct lockdep_map [noderef] __rcu * Looks like sparse is complaining about the missing __user attribute in the cast: ============================================ diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 9c7265b524c73..437de52e2ecaa 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -357,7 +357,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set, * reasons and because gdb uses it as a signature to notice * signal handler stack frames. */ - unsafe_put_user(*((u64 *)&retcode), (u64 *)frame->retcode, Efault); + unsafe_put_user(*((u64 *)&retcode), (__user u64 *)frame->retcode, Efault); user_access_end(); /* Set up registers for signal handler */ ============================================ The only reason it blames KMSAN patches is because those add yet another hook inside unsafe_put_user() that expects a __user pointer.