Under the 654-page bipartisan budget bill recently signed into law by President Trump, mortgage-insurance premiums are again deductible, at least for 2017. (SHAWN THEW/EPA-EFE/REX/Shutterstock/SHAWN THEW/EPA-EFE/REX/Shutterstock)

Call it buried tax treasure for homeowners: Deep inside the behemoth 654-page bipartisan budget bill recently signed into law by President Trump are little-noticed extensions of key tax-code benefits that expired in 2016 but now can be used for upcoming 2017 tax filings.

Potentially the most popular one is aimed at millions of people who pay mortgage-insurance premiums on conventional, FHA and VA loans. Roughly 4.1 million owners took write-offs averaging more than $1,500 during 2015, the most recent year for which statistics are available. Mortgage-insurance industry officials predict that at least that many will be able claim the benefit on their 2017 tax returns — provided they learn that the deduction has been revived for the year.

Mortgage insurance is designed to cover a portion or all of a lender’s risk of loss in the event of default on home loans where borrowers make a down payment of less than 20 percent. The coverage is especially commonplace — and important — on mortgages made to first-time purchasers and to households with moderate or lower incomes. Fees are either folded into borrowers’ monthly payments or paid in a lump sum upfront.

Congress first authorized tax deductions for mortgage-insurance premiums more than a decade ago, but legal authority for the write-offs lapsed at the end of 2016. The new budget law provides for a retroactive extension for premiums paid during 2017, but it’s silent about future deductions, including for 2018.

To qualify for the benefit, borrowers must pass a couple of tests: The home securing the insured mortgage must have been their principal residence during the year rather than a second home or investment property. And their adjusted gross income must have totaled less than $100,000. Deductible amounts phase down to zero for taxpayers with incomes up to $110,000.

Another popular tax-code provision brought back to life retroactively for 2017 filings: Elimination of tax liability on mortgage debt forgiven by lenders in connection with short sales, foreclosures and loan modifications. Without this special exception, financially distressed homeowners would otherwise be subject to the tax code’s traditional, harsh treatment of canceled debt: Any amounts forgiven are taxed as ordinary income, at regular marginal rates — essentially hitting owners with prodigious tax bills at the very time they are least able to pay, following a foreclosure or short sale. If, for example, a lender wrote off $100,000 as part of a short-sale arrangement, the Internal Revenue Service could demand income taxes on that $100,000 even though the sellers had lost all their equity and were in bad financial shape already.

Originally passed by Congress during the housing crisis of the past decade, the special exception benefited thousands of owners who struggled with job losses, medical bills and other financial challenges during the Great Recession and the years following. Although foreclosures and short sales have declined steadily during the post-recession recovery, they are still a significant presence in the real estate market. According to ATTOM Data Solutions, lenders started the foreclosure process on nearly 384,000 properties during 2017. The amounts canceled by lenders often reach the tens of thousands or hundreds of thousands of dollars; some exceed $1 million.

Although Congress renewed the debt-forgiveness rule multiple times, it expired at the end of 2016. But under the new budget law, homeowners who had mortgage debt canceled by their lender during 2017 may be eligible for tax relief. IRS guidelines for the program are spelled out in the agency’s Publication 4681. Maximum eligible amounts of mortgage debt canceled range up to $2 million ($1 million if you’re married filing separately).

Other potentially useful expired tax benefits that were revived retroactively for 2017 involve energy-conserving improvements made to your home. The new extension allows you to get a tax credit of 10 percent of what you spent on certain improvements such as insulation, energy-efficient windows and doors, and roofs. The cost of installing the improvements cannot be included in the calculation of the credit amount.

You may also be eligible for a credit for high-efficiency heating and air conditioning systems, water heaters and stoves that burn biomass fuel. Note that there are limits on the total credit you can claim. To qualify, you’ll need to have installed your “qualified improvements” in your principal residence — no second homes allowed — no later than Dec. 31, 2017.

Ken Harney’s email address is harneycolumn@gmail.com.