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: <YDhAZ5bQ9fqd3FWB@shinobu>
Date:   Fri, 26 Feb 2021 09:27:19 +0900
From:   William Breathitt Gray <vilhelm.gray@...il.com>
To:     Pavel Machek <pavel@....cz>
Cc:     Jonathan Cameron <jic23@...nel.org>, kernel@...gutronix.de,
        linux-stm32@...md-mailman.stormreply.com, a.fatoum@...gutronix.de,
        kamel.bouhara@...tlin.com, gwendal@...omium.org,
        alexandre.belloni@...tlin.com, david@...hnology.com,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, syednwaris@...il.com,
        patrick.havelange@...ensium.com, fabrice.gasnier@...com,
        mcoquelin.stm32@...il.com, alexandre.torgue@...com,
        o.rempel@...gutronix.de
Subject: Re: [PATCH v8 18/22] docs: counter: Document character device
 interface

On Mon, Feb 22, 2021 at 11:11:33AM +0100, Pavel Machek wrote:
> Hi!
> 
> > > +* COUNTER_ENABLE_EVENTS_IOCTL:
> > > +  Enables monitoring the events specified by the Counter watches that
> > > +  were queued by ``COUNTER_ADD_WATCH_IOCTL``. If events are already
> > > +  enabled, the new set of watches replaces the old one. Calling this
> > > +  ioctl also has the effect of clearing the queue of watches added by
> > > +  ``COUNTER_ADD_WATCH_IOCTL``.
> > > +
> > > +* COUNTER_DISABLE_EVENTS_IOCTL:
> > > +  Stops monitoring the previously enabled events.
> > 
> > Is there a way to remove a watch? 
> 
> Is there a way to eat all kernel memory and crash the system by adding
> too many watches?

There can only ever be as many watches as there are Counter components
for the respective Counter device. This is enforced by
counter_set_event_node() which checks whether a particular watch has
been created before and returns an EINVAL if it so has.

> > > +For example, the following userspace code opens ``/dev/counter0``,
> > > +configures the ``COUNTER_EVENT_INDEX`` event channel 0 to gather Count 0
> > > +and Count 1, and prints out the data as it becomes available on the
> > > +character device node::
> > > +
> > 
> > Consider adding an example program under tools/
> > 
> > > +        #include <fcntl.h>
> > > +        #include <linux/counter.h>
> > > +        #include <stdio.h>
> > > +        #include <string.h>
> > > +        #include <sys/ioctl.h>
> > > +        #include <unistd.h>
> > > +
> > > +        struct counter_watch watches[2] = {
> > > +                {
> > > +                        .component.type = COUNTER_COMPONENT_COUNT,
> > > +                        .component.scope = COUNTER_SCOPE_COUNT,
> > > +                        .component.parent = 0,
> > 
> > Good to add comments on what these elements actually are?
> 
> > > +                fd = open("/dev/counter0", O_RDWR);
> > > +
> > > +                ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches);
> > > +                ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches + 1);
> > > +                ioctl(fd, COUNTER_ENABLE_EVENTS_IOCTL);
> 
> > > +                for (;;) {
> > > +                        read(fd, event_data, sizeof(event_data));
> 
> If this goes to tools it really should have error handling and
> handling of short read.
> 
> Best regards,
> 							Pavel
> 
> -- 
> http://www.livejournal.com/~pavelmachek

Ack. I'll improve the error handling for this.

William Breathitt Gray

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ