[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d4f354f0972243bebe81c2c132ac95b3@fintech.ru>
Date: Mon, 20 Oct 2025 13:36:44 +0000
From: Жандарович Никита Игоревич <n.zhandarovich@...tech.ru>
To: Ian Abbott <abbotti@....co.uk>,
"syzbot+af53dea94b16396bc646@...kaller.appspotmail.com"
<syzbot+af53dea94b16396bc646@...kaller.appspotmail.com>, H Hartley Sweeten
<hsweeten@...ionengravers.com>
CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"lvc-project@...uxtesting.org" <lvc-project@...uxtesting.org>
Subject: RE: [syzbot] [kernel?] divide error in comedi_inc_scan_progress
Hi Ian,
Thank you for your response!
> > ...
> > if (!(s->subdev_flags & SDF_PACKED) && (cmd->chanlist_len != 0)) {
> > async->cur_chan += comedi_bytes_to_samples(s, num_bytes);
> > async->cur_chan %= cmd->chanlist_len;
> > }
> > ...
> >
> > Any suggestions are greatly appreciated!
>
> I have a plan to deal with these unexpected interrupts, at least within the
> Comedi core functions. The basic idea would be to for the Comedi core
> functions called by the ISRs to check that the subdevice is in the running state
> and increment a reference counter (either a refcount_t or a struct kref) if it is
> safe to proceed. Then it will be allowed to assume that the struct
> comedi_async contents are reasonable until it decrements the reference
> counter. Some other task may be calling
> do_become_nonbusy() in parallel with the above. After
> do_become_nonbusy() clears the COMEDI_SRF_RUNNING flag to mark the
> subdevice as not being in the running state, it should wait until it is safe to
> continue before calling comedi_buf_reset(). This will make use of the
> reference counter and a struct completion. The reference counter and struct
> completion can be stored as members of struct comedi_async.
>
> There may be other parts of individual driver ISRs that use struct
> comedi_async directly and may need changing to do similar checks. The
> checking and final decrement can done by a couple of new exported
> functions:
>
> bool comedi_get_is_subdevice_running(struct comedi_subdevice *s); void
> comedi_put_is_subdevice_running(struct comedi_subdevice *s);
>
> If comedi_get_is_subdevice_running(s) returns true, the ISR can safely
> access s->async and then should call comedi_put_is_subdevice_running(s)
> when it has finished.
>
>
I'll try to tackle this idea when I get the chance, thanks for your suggestion!
> > P.S. To reiterate, I've failed to reproduce this error and this flawed
> > analysis is theoretical only.
> >
> > [1] https://syzkaller.appspot.com/bug?extid=af53dea94b16396bc646
> > [2] https://syzkaller.appspot.com/bug?extid=f6c3c066162d2c43a66c
> >
> > Regards,
> > Nikita
>
>
> --
> -=( Ian Abbott <abbotti@....co.uk> || MEV Ltd. is a company )=- -=(
> registered in England & Wales. Regd. number: 02862268. )=- -=( Regd. addr.:
> S11 & 12 Building 67, Europa Business Park, )=- -=( Bird Hall Lane, STOCKPORT,
> SK3 0XA, UK. || www.mev.co.uk )=-
Regards, Nikita
Powered by blists - more mailing lists