Done properly
Proper chimney flashing is two parts. Step flashing woven into each shingle course up the side, and counterflashing let into a cut groove in the mortar joint and sealed there.
What we usually find instead is a bead of roofing tar smeared over the joint. Tar cracks within a couple of seasons and the leak comes back.
Crickets on wide chimneys
A chimney wider than about thirty inches needs a cricket, a small ridged structure behind it that diverts water around instead of letting it pool on the up-slope side.
Missing crickets are a frequent cause of rotted decking behind a chimney.
