2022 was a challenging year for investors, with the S&P 500 index down 19.4% and the tech-heavy Nasdaq Composite index falling 33.1%. The declines put both indexes firmly in bear market territory.

One person who knows a thing or two about investing in bear markets is Berkshire Hathaway CEO Warren Buffett. Since taking control of Berkshire Hathaway in 1965, Buffett has helped the holding company generate returns of roughly 2,419,900% for investors -- crushing the S&P 500's returns in the process.

One of Buffett's many notable investment quotes encapsulates the current stock-buying environment quite well: "Be fearful when others are greedy and greedy when others are fearful." Coming into 2022, Berkshire Hathaway was sitting on a record cash balance. Buffett used the bear market in stocks to put billions of this cash to work, investing heavily in several companies.

Let's take a closer look at four intriguing stocks the Oracle of Omaha bought during the 2022 bear market.

1. Ally Financial: 30 million shares purchased

Since the start of 2022, Buffett (through Berkshire) took a 9% ownership stake in Ally Financial (ALLY 0.41%). Ally Financial primarily funds automotive loans to consumers. Last year its operations were challenged by rising interest rates and slowing consumer demand for those loans.

Buffett likes to invest with a margin of safety, which is the idea that you should only invest in stocks when their market price is far below their intrinsic value. In 2022, Ally stock fell 48.7% and it now trades at a dirt cheap valuation. Ally trades at a 20% discount to its book value and is near its cheapest valuation since going public in 2014, as measured by its price-to-sales (P/S) and price-to-earnings (P/E) ratios.

ALLY Price to Tangible Book Value Chart

ALLY Price to Tangible Book Value data by YCharts

Ally faces headwinds from its automotive lending business in the short term, but it is steadily growing its other offerings, including Ally Invest, Ally Credit Card, and Ally Lending. Buffett is taking the long view and investing in a bank that has grown its consumer deposits for 54 consecutive quarters and benefits from higher interest rates -- with new loans producing up to 9% interest. Given its dirt-cheap valuation, Ally should provide long-term investors with solid upside potential and limited downside risk.

2. Markel: 467,611 shares purchased

Markel (MKL -1.00%) writes insurance policies on hard-to-place risks and is often compared with Berkshire Hathaway because of its vast investment portfolio -- which is likely why Buffett took a $616 million stake in it. 

The insurer has done a stellar job of writing insurance policies and uses the cash it makes to invest in businesses outside of insurance. One-third of Markel's investments are in stocks, including Berkshire Hathaway, Brookfield Asset Management, Alphabet, Amazon, Deere, and Home Depot. It also invests in private companies across various industries, including construction machinery, building supplies, and luxury handbags. 

Warren Buffett is a huge fan of insurers because of the cash flows they generate, and Markel's investment portfolio has it well-positioned for when the market eventually rebounds.

3. Chevron: 127 million shares purchased

Since the start of 2022, Berkshire Hathaway has piled into oil and gas stocks, including adding a $22 billion stake in Chevron (CVX 0.37%)

Chevron is appealing because it's one of the most well-balanced oil and gas companies, operating both upstream and downstream businesses that make it less vulnerable to the big swings in oil and gas prices. This balanced business model makes it an appealing dividend-paying stock that has increased its dividend payout for 35 consecutive years.

Higher oil prices in the last year have benefited the oil giant, which through three quarters has generated net income and cash flow from operations of $29 billion and $37 billion, respectively. It has used these staggering cash flows to pay down debt, raise its dividend, and buy back billions of dollars in shares.

While oil prices may come down in 2023, tailwinds such as the U.S. purchase of oil to refill its strategic petroleum reserve (SPR), China's reopening, and OPEC production cuts could keep prices elevated -- making Chevron a solid passive income stock worth owning.

4. Occidental Petroleum: 194 million shares purchased

Occidental Petroleum (OXY -0.15%) is another oil and gas company Berkshire Hathaway aggressively bought during the year, building a stake worth over $12 billion. 

Its acquisition of Anadarko Petroleum in 2019 saddled it with a huge debt burden, but higher oil prices have helped it cut this debt load nearly in half this year. Reducing its debt loan helps get Occidental back to investment-grade status, which lowers its cost of capital and helps save the company $350 million in interest expenses. These added savings allows the company to boost dividends and stock repurchases as well.

Looking forward, Occidental is a leader in carbon capture and sequestration -- the process of capturing carbon emissions and safely storing them elsewhere to reduce carbon in the atmosphere. This could be a $4 trillion market opportunity and provide Occidental's business with a significant boost in the coming years.