It's not illegal to build inventories. However, it is illegal to corner a market to artificially inflate prices [unless you're the Saudi goberment, then its ok to do it].
Is kind of like doing a pump and dump strategy, just that you do it in a much larger scale with a few more 000's.