From mboxrd@z Thu Jan 1 00:00:00 1970 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 DBA3E1F5857; Wed, 6 Nov 2024 12:57:21 +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=1730897841; cv=none; b=qgtRxxq1v2GYYSDwYPJYCDvtqpbgu9Y1pc0kTS4vD78nQ6/F75DKSqOzKYnP0KLGhP2fKOvlalNJ1R/fFQidWnd1mvlyahbIIOORAY90VVAkdvKDzTa6n6NpSVQR8u0GuPCIvV7GRU4HWUHwnn6bXDlxCsaJCBvF+NFd9uEERYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730897841; c=relaxed/simple; bh=5Hiz9Kp6CaV0akCQvgq0VVi36foHCY2A/IjG4YogGg0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e/B4TUh1IPdwFhgW1AhFPypWuNZBAFn2FyC4uD4Xy5MJiSZfxVMaxolOr8sHplvH3g5fXKHFwLnyOXSZTg0V9hwQHdrSxb59SU0nLT1+DmR/cv5lwUymL5h+FnZi9EM9XKB5z87ZWJPsdgLhlk3zWVi3ZsGWOuJIGo0yBwLmQqI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tEAuGQVX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="tEAuGQVX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FB2FC4CECD; Wed, 6 Nov 2024 12:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730897841; bh=5Hiz9Kp6CaV0akCQvgq0VVi36foHCY2A/IjG4YogGg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tEAuGQVXC53a4dFTc2XTRTYO52RZorROmAafOJPebAQxotswLqWqzGLfIUeWr8mc+ 3w6FFraVKRUmDdaYyUZj/MkpjrnIJNzrDyUtSsRJrb0QaKkJM5dxVIsbKd8kHK57tJ DmEK8Hm6LGlc0hutldDo/LttDbXztlnQizLxrqmI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Olaf Hering , Christian Brauner , Sasha Levin Subject: [PATCH 5.4 038/462] mount: handle OOM on mnt_warn_timestamp_expiry Date: Wed, 6 Nov 2024 12:58:51 +0100 Message-ID: <20241106120332.463095233@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120331.497003148@linuxfoundation.org> References: <20241106120331.497003148@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Olaf Hering [ Upstream commit 4bcda1eaf184e308f07f9c61d3a535f9ce477ce8 ] If no page could be allocated, an error pointer was used as format string in pr_warn. Rearrange the code to return early in case of OOM. Also add a check for the return value of d_path. Fixes: f8b92ba67c5d ("mount: Add mount warning for impending timestamp expiry") Signed-off-by: Olaf Hering Link: https://lore.kernel.org/r/20240730085856.32385-1-olaf@aepfle.de [brauner: rewrite commit and commit message] Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/namespace.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index f1c0e0a705621..281f08eaba5b9 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2494,8 +2494,15 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * if (!__mnt_is_readonly(mnt) && (!(sb->s_iflags & SB_I_TS_EXPIRY_WARNED)) && (ktime_get_real_seconds() + TIME_UPTIME_SEC_MAX > sb->s_time_max)) { - char *buf = (char *)__get_free_page(GFP_KERNEL); - char *mntpath = buf ? d_path(mountpoint, buf, PAGE_SIZE) : ERR_PTR(-ENOMEM); + char *buf, *mntpath; + + buf = (char *)__get_free_page(GFP_KERNEL); + if (buf) + mntpath = d_path(mountpoint, buf, PAGE_SIZE); + else + mntpath = ERR_PTR(-ENOMEM); + if (IS_ERR(mntpath)) + mntpath = "(unknown)"; pr_warn("%s filesystem being %s at %s supports timestamps until %ptTd (0x%llx)\n", sb->s_type->name, @@ -2503,8 +2510,9 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * mntpath, &sb->s_time_max, (unsigned long long)sb->s_time_max); - free_page((unsigned long)buf); sb->s_iflags |= SB_I_TS_EXPIRY_WARNED; + if (buf) + free_page((unsigned long)buf); } } -- 2.43.0