Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp13737pxk; Wed, 16 Sep 2020 17:29:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+HaINI7DqQIWQmY0Ce7yXifpJE9AL695IKVz1P+seL5Saj4PmIuil0I4taK2pGAl2kQx/ X-Received: by 2002:a50:9d0a:: with SMTP id v10mr29894046ede.144.1600302568220; Wed, 16 Sep 2020 17:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600302568; cv=none; d=google.com; s=arc-20160816; b=dcXuBB9eHZzlHA+U8FnttJp5hgblJ4K2WtCCnQx4qvsHyC7YB1TFJw8rvHhT3Rw46x CknrdldMrZjMA4d20kpQ2S6CKZrS9SrBwQmk5xPNC627HizG+iUs/ep86m0+vIpuG4cu 6qX4L330BrmQMuSvxeS0y8RaXYPu+sjJPtOFkYKMy/hlAu6spBVAYIdtfNs6E1yb2w+A IyxkQ7aUDRCp3zXCsYZuvMQxOEDTX6l8Tur8zIdat4P4ilW42SrbuorXCdeUVaR0neOQ JV6E49lteLljrQHOWb4y8wHJvyXoLjz1owI8nMTFYS7PKSNkWBHHsSJ19OErlb6qBuz8 U+LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=S+7HH+9sjziuLtV3gM0ei4or9mIwAUYM8d+qtYY6Yeo=; b=bvNvAaqaZa6AwZ5pJx3IpEwB+r7kxf3k+vfMAnNW3cjnovxemoTn0VSw8gaQy2pjey YyU4G4i+ABmnl082Kbz1YTcdzNdsDTzdCRdRVl3DbMF3dGEdjmtPTasbq3ooEanYxg9+ 1AA8UnFqBeT8Iqpyfq1POJ3F8kjR5Y2CcUAbclaQEKiJjDsElZs4QGSOzRaa3xBf3QDX /5UjVV1MMeA1mU/mINBm2VoFk7kuUbbpfiDgv0a1+RojfwNfHvy0qJ3yKekXHuIJL9vD FPX9m7txQz6GZ2C6pFMa4hvyLZGGp8N9YFyJxqA/B3UJIO3kRoV/mhL67Rla/5c1kdHE /zRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si5706726edt.107.2020.09.16.17.29.05; Wed, 16 Sep 2020 17:29:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726129AbgIQA2A (ORCPT + 99 others); Wed, 16 Sep 2020 20:28:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbgIQA2A (ORCPT ); Wed, 16 Sep 2020 20:28:00 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B099C061756; Wed, 16 Sep 2020 17:22:48 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIhh8-0004tj-2A; Thu, 17 Sep 2020 00:22:38 +0000 Date: Thu, 17 Sep 2020 01:22:38 +0100 From: Al Viro To: Eric Biggers Cc: Anant Thazhemadam , linux-kernel-mentees@lists.linuxfoundation.org, syzbot+4191a44ad556eacc1a7a@syzkaller.appspotmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs: fix KMSAN uninit-value bug by initializing nd in do_file_open_root Message-ID: <20200917002238.GO3421308@ZenIV.linux.org.uk> References: <20200916052657.18683-1-anant.thazhemadam@gmail.com> <20200916054157.GC825@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200916054157.GC825@sol.localdomain> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 10:41:57PM -0700, Eric Biggers wrote: > Looking at the actual KMSAN report, it looks like it's nameidata::dir_mode or > nameidata::dir_uid that is uninitialized. You need to figure out the correct > solution, not just blindly initialize with zeroes -- that could hide a bug. > Is there a bug that is preventing these fields from being initialized to the > correct values, are these fields being used when they shouldn't be, etc... False positive, and this is the wrong place to shut it up. ->dir_uid and ->dir_mode are set when link_path_walk() resolves the pathname to directory + final component. They are used when deciding whether to reject a trailing symlink (on fs.protected_symlinks setups) and whether to allow creation in sticky directories (on fs.protected_regular and fs.protected_fifos setups). Both operations really need the results of successful link_path_walk(). I don't see how that could be not a false positive. If we hit the use in may_create_in_sticky(), we'd need the combination of * pathname that consists only of slashes (or it will be initialized) * LAST_NORM in nd->last_type, which is flat-out impossible, since we are left with LAST_ROOT for such pathnames. The same goes for may_follow_link() use - we need WALK_TRAILING in flags to hit it in the first place, which can come from two sources - return walk_component(nd, WALK_TRAILING); in lookup_last() (and walk_component() won't go anywhere near the call chain leading to may_follow_link() without LAST_NORM in nd->last_type) and res = step_into(nd, WALK_TRAILING, dentry, inode, seq); in open_last_lookups(), which also won't go anywhere near that line without LAST_NORM in the nd->last_type. IOW, unless we manage to call that without having called link_path_walk() at all or after link_path_walk() returning an error, we shouldn't hit that. And if we *do* go there without link_path_walk() or with an error from link_path_walk(), we have a much worse problem. I want to see the details of reproducer. If it's for real, we have a much more serious problem; if it's a false positive, the right place to deal with it would be elsewhere (perhaps on return from link_path_walk() with a slashes-only pathname), but in any case it should only be done after we manage to understand what's going on.