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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e3548c86-7422-432c-8b72-8de99fa9772f@efficios.com>
Date: Fri, 26 Jan 2024 15:24:17 -0500
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Steven Rostedt <rostedt@...dmis.org>, LKML
 <linux-kernel@...r.kernel.org>,
 Linux Trace Kernel <linux-trace-kernel@...r.kernel.org>
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
 Christian Brauner <brauner@...nel.org>, Ajay Kaher
 <ajay.kaher@...adcom.com>, Geert Uytterhoeven <geert@...ux-m68k.org>,
 linux-fsdevel <linux-fsdevel@...r.kernel.org>,
 Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [RESEND] [PATCH] eventfs: Have inodes have unique inode numbers

On 2024-01-26 15:12, Steven Rostedt wrote:
[...]
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index e1b172c0e091..2187be6d7b23 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -223,13 +223,41 @@ static const struct inode_operations tracefs_file_inode_operations = {
>   	.setattr	= tracefs_setattr,
>   };
>   
> +/* Copied from get_next_ino() but adds allocation for multiple inodes */
> +#define LAST_INO_BATCH 1024
> +#define LAST_INO_MASK (~(LAST_INO_BATCH - 1))
> +static DEFINE_PER_CPU(unsigned int, last_ino);
> +
> +unsigned int tracefs_get_next_ino(int files)
> +{
> +	unsigned int *p = &get_cpu_var(last_ino);
> +	unsigned int res = *p;
> +
> +#ifdef CONFIG_SMP
> +	/* Check if adding files+1 overflows */

How does it handle a @files input where:

* (files+1 > LAST_INO_BATCH) ?

* (files+1 == LAST_INO_BATCH) ?

> +	if (unlikely(!res || (res & LAST_INO_MASK) != ((res + files + 1) & LAST_INO_MASK))) {
> +		static atomic_t shared_last_ino;
> +		int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
> +
> +		res = next - LAST_INO_BATCH;
> +	}
> +#endif
> +
> +	res++;
> +	/* get_next_ino should not provide a 0 inode number */
> +	if (unlikely(!res))
> +		res++;

I suspect that bumping this res++ in the 0 case can cause inode range
reservation issues at (files+1 == LAST_INO_BATCH-1).

Thanks,

Mathieu

> +	*p = res + files;
> +	put_cpu_var(last_ino);
> +	return res;
> +}

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ