Whilst not illegal to undertake, this is from the RAC site, full link here:
Undertaking – have you been breaking the law? | RAC Drive
Can you receive a penalty for undertaking?
Some drivers may find it tempting to undertake, especially if they’re faced with a
middle-lane hogger, but be aware that it can be dangerous and you can be fined for doing so.
Undertaking recklessly could see you receive a fixed penalty notice (FPN) for careless driving or
driving without due care and attention.
READ MORE: 10 driving offences you didn’t know were illegal
This usually means three points on your driving licence and a £100 fine, although some police forces may offer a driver education course as an alternative.
In some more serious cases it could be considered dangerous driving which carries a harsher penalty of up to nine points on your licence or disqualification, a fine of up to £5.000 and a court summons.
I don't bother with passing then moving to the left and slowing down, I just pass, signal my intention and move back to the left and move on, hopeful that showing the numpty the way to do it might have some effect.... it sometimes does. Obviously road conditions play a part in this, but on a motorway with clear left hand lane with a good surface there is no excuse.