If we chose to become an exit node at the same time while routing our connections through Tor, is there a possibility that our own exit node is going to be the exit node that we just set up? (As a result, our real IP would be exposed)
The path spec doesn't list choosing your own node as one of its constraints on exit nodes:
2.2. Path selection and constraints
We choose the path for each new circuit before we build it. We choose the exit node first, followed by the other nodes in the circuit. All paths we generate obey the following constraints:
- We do not choose the same router twice for the same path.
- We do not choose any router in the same family as another in the same path. (Two routers are in the same family if each one lists the other in the "family" entries of its descriptor.)
- We do not choose more than one router in a given /16 subnet (unless EnforceDistinctSubnets is 0).
- We don't choose any non-running or non-valid router unless we have been configured to do so. By default, we are configured to allow non-valid routers in "middle" and "rendezvous" positions.
- If we're using Guard nodes, the first node must be a Guard (see 5 below)
and I suspect that it would not exclude itself from the list of possible exit nodes. Contrary to what you might think, this is a good thing.
Imagine a situation where an attacker has found a way to force you to create a new circuit and knows what exit node you're using: The attacker could continuously force you to create a new circuit, all the while writing down what exit nodes you select. Eventually he would see that you don't pick a certain node (the one you're running) and you'd be deanonymized.
By allowing you to pick your own node, you're actually gaining security because it makes your exit node and proxied traffic indistinguishable from other traffic / exit nodes in the network. Not being able to select your own exit would be a factor that could lead to deanonymization.