Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2042363lqp; Sun, 24 Mar 2024 00:02:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOCV5Yx2nlnQ14S1HqfoFNjvTlJpjf+2c4rUcbvz3oHdpZza+jad4ACFuBSQzztAcB4A+u5S/BDGUS97zfTpl30PN8MfRiKD3ej2Z8tg== X-Google-Smtp-Source: AGHT+IH4fqJbst5N2fF4XKSluLgFt8ZG0lo3qwkaVLv4IFVvLbQpm+rLR6Sd6FoPhAqLSUKByQx5 X-Received: by 2002:a17:902:6f01:b0:1e0:25f:acfe with SMTP id w1-20020a1709026f0100b001e0025facfemr3257987plk.42.1711263769757; Sun, 24 Mar 2024 00:02:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711263769; cv=pass; d=google.com; s=arc-20160816; b=J5Ctkq4/gM2PCJr+rXmSG/aAKlt9z4bUl14sDoArCkp7aG8oYT45P0qHrrJNqDQ97w eyI2QWJi46SS7yqpgJptt4xxF9yBXaVilWSjTe6vd/sWhHdU4leQuV8mq80zkg4HwuUN C8lVDv83HMrtRCjvi5A4iMC5LcPwEc5c5DvrTYEddopHGEIWaylLlc4OuCLQbQxULMgl p6Di+1oVItlhOMMHPwBmYdfGLgaJzKFh8JN0QyPoSaHOXg6G0i9cI3d6LpIO6qBDBleo 0KBt+Yv7HpKgT19iYBS2ACt9bZpMVgrdJGYtQsDYSygSTlY9+1he8urXlgVNKXcICPnl iguw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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=O8CCWKw9gWzyR41X6fBvNpozhoGEljQYmnOirFrjEsQ=; fh=TxefPhFCNWpwnymDiccBhEJygfgSQ8wdnM/H6a6V6jk=; b=lgB2GreGLMUQrR2X/azS9kW5tCwYDYopoxPZ4JdDIKniaSbGhMZzi25fsUTSm9JLWm EKN3jODd/H3yP2OH2cP7hRa06+81aElFAzZfvATaWEjbp1yxA+O2XvqhP5QALQ3X+lin AuYuWw+LUC4EwLA7PYUyZJnHN9FWil+x0nGGWAlqyw59FlNe11Kae5m3YeM4AZcm697x zWvjoyWshyh+1QeIU9Uj351WFAaJ3bo7U54NHfSYrtEcGDeY7BbZ9mTaeCVAufvsKQx9 /mgPWEVZU5OFsgEQ1h3cq54fnvIfIy5x6KnEQfkWSh1ER0foVs1v+Mt7Z+t2VTO1GYuU AdJA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=FR1efPh+; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-112595-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112595-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p16-20020a63fe10000000b005dc833ef4e6si5115746pgh.75.2024.03.24.00.02.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 00:02:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112595-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=@linux.org.uk header.s=zeniv-20220401 header.b=FR1efPh+; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-112595-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112595-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk 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 3509D2820D3 for ; Sun, 24 Mar 2024 05:46:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2831514286; Sun, 24 Mar 2024 05:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="FR1efPh+" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 267FC1A38FF; Sun, 24 Mar 2024 05:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711259205; cv=none; b=buCWaf0BXw7U5AEP8/RuSH66g4MUKlJEfpX0kSB6lZnu375QFnE7pXLrmaCY5CSLUlirMGP/sXSrMKaHcu0tuq6+kS1mt8qwaZdbMldAdRHTneYy3zqzijSSi06i9Q621FtCS3jInSGVqIOzWQrNb8hUQeUULmDPgaVGXNAZtDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711259205; c=relaxed/simple; bh=ZdMk2+QQU6WaQaTZwwrBGsmbnw7raeC1F7UhsPN3KUQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=I3fpTJEIX4LBZaMRLQDI2Z2qcFwJA7cp59g/yTA3M/VhrkUSTQLOSiErV+DVMGS13BSDrUCOBoFW7bwgVO033iEfXiWehmcaJhsceJQrayvym0pcmPSSM4Xqy2qoNfFdQfgU2d8nKgYkETsW59RWwF0exPw4ERtsZ4gBBQCw51Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=FR1efPh+; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=O8CCWKw9gWzyR41X6fBvNpozhoGEljQYmnOirFrjEsQ=; b=FR1efPh+v2DmePoy0goXs9XQI7 8/BNKVhBbYAnStkIPwQcGtPi9npwvkqkXEcsJ+amOp0iFTcwZ+HZjEhNreE8CxcU9Yz9OCLORp8sn LgiT7wwpw9ultvHUIWAIbvHPOMB53L5PjK2lNZz7dZUNA32F6vfb5Muq1fvVJvHKyM5iJvXra5TD7 9igi9CRPD7l01+9/A7KK8dCYHYn2HhGPMayig6f4M8Wpr2n0pIFnd6xgw2k0vtKOQdf/QKtODkvat BddQMcrAxcOnb73mvP2F03P/PETJCmJ2XcCjeDzfDTqa1qVHWLDJRZSeaPn2x5bDU4AzWsJ7CEROc 6gK0EnKw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1roGgm-00Fd0I-38; Sun, 24 Mar 2024 05:46:37 +0000 Date: Sun, 24 Mar 2024 05:46:36 +0000 From: Al Viro To: Steve French Cc: LKML , linux-fsdevel , Roberto Sassu , CIFS , Paulo Alcantara , Christian Brauner Subject: Re: kernel crash in mknod Message-ID: <20240324054636.GT538574@ZenIV> References: 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: Sender: Al Viro On Sun, Mar 24, 2024 at 12:00:15AM -0500, Steve French wrote: > Anyone else seeing this kernel crash in do_mknodat (I see it with a > simple "mkfifo" on smb3 mount). I started seeing this in 6.9-rc (did > not see it in 6.8). I did not see it with the 3/12/23 mainline > (early in the 6.9-rc merge Window) but I do see it in the 3/22 build > so it looks like the regression was introduced by: FWIW, successful ->mknod() is allowed to return 0 and unhash dentry, rather than bothering with lookups. So commit in question is bogus - lack of error does *NOT* mean that you have struct inode existing, let alone attached to dentry. That kind of behaviour used to be common for network filesystems more than just for ->mknod(), the theory being "if somebody wants to look at it, they can bloody well pay the cost of lookup after dcache miss". Said that, the language in D/f/vfs.rst is vague as hell and is very easy to misread in direction of "you must instantiate". Thankfully, there's no counterpart with mkdir - *there* it's not just possible, it's inevitable in some cases for e.g. nfs. What the hell is that hook doing in non-S_IFREG cases, anyway? Move it up and be done with it... diff --git a/fs/namei.c b/fs/namei.c index ceb9ddf8dfdd..821fe0e3f171 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4050,6 +4050,8 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode, case 0: case S_IFREG: error = vfs_create(idmap, path.dentry->d_inode, dentry, mode, true); + if (!error) + error = security_path_post_mknod(idmap, dentry); break; case S_IFCHR: case S_IFBLK: error = vfs_mknod(idmap, path.dentry->d_inode, @@ -4061,10 +4063,6 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode, break; } - if (error) - goto out2; - - security_path_post_mknod(idmap, dentry); out2: done_path_create(&path, dentry); if (retry_estale(error, lookup_flags)) {