If I have a low GPA in undergrad, and want to get into top PhD programs, should I do an MS degree or redo my undergrad degree? I want to get into specifically top schools (in materials science and engineering) because I want to have a decent shot at being a professor.

I am aware that quite a few people have successfully done an MS and went on to top PhD programs, but my concern is that because the MS GPA is so inflated, it won't help me in my case. I already have a first author publication soon to be submitted, so my research experiences have been covered well, and my uGPA of 3.1 is my only weakness. Remember, I am trying to get into top schools, where they get so many applications that they are seeking any reason to throw them out.

Because undergrad GPAs are less inflated, I was thinking that doing a whole another undergrad might be more helpful in letting me demonstrate an improvement academically. In addition, some schools require specifically an undergrad GPA limit, apparently without regards to whether the applicant has an MS degree or not. But at the same time, since I would be repeating the same thing, they might not see it as that much of an improvement.

What do you think?
As others have said, getting a second undergrad degree is a waste of time.  Don't bother.

The unfortunate truth is that your undergrad GPA may keep you out of top PhD programs even if you have a Master's degree with a perfect GPA and multiple journal publications.

Top engineering graduate programs receive hundreds or even thousands of applicants every year.  Despite what others may tell you, they're not looking for an excuse to reject applicants because it keeps their US News rating high.  They're looking for excuses to reject because there are far too many applications to judge each one on its merits, and far too many highly qualified applicants to admit them all, and the committee members are faculty who have many other demands on their time and who want sleep occasionally.  In some departments, applications are filtered by GPA even before the first human committee member reads them.

By far the best way over that hurdle is to cultivate a champion -- a faculty member who is active and visible in their research community, who will write you glowing letters describing your strong potential for independent research (in personal, technical, and credible detail), and who will call up their colleagues in other departments to tell them to watch for your application.  The goal here is to interest someone in your target department enough to rescue your application from knee-jerk rejection and evaluate it on its own merits.

And then your application needs to shine on its own merits.  It must provide compelling evidence of your strong potential for independent research.  Yes, your graduate GPA is a (small) part of this, but you need to sell yourself primarily as a future researcher, if not a current researcher, not just someone who excels at classes.  Moreover, this evidence needs to be stronger than for other applicants with higher undergraduate GPAs.  Do not assume that one first-author publication is enough.

All that said... Focusing on research and finding a champion will improve your chances of being admitted to a top program, but they will not guarantee anything.  In particular, even with a strong research record and vocal champions, you may still be rejected because of your undergrad GPA.  Admissions is best considered a random process; the most you (or anyone) can do is improve your odds.

Incidentally, the same advice goes for your longer-term goal of getting a faculty position.  Yes, having a degree from a non-top-10 department makes it harder to get an academic position, but you can work against that disadvantage by developing a killer research portfolio and multiple champions (not just your advisor).  Conversely, a PhD from a top-10 department will not guarantee you success on the faculty job market; you also need a killer research portfolio and multiple champions (not just your advisor).  Start developing that now.