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 D16F6EE49A6 for ; Sat, 19 Aug 2023 19:17:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3F8A900010; Sat, 19 Aug 2023 15:17:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BED4C900008; Sat, 19 Aug 2023 15:17:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB502900010; Sat, 19 Aug 2023 15:17:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 97DEB900008 for ; Sat, 19 Aug 2023 15:17:00 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 68801A08B0 for ; Sat, 19 Aug 2023 19:17:00 +0000 (UTC) X-FDA: 81141811800.13.83BBFE1 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by imf05.hostedemail.com (Postfix) with ESMTP id 8152110000A for ; Sat, 19 Aug 2023 19:16:58 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=mit.edu header.s=outgoing header.b=Atxp7UFw; spf=pass (imf05.hostedemail.com: domain of tytso@mit.edu designates 18.9.28.11 as permitted sender) smtp.mailfrom=tytso@mit.edu; dmarc=pass (policy=none) header.from=mit.edu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692472618; 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=6N9EMQdf0dg3QG8w35gHzeeRG5O6PiKxY5DKUYynzzw=; b=4pDK4yduRFdmQlbo4qo+FbZx2LEO20DcGFanpRSq/eMWGLLm3BOJ5UEwEIpQg6iywOMo1W aFp9d4xQjIv3e3YAy32Un67N+YRMuZvSidBcnve1EuAjt3ZyRExVQw9h5kk4yXaM2u3ZWb 8wu03V/oPFDCRpKMfCg14XYJqN49MhU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692472618; a=rsa-sha256; cv=none; b=3gU/hlycxpdKY2mZvdWqWNeUHu72JS2SFG/Vqg/kZA+Aq9RNTCqO9uEk36Ot4IB1JGXqZF JBMLFhUAO2/6ExFYIikLo4b2+rL7/ZdWihvmqE/XiUvMU/Pg0rBWIyLIw27opzZVKPv66p HU6fNPz+OnIWeXjmeQUOE4BVO9BqJdo= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=mit.edu header.s=outgoing header.b=Atxp7UFw; spf=pass (imf05.hostedemail.com: domain of tytso@mit.edu designates 18.9.28.11 as permitted sender) smtp.mailfrom=tytso@mit.edu; dmarc=pass (policy=none) header.from=mit.edu Received: from cwcc.thunk.org (pool-173-48-121-162.bstnma.fios.verizon.net [173.48.121.162]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 37JJGcCr017522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 19 Aug 2023 15:16:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1692472605; bh=6N9EMQdf0dg3QG8w35gHzeeRG5O6PiKxY5DKUYynzzw=; h=Date:From:Subject:Message-ID:MIME-Version:Content-Type; b=Atxp7UFw7l/+ynDLo45X7aYFou+u6wFBCEsfhVVnm6OKRuP0uyYyQPPRclCZsptk6 Uo2Ex0I4P4e85RQ56V6hxZ8xXHNMoQKrzby43drHZHyQED1WxgDAMPaprvKIDFTZxt qtxhJ1TI/0gz3qP655QzThWln9g9002vhBgBmgm9hbeAb5OuLLLMlLls+bR3jmu8xL 8vWJziOlUgCrrHnCvwTqyjbFEVue5jbKrge+JN4nv9hekFBIvNRazZeNcHGXkE52QE L2nNHprUAHFeGB8QLrW4c96SnWN8yaAsosZ5KSMPfYQK+5etVT63CHfCajI0c1477I PcC6DSCHnArzA== Received: by cwcc.thunk.org (Postfix, from userid 15806) id BCAAD15C0292; Sat, 19 Aug 2023 15:16:38 -0400 (EDT) Date: Sat, 19 Aug 2023 15:16:38 -0400 From: "Theodore Ts'o" To: Mateusz Guzik Cc: Kees Cook , "Eric W. Biederman" , syzbot , anton@tuxera.com, brauner@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-ntfs-dev@lists.sourceforge.net, syzkaller-bugs@googlegroups.com, viro@zeniv.linux.org.uk Subject: Re: [syzbot] [ntfs?] WARNING in do_open_execat Message-ID: <20230819191638.GJ3464136@mit.edu> References: <000000000000c74d44060334d476@google.com> <87o7j471v8.fsf@email.froward.int.ebiederm.org> <202308181030.0DA3FD14@keescook> <20230818191239.3cprv2wncyyy5yxj@f> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230818191239.3cprv2wncyyy5yxj@f> X-Rspamd-Queue-Id: 8152110000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: sgy6qfiaiq9bi3efduugh9599f798enw X-HE-Tag: 1692472618-826458 X-HE-Meta: U2FsdGVkX1/dNSiaxFJNgMGje3n8KD9KKbmeI2dNAOUdiC+BN3zk/CNg6FUz8KFPthUKY75Fbb5F+CNYDho/95XYthn1bwn3vlzkKeZua/bUmWaKRX1Y35xecxijUSddGzXZw/6DQjx3HjE9pHwohX+M/g3q0xZ4EhhWO8zxJzaAasZszObQ0Y7PVMw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iDR0b0kD/r39cY/rW/cgiW/SLNBrAiVvI0P6ZRxmZAWEgKLeJueCqfAWUsC5hhkPJzLPhdERJWzdvT6V2 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 Fri, Aug 18, 2023 at 09:12:39PM +0200, Mateusz Guzik wrote: > > The ntfs image used here is intentionally corrupted and the inode at > hand has a mode of 777 (as in type not specified). > > Then the type check in may_open(): > switch (inode->i_mode & S_IFMT) { > > fails to match anything. > ... > > Do other filesystems have provisions to prevent inodes like this from > getting here? Well, what ext4 does is that we do a bunch of basic validity checks in ext4_iget(), and if the inode is bad (for example the type is not specified), the following gets executed: } else { ret = -EFSCORRUPTED; ext4_error_inode(inode, function, line, 0, "iget: bogus i_mode (%o)", inode->i_mode); goto bad_inode; ... bad_inode: brelse(iloc.bh); iget_failed(inode); return ERR_PTR(ret); iget_failed() takes the inode under construction (returned by iget_locked), and marks it as a bad/"dead" inode. So subsequent attempts to do anything with the inode, including opening it, will fail at the VFS level, and you never get to the file system's open function. The ext4_error_inode() function is reponsible for logging the error, and if userspace is using fsnotify and are subscribed FS_ERROR, notifying user space that the file system is corrupted. Depending on the file system settings, we may also remount the file system read-only, or force a panic to reboot the system (so that a failover backup server can take over), or just log the message and continuing. - Ted