Maliks Muwatta Book 16, Hadith Number 34.
Section : Stopping for Funerals and Sitting in Graveyards.
Yahya related to me from Malik that he had heard that Ali ibn Abi Talib used to rest his head on graves and lie on them.
Malik said, “As far as we can see, it is only forbidden to sit on graves to relieve oneself.”