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] [day] [month] [year] [list]
Date:   Mon, 24 Oct 2022 00:54:40 +0000
From:   "Wang, Wei W" <wei.w.wang@...el.com>
To:     Vipin Sharma <vipinsh@...gle.com>
CC:     "Christopherson,, Sean" <seanjc@...gle.com>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "dmatlack@...gle.com" <dmatlack@...gle.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v1] KVM: selftests: name the threads

On Saturday, October 22, 2022 6:34 AM, Vipin Sharma wrote:
> On Mon, Oct 17, 2022 at 9:25 AM Wei Wang <wei.w.wang@...el.com> wrote:
> > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c
> > b/tools/testing/selftests/kvm/lib/kvm_util.c
> > index f1cb1627161f..c252c912f1ba 100644
> > --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> > @@ -2021,3 +2021,50 @@ void __vm_get_stat(struct kvm_vm *vm, const
> char *stat_name, uint64_t *data,
> >                 break;
> >         }
> >  }
> > +
> > +/*
> > + * Create a named thread
> > + *
> > + * Input Args:
> > + *   attr - the attributes for the new thread
> > + *   start_routine - the routine to run in the thread context
> > + *   arg - the argument passed to start_routine
> > + *   name - the name of the thread
> > + *
> > + * Output Args:
> > + *   thread - the thread to be created
> > + *
> > + * Create a thread with user specified name.
> > + */
> > +void pthread_create_with_name(pthread_t *thread, const pthread_attr_t
> *attr,
> > +                       void *(*start_routine)(void *), void *arg,
> > +char *name) {
> > +       int r;
> > +
> > +       r = pthread_create(thread, attr, start_routine, arg);
> > +       TEST_ASSERT(!r, "thread(%s) creation failed, r = %d", name, r);
> > +       pthread_setname_np(*thread, name);
> 
> Since pthread_setname_np() expects "name" to be 16 chars including \0,
> maybe a strnlen(name, 16) check before it will be useful.

Yes. Alternatively, we should just check the return value of pthread_setname_np
and assert on any errors.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ