Twain's attitude toward slavery and racism is that he is against it. How you can tell is by examining how his characters react to the other characters in the novel who support slavery and who are racist. I am thinking of that chapter where Huck stays with the Grangerford's. It is such a funny chapter because it really shows Twain's attitude toward those people who supported slavery and racism. He portrays the Grangerford's and the Sheperdson's are really stupid white people who haven't got a clue about why they believe the things they do. They act in ways that support fighting and slavery but they cannot explain why. And, even when they are asked to explain their actions, they don't even take that as an opportunity to re-think their actions or beliefs. Instead, they just blindly follow the social rules and habits of their ancestors. This says a lot about what Twain thinks about slavery. He sees most people to be more like the Grangerford's and Sheperdson's than unlike them.
Mark Twain's Adventures of Huckleberry Finn is a satirical look at the institution of slavery. Although written from the point of view of a southern white boy, Huck ultimately sheds the ideals of his upbringing and decides to help his friend, the slave Jim. The novel explores many ideas of freedom. Jim is a slave from St. Petersburg who has found out that he is to be sold away from his family. In order to prevent this, he runs away. Huck is also running away, from an abusive father and a town that wants to "sivilize" him. In Huck's case, civilizing him means turning him into a version of themselves, Bible-toting racists and hypocrites. Huck cannot abide it, and against all he's ever been taught, helps Jim escape slavery. There is a pivotal scene in the novel where Huck has an opportunity to do what is right according to his society and turn in Jim. Instead he says, "alright then, I'll go to hell!" and decides to protect Jim at the expense of his own soul. By doing this, Twain points out the humanity of this lone boy in the face of a whole institution. Huck is more humane, more ethical, than almost every other character in the book. Huck is the only one that sees Jim as something more than property, he sees him as a friend.
There have been critical texts galore written about this topic. I would suggest reading books and essays by Shelley Fisher Fishkin, R. Kent Rasmussen, Henry Nash Smith, and others. There is also the Annotated Huckleberry Finn edited by Michael Patrick Hearn that has more information on this topic. Enotes has a wonderful study guide and group on Huck Finn as well.