lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240730131145.caamuyu2goloa67n@quack3>
Date: Tue, 30 Jul 2024 15:11:45 +0200
From: Jan Kara <jack@...e.cz>
To: Christian Brauner <brauner@...nel.org>
Cc: Olaf Hering <olaf@...fle.de>, Deepa Dinamani <deepa.kernel@...il.com>,
	Jeff Layton <jlayton@...nel.org>, linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Alexander Viro <viro@...iv.linux.org.uk>, Jan Kara <jack@...e.cz>
Subject: Re: [PATCH v1] mount: handle OOM on mnt_warn_timestamp_expiry

On Tue 30-07-24 11:49:37, Christian Brauner wrote:
> On Tue, Jul 30, 2024 at 10:58:13AM GMT, Olaf Hering wrote:
> > 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. The API of that function is not
> > documented. It currently returns only ERR_PTR values, but may return
> > also NULL in the future. Use PTR_ERR_OR_ZERO to cover both cases.
> > 
> > Fixes: f8b92ba67c5d ("mount: Add mount warning for impending timestamp expiry")
> > 
> > Signed-off-by: Olaf Hering <olaf@...fle.de>
> > ---
> >  fs/namespace.c | 12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/namespace.c b/fs/namespace.c
> > index 328087a4df8a..539d4f203a20 100644
> > --- a/fs/namespace.c
> > +++ b/fs/namespace.c
> > @@ -2922,7 +2922,14 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount *
> >  	   (!(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 *mntpath;
> > +		
> > +		if (!buf)
> > +			return;
> > +
> > +		mntpath = d_path(mountpoint, buf, PAGE_SIZE);
> > +		if (PTR_ERR_OR_ZERO(mntpath))
> 
> This needs to be IS_ERR_OR_NULL().
> 
> > +			goto err;
> 
> We should still warn when decoding the mountpoint fails. I'll just amend
> your patch to something like:

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 328087a4df8a..0f2f140aaf05 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2921,16 +2921,21 @@ 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 = NULL;
> +
> +               buf = (char *)__get_free_page(GFP_KERNEL);
> +               if (buf)
> +                       mntpath = d_path(mountpoint, buf, PAGE_SIZE);
> +               if (IS_ERR_OR_NULL(mntpath))
> +                       mntpath = "(unknown)";
> 
>                 pr_warn("%s filesystem being %s at %s supports timestamps until %ptTd (0x%llx)\n",
>                         sb->s_type->name,
>                         is_mounted(mnt) ? "remounted" : "mounted",
>                         mntpath, &sb->s_time_max,
>                         (unsigned long long)sb->s_time_max);
> -
> -               free_page((unsigned long)buf);
> +               if (buf)
> +                       free_page((unsigned long)buf);
>                 sb->s_iflags |= SB_I_TS_EXPIRY_WARNED;
>         }
>  }
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ