In this work, the physical layer security performance of an underlay cognitive buffer-aided relay network over the general Nakagami-m fading channel model is addressed, where a primary source communicates with a destination via a decode-and-forward relay node in the presence of an eavesdropper and a secondary communication system. The relay is equipped with a finite-size storage equipment or buffer which can store the sequence of received data packets from source and forward it immediately or subsequently in an adequate time-slot. In this way, the buffer relay enables to adopt a link selection scheme in order to detect the best available link, (i.e. the one with higher secrecy rate) among the available data at source or at the relay buffer. The closed-form expression for the secrecy outage probability (SOP), which is a widely adopted performance metric in the considered scenario, is also derived. Numerical results confirm the accuracy of the derived closed-form analytic expression for SOP and indicates the interaction between secrecy performance and the Nakagami channel parameter m. In particular, it is shown that the SOP experiences a significant drop as the Nakagami channel parameter increases for a predefined target secrecy rate.