Commit cf4df9cf authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka
Browse files

cobalt/vfile: seq_file seek index must progress

The offset field we receive from the kernel in a vfile next() handler
must progress in order for the loop to stop properly, independently
from our own tracking of the end-of-list condition.

Bug is reproducible by running two loops in parallel:

- one continuously spawning an application which creates a few tenths
of threads (10-20 would suffice) before exiting shortly after.

- another one continuously reading from /proc/xenomai/sched/{threads,
  stat, acct}.

At some point, the vfile handler should cause a kernel crash.
Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
parent d3b4ad5b
......@@ -109,11 +109,11 @@ static void *vfile_snapshot_next(struct seq_file *seq, void *v, loff_t *offp)
struct xnvfile_snapshot_iterator *it = seq->private;
loff_t pos = *offp;
if (pos >= it->nrdata)
return NULL;
return it->databuf + pos * it->vfile->datasz;
......@@ -454,17 +454,15 @@ static void *vfile_regular_next(struct seq_file *seq, void *v, loff_t *offp)
struct xnvfile_regular *vfile = it->vfile;
void *data;
it->pos = ++(*offp);
if (vfile->ops->next == NULL)
return NULL;
it->pos = *offp + 1;
data = vfile->ops->next(it);
if (data == NULL)
return NULL;
*offp = it->pos;
return data;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment