Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp54264lqz; Fri, 29 Mar 2024 08:20:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUksKaXocumjaAJM4SGdA7I6poAy7ZXE/mPGSh+8lnf2WmleCnUuA+FhoUG1VzLn6b6SPZiWHXRIRberOxqHwjUVwxi5K46O/SPwrDD9w== X-Google-Smtp-Source: AGHT+IEWUUTIDC+TE9GoGq3ujnS4nCbx7Th4VLkuLQZvX3OZHwpJQ5CYnH6hgqC+lyddxEzRsyBy X-Received: by 2002:a50:ab5b:0:b0:566:59a2:7a10 with SMTP id t27-20020a50ab5b000000b0056659a27a10mr2165916edc.1.1711725606937; Fri, 29 Mar 2024 08:20:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711725606; cv=pass; d=google.com; s=arc-20160816; b=tQWZGg3r6QlYCHb/W/UltSOC8JjI4989SAX9lPkZpSNjn4uC1sSlNJY8/ovQ1bcqxQ 3Ff47IOqOnBcPpprekNvWmjW7KvOCB1H1oXFcoBfWSPQqhUdb32ZlwRdJyHrZ3U6Kmil t6UYanLRiCzLfUHEjGAVfkUpvtygFbKgIpNLxfqSb04/FIs8mSAVh8HXXYhPDmNbeCXV kSbXK47TDYv/GeD13xKf0me4dSr5tZl2PyrIdJNZKoRzUNX0IwS4d6FsZzhPeJBlrQ6j RAxlSlEn/j0G8Os7i5NsYUpgrlUMOwkQ/NMZsGs6P7oBCgdJyhSI3lTSu7qaL0Fzvkjt 04bQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=j3kxR/csuodeDHffXwgWbeoQ0UBFIz87t1zEbv/ko6M=; fh=LK1OlhYbfU/tH/fP5Wr7EwTrSjiS3JKSu9bL3p5sD5M=; b=phjNojORxIDaA2J+rwQbi5NK15IYl4Cas1LH6RJOOm6Qbus1keyS/vlxawTsXYtSN5 F6/Pp35SvDowcS4EKdu6q1vXgPh8+5TCfgYXAyA1N/n2QR+sL+dqli8AkqdoNm98NL2z bLBYdpqaGBCw5WfHWLxXNZQimnj++ihPBA/FktIswje7UoodoWEZ/8ljiOkQ7RjmSjbS yFjIZP6FV/qQk05IYsD7229wGJTVj+mdMQRXGd1Bg6PgQ8YRGuwY2hFgiRUcCMUiFxXa oTlwiNiY54omsDw36hj9ngYiBckX3TryNr0JPE26VBdcmOXqPpDvQZxQrO9nn8YtczZB yWVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=qjcJgRX+; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-125108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125108-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u21-20020a50a415000000b0056c498c9905si1834805edb.102.2024.03.29.08.20.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 08:20:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=qjcJgRX+; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-125108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125108-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7DC151F2252D for ; Fri, 29 Mar 2024 15:20:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 170A713342A; Fri, 29 Mar 2024 15:05:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="qjcJgRX+" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 AAEFD48787; Fri, 29 Mar 2024 15:05:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724755; cv=none; b=mFniPnx/5rWavZxtcm+fqhUkJj/wZDQ5TIiV3Q4Llvqeams+Mcljjeobk+P4fF6zMUjk3qgpxuDzT2WhkaEn/0C2+HOGctnNLFV7wDjhcTUCw5fp50MyWofTZqxQR4piIvtdXmmbVO5USbK8LcAeDNnkmS1yN4672/QHvKcEnCw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724755; c=relaxed/simple; bh=hWTBr1HsRFSiIR+jVAkUIvH4iFAvcopyR5HkgRFO4VA=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=pX5V65g73Z7UsBMHOBGT5REbokHHeoqIiyGt7wczyrZ6HAN5CediOgEcq01GLCIsV1AR0AIeZ7UwHq1KmghsEs8fFQyoCmO91lXUeS1bwb/SbwAY+l/jW3yRRBbZnKY6ileRkzNkUel7rQIleYq5eJhpfzdo7uy9LetnXS9EogE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=qjcJgRX+; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42TF2v2P004967; Fri, 29 Mar 2024 15:05:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=j3kxR/csuodeDHffXwgWbeoQ0UBFIz87t1zEbv/ko6M=; b=qjcJgRX+neaKnzPRRWb7qoH2qZ6KoaXKFtoUW1L6Iht796BfDFNG0hfFi9sP/s2aKBBS Fbzf1ageLnyOkHC/C2ophHxj1iU1EFxDY+kWkRHqjRwlJb3DS9fN2m2vWYzUI7vpW5sC +ii3lBsg+ggzoUslOYfUQqT2Py4yDCBXaNHMhksqLNxAzRHQFbNMT8akwMnPkU3A/9Xi Cl+PHpCrRDhUb8T/HTb+LCiZ1shnQiQGtb+Lt13UsJkV/pm2JryJKKJ+7us32hQjnXg/ WWnTQwP4oWlM+3lFc4bPPChaUWRAzD/GImVuBqeaj9JcYO+BIK+fm3c2y0BpKXBsan9q uA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x5yxf809h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Mar 2024 15:05:19 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42TF5Ju5008421; Fri, 29 Mar 2024 15:05:19 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x5yxf809g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Mar 2024 15:05:19 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42TEbeMX016411; Fri, 29 Mar 2024 15:05:18 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3x29dun0ew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Mar 2024 15:05:18 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42TF5FPs25166550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Mar 2024 15:05:17 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8468E5805F; Fri, 29 Mar 2024 15:05:15 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E9A9758060; Fri, 29 Mar 2024 15:05:13 +0000 (GMT) Received: from li-5cd3c5cc-21f9-11b2-a85c-a4381f30c2f3.ibm.com (unknown [9.61.126.92]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 29 Mar 2024 15:05:13 +0000 (GMT) Message-ID: <7b8162281b355b16e8dbdb93297a9a1cfb5bb6da.camel@linux.ibm.com> Subject: Re: [PATCH 1/2] security: Handle dentries without inode in security_path_post_mknod() From: Mimi Zohar To: Roberto Sassu , dmitry.kasatkin@gmail.com, eric.snowberg@oracle.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, viro@zeniv.linux.org.uk, pc@manguebit.com, christian@brauner.io, Roberto Sassu , stable@vger.kernel.org, Steve French Date: Fri, 29 Mar 2024 11:05:13 -0400 In-Reply-To: <20240329105609.1566309-1-roberto.sassu@huaweicloud.com> References: <20240329105609.1566309-1-roberto.sassu@huaweicloud.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-23.el8_9) X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gEKmMXZ0y70WPjaV8vljt_hLgh1srMtD X-Proofpoint-ORIG-GUID: XvQ5czlv999DsIyO-nwzKjYYOrUUmD7Q Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-29_13,2024-03-28_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=831 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 spamscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403290133 On Fri, 2024-03-29 at 11:56 +0100, Roberto Sassu wrote: > From: Roberto Sassu > > Commit 08abce60d63fi ("security: Introduce path_post_mknod hook") > introduced security_path_post_mknod(), to replace the IMA-specific call to > ima_post_path_mknod(). > > For symmetry with security_path_mknod(), security_path_post_mknod() is > called after a successful mknod operation, for any file type, rather than > only for regular files at the time there was the IMA call. > > However, as reported by VFS maintainers, successful mknod operation does > not mean that the dentry always has an inode attached to it (for example, > not for FIFOs on a SAMBA mount). > > If that condition happens, the kernel crashes when > security_path_post_mknod() attempts to verify if the inode associated to > the dentry is private. > > Add an extra check to first verify if there is an inode attached to the > dentry, before checking if the inode is private. Also add the same check to > the current users of the path_post_mknod hook, ima_post_path_mknod() and > evm_post_path_mknod(). > > Finally, use the proper helper, d_backing_inode(), to retrieve the inode > from the dentry in ima_post_path_mknod(). > > Cc: stable@vger.kernel.org # 6.8.x Huh? It doesn't need to be backported. > Reported-by: Steve French > Closes: > https://lore.kernel.org/linux-kernel/CAH2r5msAVzxCUHHG8VKrMPUKQHmBpE6K9_vjhgDa1uAvwx4ppw@mail.gmail.com/ > Fixes: 08abce60d63fi ("security: Introduce path_post_mknod hook") -> 08abce60d63f > Signed-off-by: Roberto Sassu Acked-by: Mimi Zohar