M-MTax
Level 12

Deductions & credits

You might want to read Reg. Sec 1.121-1. I'll copy and paste it below.

 

(3) Ownership—(i) Trusts. If a residence is owned by a trust, for the period that a taxpayer is treated under sections 671 through 679 (relating to the treatment of grantors and others as substantial owners) as the owner of the trust or the portion of the trust that includes the residence, the taxpayer will be treated as owning the residence for purposes of satisfying the 2-year ownership requirement of section 121, and the sale or exchange by the trust will be treated as if made by the taxpayer.

 

Then read sections 671-679 which outline the grantor trust rules particularly Sec 678....substantial owners.