Are can and may interchangeable?

An often-repeated grammar rule says that can indicates an ability to do something, while may indicates what is allowed or permitted.

Can she run a mile in less than six minutes?
May I have another piece of cake?

In reality, this distinction in meaning is often difficult to make, so can and may are sometimes used interchangeably.

You may keep that umbrella, if you want it.
You can keep that umbrella, if you want it.
(Is the speaker granting you permission to keep the umbrella, or informing you that you have the ability to keep it?)