In general you have a wash sale if you sell stock at a loss, and buy substantially identical securities within 30 days before or after the sale. (fairmark.com)
If you buy the same or a substantially identical security within 30 days before or after you sold the losing stock, you aren't allowed to claim the tax loss. (humbledollar.com)
You then buy identical securities back at a later date, to return to the lender. (moneysmart.gov.au)