From: "Жандарович Никита Игоревич" <n.zhandarovich@fintech.ru>
To: Ian Abbott <abbotti@mev.co.uk>,
"syzbot+af53dea94b16396bc646@syzkaller.appspotmail.com"
<syzbot+af53dea94b16396bc646@syzkaller.appspotmail.com>,
H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>
Subject: RE: [syzbot] [kernel?] divide error in comedi_inc_scan_progress
Date: Mon, 20 Oct 2025 13:36:44 +0000 [thread overview]
Message-ID: <d4f354f0972243bebe81c2c132ac95b3@fintech.ru> (raw)
In-Reply-To: <9c92913c-c04b-4784-9cdc-5d75b10d2ed9@mev.co.uk>
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@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
next prev parent reply other threads:[~2025-10-20 13:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 17:52 syzbot
2025-10-16 11:05 ` Nikita Zhandarovich
2025-10-20 10:45 ` Ian Abbott
2025-10-20 13:36 ` Жандарович Никита Игоревич [this message]
2025-10-20 17:29 ` Ian Abbott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d4f354f0972243bebe81c2c132ac95b3@fintech.ru \
--to=n.zhandarovich@fintech.ru \
--cc=abbotti@mev.co.uk \
--cc=gregkh@linuxfoundation.org \
--cc=hsweeten@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=syzbot+af53dea94b16396bc646@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®