@@ -120,6 +120,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
err = seq->op->show(seq, p);
if (err > 0) {
+ WARN_ONCE(1, "seq_ops->show() returns %d\n", err);
/* object is skipped, decrease seq_num, so next
* valid object can reuse the same seq_num.
*/
@@ -156,6 +157,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
err = seq->op->show(seq, p);
if (err > 0) {
+ WARN_ONCE(1, "seq_ops->show() returns %d\n", err);
bpf_iter_dec_seq_num(seq);
seq->count = offs;
} else if (err < 0 || seq_has_overflowed(seq)) {
In seq_read() implementation, a positive integer return value of seq_ops->show() indicates that the current object seq_file buffer is discarded and next object should be checked. bpf_seq_read() implemented in a similar way if show() returns a positive integer value. But for bpf_seq_read(), show() didn't return positive integer for all currently supported targets. Let us add a WARN_ONCE for such cases so we can get an alert when things are changed. Suggested-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com> --- kernel/bpf/bpf_iter.c | 2 ++ 1 file changed, 2 insertions(+)