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 33D2C1C07C2; Tue, 15 Oct 2024 12:57:58 +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=1728997079; cv=none; b=GB1zylzlRX9ACB8MLnpuXuUTBDLvgeviGLcFu2kQekdginXZzpPqi3WB16hfiKPuj+JVky6yyT6raacMT7BfiIGz0/XaCZINEepmYttcfi3uin/ve0yh01ABP5T5dFOHE6xLDpeGVadeOlpVwl4w7qqL1sOK4jQo/0uCvKLcsOI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728997079; c=relaxed/simple; bh=vlrwI6H9Tg2Wn2d2hTY5lA4c+Z44GRpnrW0ObUqNiFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uMlylW3TGBkuGRz8WBN7wbaY2vGs148hzuE+p/26wOfk1+tflpuyE2s1DtIn0MXIPdIGVQs2JE1McAK3y/DkbMJ6kn6H7WVTQVzlxfeTj4/gjGuX/SR+wUtVCYZlaspIZVCb918d8MIdla+bknsiV1NFoNE5Ar+JToIno8ykVBA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jgU+JYij; 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="jgU+JYij" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38E1CC4CEC6; Tue, 15 Oct 2024 12:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728997078; bh=vlrwI6H9Tg2Wn2d2hTY5lA4c+Z44GRpnrW0ObUqNiFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgU+JYijyt3KnRJzIqTkZym/pm7jdKTufvXCgsCXjJ0sGTyKicGNKVha8JOqeIt6c uBfzAwsYsGeCGZmoYlCUz6zbqnT1aZheNekwucEK3QEv6pmKarf/UKTLCHWtxH1d9I 1QXCBGaHkBKW3/ZY/NO8iOSx0nYS/Bz8+Lbx8GTw= 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.10 064/518] mount: handle OOM on mnt_warn_timestamp_expiry Date: Tue, 15 Oct 2024 14:39:28 +0200 Message-ID: <20241015123919.476938907@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015123916.821186887@linuxfoundation.org> References: <20241015123916.821186887@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-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 17d3bea73f8d8..7e67db7456b3d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2555,8 +2555,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, @@ -2564,8 +2571,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