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 X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90F7EC2BA19 for ; Mon, 13 Apr 2020 16:16:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 530882072C for ; Mon, 13 Apr 2020 16:16:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tPHYEueR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 530882072C Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CED508E0128; Mon, 13 Apr 2020 12:16:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9DB48E0104; Mon, 13 Apr 2020 12:16:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B64C98E0128; Mon, 13 Apr 2020 12:16:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id A14588E0104 for ; Mon, 13 Apr 2020 12:16:38 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5CBAB180AD802 for ; Mon, 13 Apr 2020 16:16:38 +0000 (UTC) X-FDA: 76703334876.23.rest45_5702c25a73d60 X-HE-Tag: rest45_5702c25a73d60 X-Filterd-Recvd-Size: 5319 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Apr 2020 16:16:37 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id a81so10503962wmf.5 for ; Mon, 13 Apr 2020 09:16:37 -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=wwSnIcKscgkMj4JuaYKW3ZGTN3AuhsuBA341wDfY3DQ=; b=tPHYEueRydmXQJLXhS7+rTpLvsI5/cxafNFsmPxQth33Z1cwAh3+IPSMRBd3cqQUEV yCHC/jwfqV2ai6brHWpY5R0vVP2Y3Ud4MysjT1ZNTAbqFe15RIQ7m5lo/glu9y1qsU2l KIBC1xKLnHIBKtnZDyxr6IJV0zMrEyrGjENVZrUqjo8fgasmVnxgOKphCDba2dTL9fNc ArGVY4TaCx2gTsK3BX4C4zpbqE/gXSj//hM4TTi6phXhdQl4geLEC9HPCO32nBfh5Nld J+5uvFS4LC4wl+amSbGY/FYd1+1AhgiUr6/Znx+EAVERZavBAl4icVfcPBSva+1NMyDU QUFQ== 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=wwSnIcKscgkMj4JuaYKW3ZGTN3AuhsuBA341wDfY3DQ=; b=gicXndZ7vJ+QrtEZQZM+JdxENvdZsyaEOI174mhRczobi/q/mhW/ysEnM9itR/4wVb zEuxlumTkgAvp6HTeIrb+VYgz3wbd0ciS5NNMXZxO9lwDEkfrwq7ZyBeR/YfkiwzROua /8LEgE0cqm/wYnW6NX4uw0ee0irt0SUUeB6bUoHsIlqL8jPmTSx5uV4HwKLWH5TKEMCh ueEELVCQtWn/rYAIIZAfpWtXNckDwr2OsBOZoXqg/2Ix3IWL90GuZseZ26y2He5bC8/R ub0tfSilxoL4fMoGsMIj29Q+QXmb9E/iYOx7SrL1qP0wluSzEwQsGwwiC7RZ8jXiU753 Pphg== X-Gm-Message-State: AGi0PuYK+4gCee9Vjks4dXSJ74cP790HIXmLe/ALxVIpUezPB9U/8Oex Vwddp3Ob4O2r0+LRdX9S5mq+gAu82lM96lkB6mBIPw== X-Google-Smtp-Source: APiQypJtJfAM9uHORCn90/mace6eFlmSMxck0IQUwPJkqn6Oy3Fn2txb3KxhqLEf8d9Xltiel3RgTuHW8RkFocL/nbY= X-Received: by 2002:a05:600c:2a52:: with SMTP id x18mr18729598wme.37.1586794596363; Mon, 13 Apr 2020 09:16:36 -0700 (PDT) MIME-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> <20200325161249.55095-33-glider@google.com> <20200413113247.0752010b@gandalf.local.home> In-Reply-To: <20200413113247.0752010b@gandalf.local.home> From: Alexander Potapenko Date: Mon, 13 Apr 2020 18:16:24 +0200 Message-ID: Subject: Re: [PATCH v5 32/38] kmsan: disable strscpy() optimization under KMSAN To: Steven Rostedt Cc: Andrey Konovalov , Vegard Nossum , Dmitry Vyukov , Marco Elver , Linux Memory Management List , Alexander Viro , Andreas Dilger , Andrew Morton , Andrey Ryabinin , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Christoph Hellwig , Christoph Hellwig , "Darrick J. Wong" , "David S. Miller" , Dmitry Torokhov , Eric Biggers , Eric Dumazet , Eric Van Hensbergen , Greg Kroah-Hartman , Harry Wentland , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jason Wang , Jens Axboe , Marek Szyprowski , Mark Rutland , "Martin K. Petersen" , Martin Schwidefsky , Matthew Wilcox , "Michael S . Tsirkin" , Michal Hocko , Michal Simek , Petr Mladek , Qian Cai , Randy Dunlap , Robin Murphy , Sergey Senozhatsky , Takashi Iwai , "Theodore Ts'o" , Thomas Gleixner , Vasily Gorbik , Wolfram Sang Content-Type: text/plain; charset="UTF-8" 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: > > Instead of disabling the optimization, can't you make KMSAN aware of the > "has_zero()" call (which I believe is the part that will trip up KMSAN) and > just not report it? > > -- Steve I don't think this is the right thing to do. If we read a short string - e.g. only 4 bytes long, using read_word_at_a_time(), we'll also read uninitialized bytes after the trailing zero, which will lead to false positives we're trying to avoid. But if there's no trailing zero, or if the first 4 bytes are uninitialized as well, we want to catch that, so we must not ignore functions that operate on those bytes. We could theoretically make read_word_at_a_time() mask out the bytes past the trailing zero in KMSAN mode, but IIUC that function may read binary data as well.