Unmanned aerial vehicles (UAVs) will be extensively utilized in various Internet of Things (IoT) scenarios due to their flexible mobility and rapid on-demand deployment. It becomes necessary and urgent to investigate the secrecy performance of UAV IoT communication systems because of the open characteristics of wireless channels. In this paper, the physical layer security of UAV IoT communication systems is studied, in which a ground IoT device transmits some confidential messages to a UAV hovering in the air, while a random number of eavesdroppers are randomly positioned around the ground source. The ground-to-air channel is assumed to experience Rician fading for the case of line-of-sight propagation and Rayleigh fading for the case of non-line-of-sight propagation, respectively. In addition, in order to improve the security of the system, we also investigate the secrecy performance of the UAV IoT system with a friendly UAV that generates jamming signals to distract the eavesdroppers. Utilizing stochastic geometry theory, the cumulative distribution functions for the signal-to-interference-plus-noise ratioes of the main and eavesdropping links are derived, and then the analytical expressions of the secrecy outage probability and the average secrecy rate are obtained. Finally, the accuracy of the analytical results is verified by Monte Carlo simulation.