Oil from the crankshaft rotation is thrown against the cylinder walls during engine operation. This is oil escaping from the rod bearing. When the piston comes down in the cylinder, the bottom rings (usually a pair, called oil control rings) scrapes the cylinder pretty much clean of oil. There is a very small amount left behind on the cylinder walls which lubricates the rings. This oil is burnt off during the combustion process, but really there is so little of it, it doesn't cause issues. Remember, the oil is coming from the bottom and is scraped downward during engine operation by not only the oil control rings, but by the compression rings as well. This doesn't leave a lot of oil on the cylinder walls. Since the rings and pistons are lubricated from the bottom, they will draw oil with them upward as the piston travels upward during the exhaust stroke. This happens the same way during the compression stroke.
As you've probably figured out, the top ring sees the least amount of lubrication. It is most commonly made from cast iron, which self-lubricates to an extent. Cast iron also is very durable against wear of this type.
Here is what a cross section view of the piston, cylinder wall, and piston rings look like:
Image from University of Windsor.
Please note, the above image is representational, though it is a pretty good representation. Every manufacturer can and will do their setups differently.