Somehow, downstream from your connection to the common line from the downstairs tub, there is a restriction to flow that causes water to drain less quickly than you want, and it backs up along the horizontal pipe into your tub. The water comes down from the shower drain faster than it can get past the drain from the tub.
It could be something that you could remedy by unclogging the main (the downpipe below the tub drain entry), but often it is simply a design flaw and you need to do some pipework to fix it. Three options: use a narrower drain from the upstairs shower (slow flow ahead of the junction) although that likely would make the shower back up; use a larger diameter pipe below the tub drain link to increase flow from that point; or drop the drain pipe from the tub a lot before linking it to the downpipe, making it very unlikely that water could back up that far.
There is probably no elbow trap, or only a very shallow one, between tub and downpipe. I bet you get smells too when the backwash happens.