Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4586645ioa; Wed, 27 Apr 2022 07:02:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTYmg7RmplA120acYOhl+TXINuAGbLRyL4JYrVn6ofCxMidfLrRmKRY/ZMhkWJMjD4xXkk X-Received: by 2002:a02:234a:0:b0:32a:f07c:e8 with SMTP id u71-20020a02234a000000b0032af07c00e8mr6507520jau.87.1651068150835; Wed, 27 Apr 2022 07:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651068150; cv=none; d=google.com; s=arc-20160816; b=iqnsORxb7lm/VQueLPE8Tgr/eAI7VXhFzGuKIy2E/83Bx+TZIk7Vckhn1Y1P7vBEEI HSOQ3tPtTQD5HXjXiB2IXhDJTv7tkgDFFyFKqv5ec4bicGIoM5TeQ290WQXmBr4G4qNx N6E3xnzx0ogCJeZZkEDhO5borsvEYuzBTh4yD53OeRu66QT8RwfS9jmkmpeniaFHHp6R Rpn9Fxg26NJMw/SJKkbUvA+lhpSoEmjVdSBqUF9VhNvMvzGr21oyb4uRF93oEbBnRPKv GGJubBVyOY+rl7B48e30f++UNOeD0l5OHZDJHNZNm9zeS+xHDx53jSZpAlIyhOwEPRAG Qg0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=X7MGqKhcR2rK4bHhpyakvKk80PXfTvRpOEHw1CHocKs=; b=LplqPVEjdfE0/l5Xlig0elaHAaaoVaJ0Evj5mh6XjBGLXu1jCUc3ubbTuwdxX5a68P B7aCIlowvKdB3JsfZW6ul0pNrti8623nut/fjxR27v4bsV8WkvrEw71eS/y5nxcWfAYj FXpXxrkoecuXeQ2ZSLbjQ3qkfg2nGC/fpV8ncxU2B+RNNzsIqsctN5IBOGQpmcm3qN92 jjKjqV2vCONbZQWrHB3mvqid4Twn/5sh3VQQit+3GQsoBn2TrMvWnaPxwescL3op0JCn v0OnGTMmxj+aN+Md1OtEi7nMlvwXJO9CvF+ZHEEalCCdaFlt43pkucMTOtpy1uXW6PUO o9SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ohn+hC64; dkim=neutral (no key) header.i=@linutronix.de header.b=bCDiX4Fi; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e6-20020a022106000000b0032aa0b9fc49si564531jaa.19.2022.04.27.07.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 07:02:30 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ohn+hC64; dkim=neutral (no key) header.i=@linutronix.de header.b=bCDiX4Fi; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9D58149695; Wed, 27 Apr 2022 06:32:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236081AbiD0Nfn (ORCPT + 99 others); Wed, 27 Apr 2022 09:35:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235983AbiD0Nfj (ORCPT ); Wed, 27 Apr 2022 09:35:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23E8A4756A; Wed, 27 Apr 2022 06:32:26 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651066344; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=X7MGqKhcR2rK4bHhpyakvKk80PXfTvRpOEHw1CHocKs=; b=ohn+hC646sn2jflwe2+UxebhGiwPyBV84sJRxiAvyqE37QW7aGwEfptKKOcUr3GZ10ZGJO OK5sYNE/5x1GOtersnl4dBFpoxCEkYLpcHbf6zuIs/HjJsUQuhbYWTRIsF2BLKeE7EPZUT h+qiVebu5bZsClGL1aLHWFs9tBrvecF74Qxr29uhbym2tYsLjtJbiw7fhzfHj+2+unjHXy dVr2VwG+u3k3PQ0XxUQgqmFy6FCIBp95Hh3k7a0U6gcS13RuTKUADQ8fRSQ68kmWkShqAx U/Odt/SoCJYK6j45Dny0vD2N7WOyZ2n5EsUXkEohvuxsvRSwmyMwsH6cgyXa5Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651066344; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=X7MGqKhcR2rK4bHhpyakvKk80PXfTvRpOEHw1CHocKs=; b=bCDiX4Fi9GAN0Y217Gcsro/3hVbm6FpepZEqlCHPe0fNNCAHEf2xbGEkJ8g5sLfVYuqOV2 ZiOzp4zTqL7wE2BQ== To: Alexander Potapenko , glider@google.com Cc: Alexander Viro , Andrew Morton , 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 , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 28/46] kmsan: entry: handle register passing from uninstrumented code In-Reply-To: <20220426164315.625149-29-glider@google.com> References: <20220426164315.625149-1-glider@google.com> <20220426164315.625149-29-glider@google.com> Date: Wed, 27 Apr 2022 15:32:23 +0200 Message-ID: <87a6c6y7mg.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 26 2022 at 18:42, Alexander Potapenko wrote: Can you please use 'entry:' as prefix. Slapping kmsan in front of everything does not really make sense. > Replace instrumentation_begin() with instrumentation_begin_with_regs() > to let KMSAN handle the non-instrumented code and unpoison pt_regs > passed from the instrumented part. That should be: from the non-instrumented part or passed to the instrumented part right? > --- a/kernel/entry/common.c > +++ b/kernel/entry/common.c > @@ -23,7 +23,7 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs) > CT_WARN_ON(ct_state() != CONTEXT_USER); > user_exit_irqoff(); > > - instrumentation_begin(); > + instrumentation_begin_with_regs(regs); I can see what you are trying to do, but this will end up doing the same thing over and over. Let's just look at a syscall. __visible noinstr void do_syscall_64(struct pt_regs *regs, int nr) { ... nr = syscall_enter_from_user_mode(regs, nr) __enter_from_user_mode(regs) ..... instrumentation_begin_with_regs(regs); .... instrumentation_begin_with_regs(regs); .... instrumentation_begin_with_regs(regs); if (!do_syscall_x64(regs, nr) && !do_syscall_x32(regs, nr) && nr != -1) { /* Invalid system call, but still a system call. */ regs->ax = __x64_sys_ni_syscall(regs); } instrumentation_end(); syscall_exit_to_user_mode(regs); instrumentation_begin_with_regs(regs); __syscall_exit_to_user_mode_work(regs); instrumentation_end(); __exit_to_user_mode(); That means you memset state four times and unpoison regs four times. I'm not sure whether that's desired. instrumentation_begin()/end() are not really suitable IMO. They were added to allow objtool to validate that nothing escapes into instrumentable code unless annotated accordingly. Thanks, tglx