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: <20250106143350.GC7233@redhat.com>
Date: Mon, 6 Jan 2025 15:33:51 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@...el.com>,
	"David S . Miller" <davem@...emloft.net>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	Tzvetomir Stoyanov <tz.stoyanov@...il.com>,
	Naveen N Rao <naveen@...nel.org>,
	Josh Poimboeuf <jpoimboe@...nel.org>,
	Jason Baron <jbaron@...mai.com>, Ard Biesheuvel <ardb@...nel.org>,
	linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: DEFINE_FREE/CLASS && code readability (Was: [PATCH v2 2/6]
 Provide __free(argv) for argv_split() users)

On 01/06, Masami Hiramatsu wrote:
>
> On Sun, 5 Jan 2025 15:14:22 +0100
> Oleg Nesterov <oleg@...hat.com> wrote:
>
> > Perhaps we can establish a simple rule that every DEFINE_FREE() or DEFINE_CLASS()
> > should add another #define? I mean something like
> >
> >
> > 	DEFINE_FREE(argv, char **, if (!IS_ERR_OR_NULL(_T)) argv_free(_T))
> > 	#define __FREE_ARGV	__free(argv)
> >
> > 	void func(void)
> > 	{
> > 		char **argv __FREE_ARGV = argv_split(...);
> > 		do_something(argv);
> > 		return;
> > 	}
> >
> > This way I can press Ctrl-] and see what the cleanup code actually does.
> > Can save a second or two. Important when you try to read the code you are
> > not familiar with.
>
> That sounds lile a problem of your tool. Do you really need to find the
> DEFINE_FREE()

Yes, ":tag __free_argv" wont work. it is defined by DEFINE_FREE(argv) above.
I need to find this DEFINE_FREE(argv) to see what __free_argv() actually does.

> > Same for DEFINE_CLASS. For example,
> >
> > 	int ksys_fchown(unsigned int fd, uid_t user, gid_t group)
> > 	{
> > 		CLASS(fd, f)(fd);
> >
> > 		if (fd_empty(f))
> > 			return -EBADF;
> >
> > 		return vfs_fchown(fd_file(f), user, group);
> > 	}
> >
> > If you are not familiar with this code, it looks mysterious until you find
> > DEFINE_CLASS(fd, ...) in include/linux/file.h.
>
> DEFINE_CLASS() is somewhat mysterious to me too :) But if I understand
> correctly, it is for intermediate macro for implementing guard().

Well, in this case you just need to find

	DEFINE_CLASS(fd, struct fd, fdput(_T), fdget(fd), int fd)

in include/linux/file.h, after that the code is clear.

> BTW, I agree that 'argv' was too simple. Basically the label name of
> DEFINE_FREE() is better to be a function name for free.
> Let me fix that.

Up to you, but __free(argv) looks good to me.

Oleg.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ