Abu Marthad al-Ghanawi reported Allah's Messenger (sallallaahu alayhi wa sallam) as saying:
Do not sit on the graves and do not pray facing towards them.
Maalik made ta'wiil of this hadith and said that sitting is only forbidden if one does it to relieve himself. He made this ta'will based on the following in Muwatta
It reached Malik that he had heard that AIi 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."
التوضيح في شرح المختصر الفرعي لابن الحاجب
Page 289 Volume 1