Unless you have written permission from a song's original artist/rightsholder, it is not legal to sample it. If you want to play it safe, I recommend only using cleared samples in your music. You want to avoid ending up on the wrong side of a lawsuit.