Re: [RFC v1 08/14] bus1: implement peer management context

From: Tom Gundersen
Date: Fri Oct 28 2016 - 09:19:40 EST


On Fri, Oct 28, 2016 at 2:06 PM, Richard Weinberger
<richard.weinberger@xxxxxxxxx> wrote:
> David, Tom,
>
> On Wed, Oct 26, 2016 at 9:18 PM, David Herrmann <dh.herrmann@xxxxxxxxx> wrote:
>> +struct bus1_peer *bus1_peer_new(void)
>> +{
>> + static atomic64_t peer_ids = ATOMIC64_INIT(0);
>> + const struct cred *cred = current_cred();
>> + struct bus1_peer *peer;
>> + struct bus1_user *user;
>> +
>> + user = bus1_user_ref_by_uid(cred->uid);
>> + if (IS_ERR(user))
>> + return ERR_CAST(user);
>> +
>> + peer = kmalloc(sizeof(*peer), GFP_KERNEL);
>> + if (!peer) {
>> + bus1_user_unref(user);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + /* initialize constant fields */
>> + peer->id = atomic64_inc_return(&peer_ids);
>
> What is the purpose of this id? Do other components depend on it
> and are they aware of possible overflows?

The id is used purely to give a name to the peer in debugfs.

> Since it is an 64bit integer overflowing it is hard but not impossible.

Hm, what scenario do you have in mind? I cannot see how this could
happen (short of creating peers in a loop for hundreds of years).

Cheers,

Tom