At the population density of Kowloon in 1987, 1,255,000 per square kilometer, and today's population of 8 billion people, it would only take 6375 square km to house everyone.
That's less than five cities the size of Phoenix, Arizona.
Reasonable urban population density -- the kind where there is still green space and buildings are mostly just a few stories high -- would be about 7500 per square km, about 1.1 million square km for the world population. That sounds like a lot, but it's only about one tenth the metro area of Paris.
There is a clean water problem. There is a good sewage treatment problem. There are energy delivery problems. But people will happily live in much denser arrangements than they do on average, and cities make all of the other problems more efficient to deal with. These are policy problems.