Fix: reduce scope of kconsumer consumed_pos and produced_pos
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 2 Jun 2016 09:19:50 +0000 (05:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 2 Jun 2016 09:29:35 +0000 (05:29 -0400)
commit923333cd43560b8d0b1c474f4fa669bc30f02dc4
treee5f7352764287ee0826946fbec306e9e81e8a551
parent13a7bce327fb908d2ddafba17cadebbb13389f12
Fix: reduce scope of kconsumer consumed_pos and produced_pos

The consumed_pos and produced_pos accesses are protected by the
stream mutex, which is fine as-is. However, consumed_pos is
passed to consumer_get_consume_start_pos() and is flagged by
Coverity as a possible use of a "stale" consumed_pos.

From an analyzer's standpoint, this makes sense since
both lttng_kconsumer_get_produced_snapshot() and
lttng_kconsumer_get_consumed_snapshot() could leave their output
parameter uninitialized and return 0 since they both  assume that
ioctl() will set errno if ret != 0.

IOCTL(3P) specifies that errno is only set if ret < 0.

A bug in lttng-modules could cause ioctl() to return a positive
value, leaving the errno variable unset. In such a case,
both functions would return 0, leaving the positions uninitialized.

A follow-up fix enforces this assumption (ret never > 0) as part
of the kernctl API.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/kernel-consumer/kernel-consumer.c
This page took 0.024873 seconds and 4 git commands to generate.