Stocks ended a volatile session on Tuesday by closing slightly above their opening levels, as buyers returned to the market to acquire troubled financial stocks. Bad news from mortgage backers Freddie Mac and Fannie Mae dragged the mortgage sector-and the broader markets-down. Freddie Mac reported a steep quarterly loss and said it had set aside $1.2 billion in the quarter to account for credit losses. Fellow government-sponsored mortgage backer Fannie Mae's shares fell 24 percent. The company has been under pressure over the past few weeks after it revealed its mortgage losses, with investors questioning whether the losses are bigger than the company has acknowledged. In economic news, U.S. housing starts rose more than expected in October, while building permits-a measure of builder confidence-fell more than expected. Oil closed at a record high, with January light sweet crude surging $3.21 to settle at $98.03 a barrel on the New York Mercantile Exchange, surpassing the previous closing record of $96.70 set November 6. The Dow Jones industrial average rose 51.70, or 0.4 percent, to 13,010.14. Exxon Mobil shares jumped. Other gainers rebounding after Monday's decline included Alcoa, IBM, and Microsoft. The broader Standard & Poor's 500 index rose 6.43, or 0.45 percent, to 1,439.70. The technology-heavy Nasdaq composite index rose 3.43, or 0.1 percent, to 2,596.81. The New York Stock Exchange composite index rose 77.96 to 9,575.29. The American Stock Exchange composite index rose 24.65 to 2,366.84. And the Russell 2000 index fell 1.00 to 749.33.