Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp153399lqh; Thu, 30 May 2024 18:05:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/DCjSVNn2f9iaDRBoWuv3ElDq6okTwnHosQmj8megapZrxF50spSgwg52sBBw8tSOXiJeargOMeKhShSNYkAehQFId44SZTKI3lOmEQ== X-Google-Smtp-Source: AGHT+IGXV5uzAWQQiJyjsW9Hb5r7DeRh+iDk6U9vmckEjoRuyVf9G0smxj0EA/F8ICxFpuYtJc6t X-Received: by 2002:a05:620a:664:b0:792:c524:c67a with SMTP id af79cd13be357-794f5c66574mr36369285a.2.1717117542913; Thu, 30 May 2024 18:05:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717117542; cv=pass; d=google.com; s=arc-20160816; b=fS1wACCPck1yyowvkPUi80hcaZFXkLhWSTooaPObP0JvGLgonC9d66x3KTiGU/yWbS 0Of5RtE/HkQul27Bftfecg98m5TEHTfF+GdpvqncMv2R9IHhd6NYS85VcF/9qW9UchPA TBiNv90D9nxkjEs4ytzq7+KYVctvsh8SCn3iVD3oiDKLoawUfw03KuAoxCjDvSV2bpEj 91St+caFxDJ2l4dEcYTdxnpgBF3TAEzKaiwgRmmG6645jJGutr0ykshmpJJXmpH4CwTm BxuR+oP86AbxWO9n5UYNI6Z3jNIxSjMsKZCE/DUHPjnKGWFH0d6mD3KfkFNdJQJRKJHz iCDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=HKEpgE3zzSzVM4Y4XUWAIhJ8F5JcqtjpTfk/ZjuFj+Q=; fh=LOysTWKH3fw358Cdt6/ZVlBAa0Z9iKncNBYsHmKhUVQ=; b=gNn9xjymGEdGLaF/FnIV/QsqqrZzNscLv9DrBQJ2Ck7wQBuzWX/IBRsklaxMLwu2WH loT1jOcsaMkSv4VeKNz5vMk2tVtkkpR3pVubi4jaP1nkm+u0/cy1713aQPN0zV+temGR 8j8DciSSK9CezZnKyZ5/HX3GFL99u/mflPiHFdOi0VOhYM8a1yUTUYJ2plNBIu3GNC6b ZBtzkWWXIZy5vKr4/bBsdjD/gD1B9H9Ey9/wW3Y3Hav0KM1m3eobuYfBPLJtc4qAFxUO +zOiWtf3xH4YJ6zo79+RcLSlrs7qE20kSFH4t0iMgaWbxyKplrDspXiQl+a6iFpmE5cX kbhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P6UDd489; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794f317f5basi84197685a.445.2024.05.30.18.05.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 18:05:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P6UDd489; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9F4741C2435A for ; Fri, 31 May 2024 01:05:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC59517545; Fri, 31 May 2024 01:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P6UDd489" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19D6EEAE7; Fri, 31 May 2024 01:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717117516; cv=none; b=ONVVox5SsVP/Mm3kRBEq+H3OROQOT8KaCY7ciukGi76H0ERpSmeh8UHvnPgc/yeK+2KlfbJGI/Hlnvj8KtdWIe6iTH+JO24quOEAseiu5VH8VYVFSW93Qz06RX/2oYrUVQoP9EDYjWzex0SVQ8d2kEcI3pbPcWJSCNwKV5e0ijA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717117516; c=relaxed/simple; bh=lPLWeAPfBQ6oxpEs16VAr4Cg6Rl9aRzpSeyPTv3ueiA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jtml2AVyHk0ISehnOw9dmwgw2ogy4kz6h48q8b/gAtl/E4z9US0tbzXCS/0D6sFFnMasQInaatwtpuxUFEoeNg2cCOpSk6upOe4+Oyq693xfozEWZ970cziHZvntXMwcRaRY3bIS8sQRaqvg0ZB45Lm+oL2RQCgukN1UcF4fSW0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P6UDd489; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CA03C4AF09; Fri, 31 May 2024 01:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717117515; bh=lPLWeAPfBQ6oxpEs16VAr4Cg6Rl9aRzpSeyPTv3ueiA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=P6UDd489pzVxW7MTo4FlgeeEiIjBKfuMvB5tC0smqSZyq8AucFhhj5Gl+H2Y8DD+w WEgjlurXYQAfk8QTT+Aknoiad8cORfCXSKTPHXSvJWkqIb4AAqllLGXTmT7zs/p2JB lBOUEv7y1oeAxgb8smS27Fl0Cwx/y9OP346waPsIyakOfNUTn3bPVG4glOEoUS7J8c OxeUwK06EZKZuXUJrLG9iENe/t+MJC3mQd8NfjMUMcr0SNfxFLM5aFetDZlS78Ads0 PN7D9tF73Ac6UMSPTGzPOEZWYrGcV3l39Is8MYyY+Y2PADm/PZuQzIclm1Tt8kj+PT qlUZEUn0yzpJA== Date: Thu, 30 May 2024 18:05:13 -0700 From: Eric Biggers To: Lizhi Xu Cc: syzbot+340581ba9dceb7e06fb3@syzkaller.appspotmail.com, coreteam@netfilter.org, davem@davemloft.net, fw@strlen.de, jaegeuk@kernel.org, kadlec@netfilter.org, kuba@kernel.org, linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, pablo@netfilter.org, syzkaller-bugs@googlegroups.com, tytso@mit.edu Subject: Re: [PATCH] ext4: add casefolded file check Message-ID: <20240531010513.GA9629@sol.localdomain> References: <000000000000cb987006199dc574@google.com> <20240530074150.4192102-1-lizhi.xu@windriver.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240530074150.4192102-1-lizhi.xu@windriver.com> On Thu, May 30, 2024 at 03:41:50PM +0800, 'Lizhi Xu' via syzkaller-bugs wrote: > The file name that needs to calculate the siphash must have both flags casefolded > and dir at the same time, so before calculating it, confirm that the flag meets > the conditions. > > Reported-by: syzbot+340581ba9dceb7e06fb3@syzkaller.appspotmail.com > Signed-off-by: Lizhi Xu > --- > fs/ext4/hash.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/fs/ext4/hash.c b/fs/ext4/hash.c > index deabe29da7fb..c8840cfc01dd 100644 > --- a/fs/ext4/hash.c > +++ b/fs/ext4/hash.c > @@ -265,6 +265,10 @@ static int __ext4fs_dirhash(const struct inode *dir, const char *name, int len, > __u64 combined_hash; > > if (fscrypt_has_encryption_key(dir)) { > + if (!IS_CASEFOLDED(dir)) { > + ext4_warning_inode(dir, "Siphash requires Casefolded file"); > + return -2; > + } > combined_hash = fscrypt_fname_siphash(dir, &qname); > } else { > ext4_warning_inode(dir, "Siphash requires key"); First, this needs to be sent to the ext4 mailing list (and not to irrelevant mailing lists such as netdev). Please use ./scripts/get_maintainer.pl, as is recommended by Documentation/process/submitting-patches.rst. Second, ext4 already checks for the directory being casefolded before allowing siphash. This is done by dx_probe(). Evidently syzbot found some way around that, so what needs to be done is figure out why that happened and what is the best fix to prevent it. This is not necessarily the patch you've proposed, as the real issue might actually be a missing check at some earlier time like when reading the inode from disk or when mounting the filesystem. - Eric