Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp177830lqh; Thu, 30 May 2024 19:21:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvbx+/nGnKIRO864tLGWL6sxuHX93PG+o1wVLWVQA7IiN6/8eDulMYpPpDCKWbLUpzcDMIw1bCznkVpdJmpGJW86v8yFvGxfc1mVVEmA== X-Google-Smtp-Source: AGHT+IG/xyQZ8XIxSKTjuzxl5QDVSVDPt87Utlp+gt/hwpDpaBjhz/CBXdkSCYdluV6ny/DLl21Y X-Received: by 2002:a05:6a00:2d08:b0:6f8:b1dc:d99d with SMTP id d2e1a72fcca58-702478da666mr670408b3a.28.1717122116476; Thu, 30 May 2024 19:21:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717122116; cv=pass; d=google.com; s=arc-20160816; b=Xu5BGGRTK1zov4dpc+HhoHCBHAbcbS9A0rmdJpu6yaJysofK+xlcmvW84yPvX120qY IUJBB9Jx4lrqf6ODtBeY2IH0ZKIqzfgYnl57Hb294VpiSRfwOKoQtM0biyrXTbztBwul ECGgVkg/tEP4U9EwsIbFAa11I58Ot5lbWRvaE7+Hd94QUcJf5sA+ym1QUWhQxo/LIzbW CJvhyuR9zJCU0BO8W8ygqdh2ebNYgu99gG+soTbFmO3MfIXYDz5uEoE9za/l2yckObeK 2QYrg2JaoQB13AhuSyhUsEce7FI9AlKwDrXR1afj7F0DN6U1xgy99fwtc7DUTfaPai/w n/SA== 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=zCmlCLCMi93r+3LQ1BrPVaQa9Vd7DTUNEMrVT9OvJrs=; fh=UpzdeISAoc5ZlLT/saC6CzbpQ5fsPNwsa4VDSGSDvao=; b=YSNFP9CHuYkD0C/pu4KdgUWhHCvTeKVzERTBzGrX1lSkLb8mmbgYGqtKflCs0tu+PA BWho8Huh/AbYMPNE5+HFNT/43JulbQreYSgqNuIWHdsCvBoxIva63gB++dDzF1F5Al3J KMSHIyrRTj1muICI5VpBta8FG3KXU1Db6Xstvv+TfFNQ5cfJPOL+ISzH/1ztSVuSsZyz VWm/vWlYhUiyEh8ZHGGqHrPNF85weoScA3fhHq3JAri6XKECdD5UOccGXUlS5AgwENCX TBTFuEoC4kzHTnqytfljx1wLWS6EOFIlI6nS3o964POcNqmHUCR1Tcwr80LNs9MCWts4 0QBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AYC6kPFD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196184-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196184-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-7024a730a0asi125900b3a.209.2024.05.30.19.21.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 19:21:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196184-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AYC6kPFD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196184-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196184-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 96BE0285AE1 for ; Fri, 31 May 2024 02:21:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DED2178286; Fri, 31 May 2024 02:20:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AYC6kPFD" 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 0852A4C6D; Fri, 31 May 2024 02:20:52 +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=1717122053; cv=none; b=qJN6LtxxE6xEde2u3fWcV4o+nC+y1UwXWReNiYSrJWfbh5C/if6yhVSk6f5qq1jmyeOe/gGLBlIF8ZOTXAndpgojI0tbcd0gxghHGow6srpyJT5M7Ndr9ncvSaaS1/6xwVuVYJR1bi9x33pClGOJd2EwYJ0INAxdIAxqbkN6Hzc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717122053; c=relaxed/simple; bh=b5G/xzCKKv13+PNvSDpcSoc6cOLXomTBBZTbM3WNl+Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BMzdU36xnguHz19KBSNUPL6f/7K0BugDCo/a57c27SOqc2ykg2dpQGfXjUKPMXC7OSUtBodwS5xf2CyMC6a7ZY5V0vRu+cSDCO6LLOvfPVQgioHW+/I9p75Fudj3gzUO8PlWqAcqCQwTQ38EkylQZLCLWY7LKbMweq1YrR/IMTU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AYC6kPFD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 028B2C2BBFC; Fri, 31 May 2024 02:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717122052; bh=b5G/xzCKKv13+PNvSDpcSoc6cOLXomTBBZTbM3WNl+Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AYC6kPFDmbrWlFSPd9ew7nngeX7vNnr7ubo6m9b2OyqpSVvNr9Q8uOXF8czbmW329 hAMZAcC4V57o7n/GKhiLNhD6YeGftel6CgNbC9WQctIo0hrmBGfQuHjIWWzmsAmlvb JnaxB7ChCJyWD8KJo6Wn7BnKMdiBznYh4hKn6gjWpyU7R9JYYwYQA3a6N4VRSZT268 wDAWVRGuUaqLVlfNCd9QEI/q0r/+8/3Xf23cYFxgVBkAxZUCUe/yue9txfFzQ/fr4K hVFb4of589BAsJUL6hVkvmusxUoILUcdQYNjKrsziUWjldRgk0RMdSIjwVc3hG1bhe U+MvwDYRDWjYg== Date: Thu, 30 May 2024 19:20:50 -0700 From: Eric Biggers To: Lizhi Xu Cc: 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, syzbot+340581ba9dceb7e06fb3@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, tytso@mit.edu Subject: Re: [PATCH] ext4: add casefolded file check Message-ID: <20240531022050.GB1502@sol.localdomain> References: <20240531010513.GA9629@sol.localdomain> <20240531014747.1386219-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: <20240531014747.1386219-1-lizhi.xu@windriver.com> On Fri, May 31, 2024 at 09:47:47AM +0800, 'Lizhi Xu' via syzkaller-bugs wrote: > On Thu, 30 May 2024 18:05:13 -0700, Eric Biggers 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. > I have confirmed that there is no casefolded feature when creating the directory. > I agree with your statement that it should be checked for casefold features when > mounting or reading from disk. > I haven't looked at the syzbot reproducer, but I'm guessing that the DX_HASH_SIPHASH is coming from s_def_hash_version in the filesystem superblock. It's not valid to have DX_HASH_SIPHASH there, and it probably would make more sense to validate that at mount time. - Eric