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: <3211866.1595933798@warthog.procyon.org.uk>
Date:   Tue, 28 Jul 2020 11:56:38 +0100
From:   David Howells <dhowells@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     dhowells@...hat.com, Kees Cook <keescook@...omium.org>,
        Xiaoming Ni <nixiaoming@...wei.com>,
        David Windsor <dwindsor@...il.com>,
        Hans Liljestrand <ishkamiel@...il.com>,
        Elena Reshetova <elena.reshetova@...el.com>,
        Paul Moore <paul@...l-moore.com>, edumazet@...gle.com,
        paulmck@...nel.org, shakeelb@...gle.com,
        James Morris <jamorris@...ux.microsoft.com>,
        alex.huangjianhui@...wei.com, dylix.dailei@...wei.com,
        chenzefeng2@...wei.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 0/3] Convert nsproxy, groups, and creds to refcount_t

Peter Zijlstra <peterz@...radead.org> wrote:

> > Please do not _undo_ the changes; just add the API you need.
> 
> add_return and sub_return are horrible interface for refcount, which is
> the problem.
> 
> If you meant: refcount_dec(), but want the old value for tracing, you
> want a different ordering than if you wanted to do
> refcount_dec_and_test(); dec_return can't know this.
> 
> David, would something like a __refcount_*() API work where there is a
> 3rd argument (int *), which, if !NULL, will be assigned the old value?

That would be fine, though the number needs to be something I can interpret
easily when looking through the traces.  It would also be okay if there was an
interpretation function that I could use in the trace point when setting the
variable.

Say:

	void rxrpc_get_call(struct rxrpc_call *call, enum rxrpc_call_trace op)
	{
		const void *here = __builtin_return_address(0);
		unsigned int n;

		refcount_inc_return(&call->usage, &n);

		trace_rxrpc_call(call->debug_id, op, n, here, NULL);
	}

then:

	TRACE_EVENT(rxrpc_call,
		    TP_PROTO(..., int usage, ...),

		    TP_ARGS(...),

		    TP_STRUCT__entry(
			    ...
			    __field(int, usage)
			    ...
				     ),

		    TP_fast_assign(
			    ...
			    __entry->usage = refcount_interpret(usage);
			    ...
				   ),

		    TP_printk("... u=%d ...",
			      ...
			      __entry->usage,
			      ...)
		    );

so that it looks like the refcount is 'complete' at 0.

David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ