There are an awful lot of completely incorrect posts on this thread. What is so frustrating is that if only middle lane road hogs were prosecuted and if only drivers did MORE passing on the inside, we could free up the congestion on our motorways.
It is not illegal to undertake.
It is not illegal or against the Highway Code to pass a slower moving vehicle on the inside.
It is against the Highway Code to undertake a vehicle.
Here is the difference: if you are driving along Lane 1, and there is a middle lane road hog in Lane 2, you are PERMITTED to continue your path alone Lane 1 and pass them on the inside. i.e. The Highway Code does not demand that you do 4-6 lane changes to get round the idiot, which is something I see often. Stay in your lane and pass them on the inside.
If you are driving on lane 2, 3 or 4 and you come up against a lane hogger who is not overtaking any other vehicle (and therefore is not driving correctly), and you move to the next lane down to undertake them, and move back out to the next lane up again, that is undertaking and that is not permitted.
The difference is to do with where your car position is. I would urge everyone to pass non-undertaking, slower moving vehicles on the inside more, if it is safe to do so and carefully (given that if they're such an idiot to be in that lane in the first place when they are not overtaking they might be such an idiot to suddenly change lanes without checking their mirrors). Continuing your path and passing on the inside means it is safer for you to continue your driving line, you don't put yourself in increased danger by changing lanes, you continue using the free lane as is correct, and you make good use of the motorway reducing congestion.
Passing on the inside =/= undertaking.