Never step back with Knuth-Morris-Pratt
Naive matching restarts after every mismatch and can compare the same text characters many times. Knuth-Morris-Pratt first studies the pattern: for each prefix it records the longest proper prefix that is also a suffix.
pattern = "abab"
failure = [0, 0, 1, 2]
# after a full "abab" match,
# "ab" counts toward the next oneThink before coding
On a mismatch, fall back through the failure table instead of moving backwards in the text. Each text character is read once, so the search is linear in text plus pattern, and overlapping matches are found naturally. Work through the example by hand before changing the starter. Decide what should happen for an empty input, a single value and a repeated value where those cases apply. The checks use several inputs so a hard-coded answer cannot stand in for the rule.
Your task
Write find_all(text, pattern) returning every start index of pattern in text, overlaps included, in linear time. A non-empty pattern is guaranteed.
The explanation opens here once every check passes.