To implement various artificial intelligence and automation applications in smart factories, edge computing and industrial Internet of Things (IIoT) devices must be widely deployed, so as to increase the demand of coping with huge-scale and high-diversity data. Through deployment of fifth-generation (5G) networks (providing wide broadband, low latency, and massive machine type communications), industrial wireless networks, cloud, and fixed/mobile end devices in smart factories are interoperated in a harmony. However, with the huge-scale deployment of 5G networks and the IIoT in smart factories, threats and attacks against various vulnerabilities increase enormously, and cause considerable security and privacy challenges. Consequently, this article investigates crucial security and privacy issues for 5G-IIoT smart factories in three entities (i.e., physical layer, data layer and application layer), and further surveys recent approaches based on deep learning, reinforcement learning, and blockchain. In addition, this article provides future perspectives and challenges along this line of research.