From what I understand, you can’t just walk away from the primary loan either. Say you owe $600,000 on the loan and you walk away. The bank forecloses and auctions your previous home for $480,000. The bank cannot come after you for the $120,000, but I believe they are required to send the IRS a 1099-C for the $120,000 of cancelled debt which is considered a gain to you.
See requirements for 1099-A and 1099-C in regards to property abandonment and debt cancellation: