Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2849489lqp; Mon, 25 Mar 2024 10:58:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUw+CQtPiE2m7fUc+lky5Np3PVsTV/ih7EpcWa8wczGY85qD7DYvcc4zIgN5xgIKCMXbYJGF5px+NCJbs2K6J5tTw2c/s/c7iaEGtm0jA== X-Google-Smtp-Source: AGHT+IFDOAEXPJYWk8CMA3FZVeIF43x2+25slyTl1UCaCkPMd7SgqJdXfpVah1GZRfoyxLYigvet X-Received: by 2002:a9d:4d13:0:b0:6e6:e41a:2a21 with SMTP id n19-20020a9d4d13000000b006e6e41a2a21mr596556otf.28.1711389486900; Mon, 25 Mar 2024 10:58:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711389486; cv=pass; d=google.com; s=arc-20160816; b=j9ib1uzHooIThhnILrwwoBL2/gXDi48jblii8U8+tp6oxpdFMyAMUam6QanQQGodX5 PhKLNCxojbEtvSK2Q5VweiL5RT52kVemVb1+6ZWx3YaxEkhTRTanzITjylFoC8UuDCix dHtzqHrKwa1JlIn2bKplF3wOY9yPn8Yt0VGLnwJpiFOeLE4beBT4oBEGECIgAA0858l4 8QTzXoCPUQwNeiT8dMCzHctFsELEsPbBtjtwfYtrzxILsTurdEzuy7yliZXq2GsMOOB6 YSJVOrGYL7wm8FcWe/TTSGxwfTOzfFxiZAdLZgK9gMGGmdD6dsoY6MZ9eM25tFnE2cx+ XoGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=VLQn9MYedg2dmO1Rz4dYvveAYrX8Cm/Wfbouj1emns4=; fh=+EXWyMhFOl6SEfhhJc/Q4dKXKaMdkZ5QkCZFZQAPu0E=; b=MfXKNTaCnv3nwZR7w3LjbZhptZ/ZwzyxqDxu8tiHok7Lp93QIaIPa+ayI8eZLh1biw xv7lcB2eq5oIGDYLeh2/aX1hChQio4SU7kZM6/mJvLaALuRtyHwDD1tMgAc5ilm+dfBB JzG6mPLbkhsUxOOI4E/2IuW/k+RIAItFkkmA2NRZtwOYQ2kc0SfK50UN6FrIMgKuXyQW aVOhS81j2pUu0TKi+L1tKWIEmeRQq+UP7MbL1wgaqve36XuaWzdrLmwLoX1m1RLx3MO/ otQaCn9uo+IQZDQlFavttOen5KbDdYE/6wL2xrImXMdiaqG4WNAUaoUo/Vbw6y+6q3zP U+3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=W+DFhOgI; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-117535-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u30-20020a63235e000000b005dc9564a0afsi7906753pgm.317.2024.03.25.10.58.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117535-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=@paul-moore.com header.s=google header.b=W+DFhOgI; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-117535-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com 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 96D132C4133 for ; Mon, 25 Mar 2024 17:50:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 194CC82897; Mon, 25 Mar 2024 17:05:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="W+DFhOgI" Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DE8982860 for ; Mon, 25 Mar 2024 17:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711386327; cv=none; b=K+Kwsnp1tVSR3RITbmQizR/bgmJLQNkttKkMw4soG418OBLRVmnMmb5p4fh6xafITqU3wctFsPg+pGk6/Cf6AcKLSLeP2ML8FoxgPjf/0lud9I7n9mmSTZWjt/UKYZIoGqR4BOfdM6SLib7IriuryrEGsI8HCMc1vf3gnX5J/20= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711386327; c=relaxed/simple; bh=nlSSMt5mXwqBGalL5blRWfMGpq6ZzxT1oNeGbmu1GWs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Hsuvpg9YJq8xOhzddNEm4rQV6DQvELHVQtKUhJOvH6lpctxa1BUjs1UogzhCEOxOaonxCCrfFmG0XVwnmZE0bxWQtuVkNL2oWZoC4ymvRoEDKFgatIsoibtN20LADsYVy8L9W0LYneS8sf3f5RuASrQn98r7Os8dNdIbssb8eT4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=W+DFhOgI; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-609ff069a40so51822627b3.1 for ; Mon, 25 Mar 2024 10:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1711386323; x=1711991123; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VLQn9MYedg2dmO1Rz4dYvveAYrX8Cm/Wfbouj1emns4=; b=W+DFhOgIFhgU0e5uvjoYSBKYPE8a+2gSbUGFb1I6IaMqC6VylewY6tGi2YOx0gxHRu SDX0cr5OLHAVhzjabpfbmac+aJHZms1LJErfHo0J8Ne+tpYHIyCXOMOmY+aM7u9RxlUI I9ZJJgBR5risV2OZmko9gcSKq4r3H3cWk6ZWO4pW9vJByT/m2iumfBET3QuqaFm5xhN9 NmfHp7aAorYKPQjlf7TdbKfsqpa+qCfY+fo4eLTbIUn9pA5dU+25vkyKLCTWTlOY0Qe2 +2g0W9sVaBHdDyTqm8aI4UgSRDh+Qo4DFB0IguHkwfuBuSOuOSRh9VHsjCRaPUmJSJpj IaUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711386323; x=1711991123; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VLQn9MYedg2dmO1Rz4dYvveAYrX8Cm/Wfbouj1emns4=; b=Ut2JoRrdo5SLhvaqBqHtTpfA4bSivhyCXDaoyTD3nSSkMY4cNFCBdPRedWQhTdeIOl eYFb/juTwGIXXz74ozSK2dC8yVJM2nWkzPvNI7/NvRs6ioeR7AFCbAoIPec5nsQGIhan OtJCFUznXy47SjFZhTkRjw1AvbK8FHu2dbY/6UDJ6TonWAd9lvcjoifCdn3d5jol0Tyn DqpVquG9wRMTsjZnF6/KP34s0s/e92TbqMyntfdB8iMK41uH+HuuqNfABUSFy0zlR7oi FCSYZ89IP3mc6HhesGQKv5ppVS6Q5ZYblbbyQg+HVvj5a0o73txLKmq0ApN3X/2Tgj6I JZZw== X-Forwarded-Encrypted: i=1; AJvYcCWZ1afJ2UzmGj3jVUMvbdq+KSY+qOtr7O/QLwxVLFEBmOiMisqcDas8qtgfg871VOrsNrjcvNz6/5r6Y1OAUj0CIsDWzqcRf+YTrnHo X-Gm-Message-State: AOJu0Yw/7hWy/J/SKMGu1jhraSAgmRUOXRbYmfsJxrehzq4b5TBvV7Re rESEdxuRXSX5FBbURvyyx8FbpMFqC/OMY08EprhJCvUHoGOHIIMlMGF9PzQvNZv95SoqRQRZCWQ urCaXR/PLQGgCRZHgcFg8EdiGmOE6CN31omYTtGK6OSgxR7k= X-Received: by 2002:a0d:f8c2:0:b0:610:1a19:14fa with SMTP id i185-20020a0df8c2000000b006101a1914famr5840753ywf.50.1711386323040; Mon, 25 Mar 2024 10:05:23 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240324054636.GT538574@ZenIV> <3441a4a1140944f5b418b70f557bca72@huawei.com> In-Reply-To: <3441a4a1140944f5b418b70f557bca72@huawei.com> From: Paul Moore Date: Mon, 25 Mar 2024 13:05:12 -0400 Message-ID: Subject: Re: kernel crash in mknod To: Roberto Sassu Cc: Al Viro , Steve French , LKML , linux-fsdevel , CIFS , Paulo Alcantara , Christian Brauner , Mimi Zohar , "linux-integrity@vger.kernel.org" , "linux-security-module@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Mar 24, 2024 at 12:50=E2=80=AFPM Roberto Sassu wrote: > > From: Al Viro [mailto:viro@ftp.linux.org.uk] On Behalf Of Al Viro > > Sent: Sunday, March 24, 2024 6:47 AM > > 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 eas= y > > 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... > > Hi Al > > thanks for the patch. Indeed, it was like that before, when instead of > an LSM hook there was an IMA call. > > However, I thought, since we were promoting it as an LSM hook, > we should be as generic possible, and support more usages than > what was needed for IMA. > > > 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 *n= ame, umode_t mode, > > case 0: case S_IFREG: > > error =3D vfs_create(idmap, path.dentry->d_inode, > > dentry, mode, true); > > + if (!error) > > + error =3D security_path_post_mknod(idmap,= dentry); > > Minor issue, security_path_post_mknod() does not return an error. > > Also, please update the description of security_path_post_mknod() to say > that it is not going to be called for non-regular files. > > Hopefully, Paul also agrees with this change. > > Other than that, please add my: > > Reviewed-by: Roberto Sassu No objections here for obvious reasons. Acked-by: Paul Moore --=20 paul-moore.com