[lvc-project] [syzbot] [kernel?] divide error in comedi_inc_scan_progress

Жандарович Никита Игоревич n.zhandarovich at fintech.ru
Mon Oct 20 16:36:44 MSK 2025


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 at mev.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


More information about the lvc-project mailing list