Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp115640rdb; Wed, 17 Jan 2024 20:06:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFG7GN8OwHBir0DSBBHXv69x3hDKUl6vHgDpfldMmlBjPR4q/UGfyGb/SpiMhb/048+T7jN X-Received: by 2002:a17:902:76c5:b0:1d5:664d:3c87 with SMTP id j5-20020a17090276c500b001d5664d3c87mr274783plt.28.1705550767194; Wed, 17 Jan 2024 20:06:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705550767; cv=pass; d=google.com; s=arc-20160816; b=HJOB0Nu5JWCSQk/N08/q5utv0qHsaEYxSBKQRTPZTFIStKKCa11iP0nz/fEsUj2VqM YVF11+zzWVfl2dTggENTrPim5yIHN5OxoDUQ6DLgJNiaGw7SoluM6Zmu/D+EAaWjQzwx qrGz4uOptE0ucs8gmzGHfPLjKJtI35hnGLMgPg9of9B/8ailq9Bpq0Yu9JwDAPLF3ppc w60Q2D+3z25dsm7yNRCAciFBkyCenmOKFX29YO/CqUXlmSj9ZJdtcgwYep0orrtrDb/M 47uxBnJbIvL5rXDzksWWCeyfE6/Dlyf0uOsZ3MaMDAVrGsbi2YM+jtKbdQfBS8KR/ymC qchw== 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=w13llrR137QJAbt1+mR8vqmqXqRNx+wxIFH7k4GCagI=; fh=552l2Xn3DCvm+UqkYDgHUUYVNNy+DqcTY2w//rg+oA0=; b=G/CkPOrBo5D/KbjmER2hPF6lLik7UCO+Rvnq4GBdRwb6TICVj4tIhu9JbCxT/zqzW0 W55XFZNmueIYfTmek8TJRtQsH2RDa3y1xfBaRiA6xEvXxA9LKGTh0YEF1R9eOwKSXHnE 6iYOLe4VV2IgkhGRRrAOObgXDpjGoZWiQt6Rmg/JNGTvqXV6watC2XFI5SzoKNI5uGer Y9rX942gpWRQK03xeYuRnQf1uOLvQIBgGN5raFRjZsSqVt57XMIZKkf+exF2Fx5EiKhy lwasktd7JA8mxHH6YiaHdW0uv435Jo/JEzW4RnSM9VQ7HAGCPRj4rgjY3pEi84o3VU2m SH7A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=oEsrkKcs; 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-29629-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29629-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 iz15-20020a170902ef8f00b001d42ee2a4f0si726906plb.424.2024.01.17.20.06.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 20:06:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29629-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=oEsrkKcs; 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-29629-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29629-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 31EF228593F for ; Thu, 18 Jan 2024 01:39:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 105BF2573; Thu, 18 Jan 2024 01:39:20 +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="oEsrkKcs" 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 7AB5E184C; Thu, 18 Jan 2024 01:39:16 +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=1705541959; cv=none; b=rp86psSrye/WIG64iYIghBX2RvQh5aYgEGUUxZyHKtoe83C8tKbgcYe8hs8dwZqs6WsWfH2KetbXTRgA8n0NgUcQVikkhs8ObkFr0AQ2mtZYxvCpiHf/h/GGF9rMy6rBncwYbB9wz/pTaIPKvs0yW/6oyMZB6eE9c2eI2ygDYRg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705541959; c=relaxed/simple; bh=fhsIDzla0e62/HjWeLJvNtsOnBaIafn/n/Ktvt7/xwg=; h=DKIM-Signature:Received:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:Sender; b=DBnlhZ3iwteXQhVbXlcTRtX5V58Bw09O87Yapkpfebk/LghWxt0gkHxt77C5DImbH1JuKiPMB8Usaq7OS5Qx4DYhSsDEK6ffcXGup9tpkqlgedEDhj59/TtQzx9tDShdM6o59szwkoWipms8Yq3V4kzZLeCuWIjV8TR2QxTRyDg= 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=oEsrkKcs; 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=w13llrR137QJAbt1+mR8vqmqXqRNx+wxIFH7k4GCagI=; b=oEsrkKcsfc9527LZXvFsOgbVc+ qgbY5hmf3S19u2tybAPsbbS8x9aZ1O/G2cYeBtMkZnH7NwD3qHNVfdOBVZwQQQ7bQkoEW6/pBJ5/x x02BhWXyjamDfUZe9u7tAfcM+2dAjqkPVcDflmm4LRShv41d94aLq3BUxbuEg0MByGmp/a5gG0SiE oIrdKJdMzTOubP1Ikd5ltd89GqFB/JdQMzOfm7Dn7ZtxHZbvxxXplWyJ6oJ6oqr4S2pYU513Vlr+P FntGEluXLPNaomz0N+DMs9OvPsAA1e+XulU0pQZl+K33D1E75vNzUDEzeswRbgRDArKwQcRi69t3H 13Fs2i5Q==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rQHMv-006xCv-19; Thu, 18 Jan 2024 01:38:57 +0000 Date: Thu, 18 Jan 2024 01:38:57 +0000 From: Al Viro To: Baolin Wang Cc: akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org, jack@suse.cz, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs: improve dump_mapping() robustness Message-ID: <20240118013857.GO1674809@ZenIV> References: <937ab1f87328516821d39be672b6bc18861d9d3e.1705391420.git.baolin.wang@linux.alibaba.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: <937ab1f87328516821d39be672b6bc18861d9d3e.1705391420.git.baolin.wang@linux.alibaba.com> Sender: Al Viro On Tue, Jan 16, 2024 at 03:53:35PM +0800, Baolin Wang wrote: > With checking the 'dentry.parent' and 'dentry.d_name.name' used by > dentry_name(), I can see dump_mapping() will output the invalid dentry > instead of crashing the system when this issue is reproduced again. > dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias); > - if (get_kernel_nofault(dentry, dentry_ptr)) { > + if (get_kernel_nofault(dentry, dentry_ptr) || > + !dentry.d_parent || !dentry.d_name.name) { > pr_warn("aops:%ps ino:%lx invalid dentry:%px\n", > a_ops, ino, dentry_ptr); > return; That's nowhere near enough. Your ->d_name.name can bloody well be pointing to an external name that gets freed right under you. Legitimately so. Think what happens if dentry has a long name (longer than would fit into the embedded array) and gets renamed name just after you copy it into a local variable. Old name will get freed. Yes, freeing is RCU-delayed, but I don't see anything that would prevent your thread losing CPU and not getting it back until after the sucker's been freed.