Attacking Massive MIMO Cognitive Radio Networks by Optimized Jamming

Massive multiple-input multiple-output (MaMIMO) and cognitive radio networks (CRNs) are two promising technologies for improving spectral efficiency of next-generation wireless communication networks. In this paper, we investigate the problem of physical layer security in the networks that jointly use both technologies, named MaMIMO-CRN. Specifically, to investigate the vulnerability of this network, we design an optimized attacking scenario to MaMIMO-CRNs by a jammer. For having the most adversary effect on the uplink transmission of the legitimate MaMIMO-CRN, we propose an efficient method for power allocation of the jammer. The legitimate network consists of a training and a data transmission phase, and both of these phases are attacked by the jammer using an optimized power split between them. The resulting power allocation problem is non-convex. We thus propose three different efficient methods for solving this problem, and we show that under some assumptions, a closed-form solution can also be obtained. Our results show the vulnerability of the MaMIMO-CRN to an optimized jammer. It is also shown that increasing the number of antennas at the legitimate network does not improve the security of the network.


I. INTRODUCTION
I N RECENT years, the increasing demands for bandwidth and also inefficient usage of the frequency spectrum have caused a severe shortage of this communication resource. Cognitive radio networks (CRN) and massive multiple-input multiple-output (MaMIMO) systems are two efficient solutions to this problem [1]- [3]. The main goal of the CRN is to efficiently utilize the scarce spectrum by sharing the spectrum between different networks or by opportunistically using the unused frequency bands [1]. On the other hand, in the MaMIMO systems, by using a large number of antennas at the base stations (BSs), very high spectral efficiency is achievable with low complexity transmitters and receivers [3]. The combination of these two techniques; which we refer to as MaMIMO-CRN; can boost these gains and is considered as an efficient method for substantial improvement in the wireless network performance in terms of sum rate and spectral efficiency [4]- [10].
In [4], authors showed that the achievable sum rate of the CRN increases if both primary and secondary BSs have a large number of antennas. In addition, it is shown that increasing the number of antenna at the secondary system has the advantage of reducing the channel estimation error and improving spectrum sensing procedure [5]. Three problems of resource allocation, interference mitigation, and user selection in underlay MaMIMO-CRNs were studied in [6]. Authors in [7] proposed an orthogonal pilot sharing scheme at the training phase and formulated a power allocation problem in a MaMIMO-CRN that provides the maximum downlink sum rate in the secondary system. In [8], selecting the maximum number of secondary users and satisfying the required quality of service in a MaMIMO-CRN This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ VOLUME 2, 2021 were investigated and a joint power allocation and secondary user selection algorithm was proposed. Authors in [9] proposed a fair energy-efficient optimization problem in MaMIMO-CRN. In [10], a power allocation problem for pilot and data transmission phases with an energy efficiency guarantee in the uplink of the MaMIMO-CRNs was investigated. Moreover, a conventional method for combating these attacks is using encryption techniques that are related to upper layers of the networks. However, physical layer attacks can be efficiently mitigated by techniques performed at that layer which are known as physical layer security techniques [11]- [12]. Physical layer security has been widely studied in the context of massive MIMO systems as well as CRNs. Authors in [13] showed that MaMIMO systems are secure against passive attacks but vulnerable against active attacks. For example, if an active attacker attacks the training phase of a MaMIMO network, it can produce a pilot contamination effect that makes the channel estimation erroneous [14]. Furthermore, in [15], authors studied the effect of eavesdropping in a multi-user MaMIMO system, where there is one active eavesdropper per user. They assumed that each eavesdropper obtains the pilot used by one user and re-transmits it to disrupt the network quality. Then, they proposed an uplink data aided double channel training scheme, which can accurately detect the presence of an attacker and estimate the legitimate channels. Moreover, authors in [16] studied physical layer security in the presence of a full-duplex active eavesdropper that uses jamming attacks to improve its eavesdropping mode. Also, some issues around the jamming attack such as jamming detection as well as designing jamming resistant receivers were studied in [17]- [19]. It has been shown in the literature that a smart jammer that has some pieces of information about the MaMIMO network and accordingly uses them to optimize its attack, can disrupt the performance of the legitimate network considerably.
For instance, a worst-case smart jamming attack over MIMO Gaussian channels was proposed in [20]. On the other hand, in the CRNs, the problem of physical layer security has been studied from two different aspects [21]. Spectrum sensing data falsification and primary user emulation are some known attacks that destroy the spectrum sensing phase [22]- [23]. On the other hand, jamming and eavesdropping are the attacks that are performed at the cognitive communications phase [24]- [25]. Despite many papers published on the physical layer security of the MaMIMO and CRN networks, related to MaMIMO-CRN the number of papers is very limited. For example, in [26], providing secure transmissions in the MaMIMO-CRNs against a passive multi-antenna eavesdropper with a pilot contamination attack was studied. Likewise, intercepting the confidential downlink transmissions of the MaMIMO-CRNs in the presence of an active eavesdropper was investigated in [27]. Moreover, in [28], a smart jamming attack on the uplink transmission of the MaMIMO-CRN was designed to destruct the performance of the secondary system.
In this paper, we investigate the maximum degradation that a jammer can have on MaMIMO-CRNs. In fact, we design and evaluate the most destructive strategy that a smart jammer may adopt to attack a MaMIMO-CRN in order to minimize spectral efficiency. In this scenario, the jammer optimizes its transmission parameters to have the worst adversary effect on the legitimate network. Particularly, it optimally allocates its power between the training and data transmission phases of the legitimate MaMIMO-CRN network to minimize the spectral efficiency of the primary network. This is an important problem and can be considered as the prerequisite step for developing countermeasure algorithms that are then designed and used to protect the MaMIMO-CRNs from illegal and destructive attacks.
We formulate the aforementioned power allocation problem as a non-convex min − max optimization problem. To solve this problem, we propose three different solution methods. In the first method, we present a geometric programming based solution. The second method presents a closed-form solution for the problem which can be obtained under specific realizations of the channel matrices. In the third method, we utilize an epigraph form of the objective function and certain transformations of the constraint functions to solve the problem. In addition, to illustrate and compare the performance of the proposed solution methods, our analytical and simulation results also show that a jammer with optimized power allocation can efficiently degrade the spectral efficiency of the MaMIMO-CRNs. In this case, even increasing the number of antennas at the base stations cannot improve the performance of the legitimate network. The aim of this study is to help network designers to develop efficient countermeasure techniques to secure MaMIMO-CRNs against jamming attacks.
The remainder of this paper is as follows. In Section II, we introduce the system model. Problem formulation for the jammer power allocation and the proposed solutions to the optimization problem are given in the Sections III and IV, respectively. Section V is devoted to the jammer optimization in the presence of primary system optimal power. Numerical results and conclusions are expressed in Section VI and Section VII, respectively.

II. SYSTEM MODEL
As illustrated in Fig. 1, we consider the uplink transmission of a TDD multi-user MaMIMO-CRN using underlay spectrum sharing. The network consists of a primary and a secondary system. The primary system consists of K legitimate single antenna users and a primary base station (PBS) equipped with N p 1 antennas. Also, the secondary system consists of M legitimate single antenna users and a secondary base station (SBS) with N s 1 antennas. We denote the ratio between N p and N s by κ. There is also a jammer in the area whose target is to destroy the communication of the primary system. We denote the coherence time of the channel by T in which the first η symbols are used for transmitting η-tuple (K + M ≤ η ≤ T) mutual orthogonal pilot sequences to estimate the channels and the rest of T is used to transmit uplink data symbols.
At the beginning of each coherence interval, each legitimate user transmits its assigned pilot. At the same time, the jammer transmits its signal which is a combination of the pilots in the training phase. Next, in the data transmission phase, the jammer sends a noise-like signal simultaneously with the users that send their data signals. For this goal, the jammer needs some information including the transmission protocol (i.e., the timing of transmission) and the pilot set. We assume that before attacking the legitimate system, this information is provided to the jammer or the optimized (smart) jammer by itself acquiring this information during some coherence time before starting to attack the network [17].
Furthermore, g k denotes the channel between the kth primary user and the PBS, i.e., the kth column of the channel matrix between the primary users and the PBS. We denote this matrix by G = H G D G 1/2 in which H G ∈ C N p ×K models small scale fading of the primary channel with i.i.d elements distributed as CN ∼ (0, 1). In addition, β g k is the kth diagonal element of the diagonal matrix D G ∈ R K×K that models the path loss and shadowing effect between the kth primary user and the PBS. Also, f m denotes the channel between the mth secondary user and the SBS, i.e., the mth column of the channel matrix between the secondary users and the SBS. We denote this matrix by F = H F D F 1/2 in which H F ∈ C N s ×M models the small scale fading of the secondary channel with i.i.d elements distributed as CN ∼ (0, 1). Likewise, β f m is the mth diagonal element of the diagonal matrix D F ∈ R M×M that models the path loss and shadowing effect between the mth secondary user and the SBS. Also, h p and h s are the channel vectors between the single antenna jammer and the PBS and the SBS, respectively. In addition, β h p and β h s model the path loss and shadowing effect between the jammer and PBS and SBS, respectively. Furthermore, v m is the mth column of V ∈ C N p ×M that denotes the channel vector between the mth secondary user and the PBS where β v m models the path loss and shadowing effect of it , and u k is the kth column of U ∈ C N s ×K that denotes the channel vector between the kth primary user and the SBS where β u k models the path loss and shadowing effect of this channel.
To formulate the destructive power allocation problem, we consider the case that the jammer uses all information that it obtained from the jamming phase.

III. PROBLEM FORMULATION AND ASYMPTOTIC SPECTRAL EFFICIENCY
In this section, we formulate the primary spectral efficiency minimization problem, targeted by the jammer, and also analyze its asymptotic behavior. For this purpose, we consider two phases of transmission, namely pilot transmission phase and data transmission phase.

A. TRAINING (PILOT TRANSMISSION) PHASE
As we mentioned before, in order to increase the impact of jamming on the primary system, we assume that the jammer knows the set of pilot sequences of the primary system and the transmission protocol. It should be noted that the jammer has no information about the specific pilot sequence that is assigned to each primary user at any time slot. The jammer adopts a pilot contamination attack strategy, and to this end sends a linear combination of the primary's pilot sequences in the training phase.
The pilot sequences of the primary and secondary systems are denoted by two matrices of p ∈ C η×K and s ∈ C η×M , respectively. The kth column of p , φ p k , denotes the kth primary user's pilot sequence and the mth column of s , φ s m , denotes the mth secondary user's pilot sequence. VOLUME 2, 2021VOLUME 2, 2221 The received signal at the PBS is (1) where p p , p s and p j are the average transmission powers of each primary user, secondary user and the jammer during the training phase, respectively. The matrix N ∈ C N p ×K is a circularly-symmetric complex Gaussian receiver noise matrix at the PBS with i.i.d. CN ∼ (0, 1) elements, and φ j = η k=1 φ p k is the jammer's pilot sequence. Since (K + M ≤ η ≤ T), the MaMIMO-CRN can allocate mutual orthogonal pilot sequences to K +M primary and secondary users. Therefore, in the MaMIMO-CRN the primary system is effectively protected from the secondary system in the training phase, i.e., φ p Thus, by using mutual orthogonal pilot sequences and minimum mean square error (MMSE) estimation [29], the estimation of g k denoted byĝ k is obtained as where The variance ofĝ k is equal to where σ 2 . It should be noted that, due to K < η, PBS can use pilot(s) utilized only by jammer to estimate the jammer's channel and obtain p j β h p [17]. After that, by using the pilot utilized by each user and the information about p j β h p , each user's channel and p p β g k can be estimated. Then, by using the closed-form solution of the MMSE estimator,ĝ k is estimated as Eq. (2) and consequently, σ 2 g k is obtained from (4).

B. DATA TRANSMISSION PHASE
In this phase, the jammer sends its adversary signal at the same time slot as the users send their data to the BSs. Let y p d be the N p × 1 received vector at the PBS defined as y where q p , q s and q j are the average transmission powers of each primary user, each secondary user and the jammer during data transmission phase, respectively. Moreover, x ∈ C K×1 and z ∈ C M×1 denote the normalized symbol vectors transmitted by the primary and secondary users, respectively where E{xx H } = I K and E{zz H } = I M . Furthermore, s denotes the normalized random symbol of the jammer where E{|s| 2 } = 1. Also, the PBS receiver noise n follows a zero mean circularly-symmetric complex Gaussian distribution. Then, the received signal at the PBS is decoded as where A ∈ C N p ×K denotes the linear detection matrix at the PBS which depends on the primary estimated channel. The kth element of y d p becomes where a k is the kth column of A. The first term in (7) is the desired signal which is independent of the other terms. In order to find a closed-form solution for spectral efficiency of the kth primary user, we use the lower band for the spectral efficiency as follows [30] By using the maximum ratio combining (MRC) detector at both the primary and secondary base stations, where the detector matrix A is equal to matrix G which is estimated in the training phase, the SINR of the kth primary user is obtained as in (9), as shown at the bottom of this page. By assuming that all channels are independent with Normal distributions and using some algebra, as stated in Appendix A, the sum spectral efficiency of the primary system can be written as (10), shown at the bottom of this page.
From the previous discussions, we have the following result.
Corollary 1: When the number of antennas at the PBS, N p , in (10) goes to infinity, the performance of the primary system is saturated due to the pilot contamination effect that is produced by the jammer. This result can be expressed as This result shows that the MaMIMO-CRN is vulnerable to a jammer that attacks the pilot phase. It is also observed that increasing the number of antennas will not improve the spectral efficiency performance.
To illustrate destructive effect of the jamming attack on the performance of the MaMIMO-CRN, we propose an optimal power allocation mechanism by the jammer.

IV. OPTIMAL POWER ALLOCATION
In order to design the optimal jammer that has the highest destruction on the performance of the primary system in the training and data transmission phases, the jammer should optimally divide its power budget between the training and data transmission phases. To do so, the jammer solves a power optimization problem to minimize the maximum sum spectral efficiency of the primary system as follows. By defining we formulate the optimization problem as in (12) at the bottom of this page.
In (12), C 1 denotes the primary interference constraint, in which Γ is the maximum allowable interference from the secondary system on the primary system; C 2 represents the quality of service requirement of the secondary users which is defined by their SINR. In addition, C 3 is the energy budget constraint of each secondary user; E s max specifies the maximum allowed total energy for each secondary user; C 4 shows that sum of energies at the training and data transmission phases is equal to the jammer's maximum energy budget and Q denotes the jammer's maximum power budget.
The optimization problem in (12) is non-convex and cannot be solved efficiently. In the following, we propose three efficient methods to solve it. Firstly, we propose a geometric programming (GP) model for the max part of (12) for a given realization of the channel matrices, and then use standard numerical methods to obtain the optimal value of (12). To reduce the complexity, in the second proposed method, we derived a closed-form solution for (12) under some constraints on the channel gains. Finally, in the third proposed method, by use of epigraph form of the objective function and some manipulations on the constraints, we transform (12) to an equivalent convex optimization problem.

A. GEOMETRIC PROGRAMMING (GP) METHOD
In this solution, because of the multiplication of the variables, we study the GP model for the max problem of (12) [31].  Thus, for a given realization of the channel matrices and by using the monotonicity of the log function we have min p j ,q j max q s ,p s a b + cq s + dp j + eq j + f q s p j + gq j p j The objective function of (13) is not a posynomial function and thus, is not in GP definitions [31]. Therefore, by using the inverse of the objective function of (13), we obtain a posynomial objective function. According to [32], inversing the objective function of a min − max problem results in an equivalent max − min problem. Therefore, our problem is transformed to a max − min problem as follows Since the objective function and constraints of (14) are posynomial functions w.r.t q s and p s , the min problem of (14) is a GP optimization problem [31]. Then, to solve the max − min problem (14), we find the solution of the min problem of (14) for a finite set of pairs (p j , q j ) satisfying p j , q j ≥ 0 and ηp j + (T − η)q j = QT. Then, we choose the pair which results in the maximum value for the solution of the min problem of (14). Note that the aforementioned set has a cardinality of N = QT η.δ , where δ is the step size of discretization of the valid interval of p j , and therefore our search is computationally affordable.

B. CLOSED-FORM SOLUTION
In this solution, we first study the max problem of (12). It should be noted that the objective function of the max problem just depends on q s . Thus, we want to obtain the optimal value of q s . At first, according to Appendix B, we demonstrate that the objective function of the max problem in (12) has a non-increasing behavior. Then for simplicity, we show the feasible set of the max problem in (12) in Fig. 2 (See Appendix C).
Under this feasible set and non-increasing behavior of the objective function, we realize that the smallest q s in the feasible set is the optimal value of q s . The smallest value of q s is shown in Fig. 2 by a black dot. Therefore, we should find the intersection of the boundary of C 2 with largest horizontal asymptotic with that of C 3 to find the smallest q s .
The optimal values of q s and p s are obtained as functions of q j (Appendix D). After that, by using C 4 , i.e., , we have a minimization problem with one variable as follows where and is the upper bound of q j (Appendix E). Finally, by setting the derivative of the objective function of (15) equal to zero, we can find optimal values of q j and p j . Also, a closed-form solution for q j and p j can be obtained for a given realization of the channel matrices (Appendix D).

C. CONVEX TRANSFORMATION (CT) METHOD
In this method, we try to find the convex model for the max problem of (12). We know that for x > 0, log 2 (1 + 1 x ) is a convex and non-increasing function. Moreover, the combination of any non-increasing convex function with a linear or concave function is always convex, and the summation of convex functions on the same domain is also convex [31]. Therefore, the objective function in (12) is a convex function w.r.t q s . Due to the maximization of a convex function is not a convex problem, we use the epigraph form of the objective function of (12) as follows max p s ,q s ,λ λ s.t. C 1 : ≥ γ m . c 2 m p s + d 2 m q s + e 2 m + f 2 m q j p s + g 2 m q j ∀m, where q k = b k + c k q s + d k p j + e k q j + f k q s p j + g k q j p j and p k = a k +q k . In (16), C 1 and C 3 are not convex sets [31]. To convexify C 1 , we exploit the concavity of the negative relative entropy function, i.e., q k log p k q k . To this end, we multiply q k by the LHS of C 1 . Then, to have a valid constraint, we should multiply the upper bound of q k by the RHS of C 1 . Moreover, to convexify C 3 we define x = p s q s . Thus, we have a convex problem as follows where X is the upper bound of x. Moreover, ζ k and ω k are the upper bounds of q k and p k , respectively. Finally, to solve the min − max problem, we find the solution of the max problem for a finite set of pairs (p j , q j ) satisfying p j , q j ≥ 0 and ηp j + (T − η)q j = QT. Then, we choose the pair which results in the minimum value for the solution of the max problem. Note that the aforementioned set has a cardinality of N = QT η.δ , where δ is the step size of discretization of the valid interval of p j , and therefore our search is computationally affordable.
Remark 1: By assuming that the SNR value is calculated for the three methods, the computational complexity can be analyzed as follows. The first method consists of two min and max parts. The min part of the problem is formulated as a GP problem, which is solved using the interior point method whose computational complexity is upper bounded by O(n 4 L), where n is the number of variables and L is the bit-length of the input data [33]. There are two variables p s and q s , and therefore, computational complexity of the GP part of the method is of order of a constant value. Moreover, the max part of the problem is a finite search over a set of cardinality of QT η.δ . Hence, the total computational complexity of this method is in the order of O(n 4 QT η.δ L) = O(16 QT η.δ L). The second method consists of min and max parts. The minmax problem is solved in a closed form, and therefore, no iteration is performed to find the solution. Hence, the computational complexity is in the order of O (1). In the third method, due to that the relative entropy function is a special type logarithmic barrier functions, the interior point method is applied for solving it [31]. Therefore, similar computational complexity with the first method, can be stated, except that the number of variables according to problem (17) is 3K + 4. Hence, the computational complexity is at worst . Moreover, computational complexity of the SINR, presented in (9), depends on the number of antenna elements, which is in order of N 2 p , where N p is the number of primary system antennas. Simulation results on the computational complexity shows that the running time of the third method is more than the two other methods. Also, the second method is the fastest method.

V. JAMMER OPTIMAL POWER ALLOCATION USING PRIMARY OPTIMAL POWERS
In previous sections, the jammer's effect on the fixed primary's powers was investigated. Here, we study a scenario that both the primary and secondary users have optimal power allocation. Therefore, in order to increase the destructive effect on the primary system, the jammer designs its attack by considering the following assumption and solves (18), as shown at the bottom of the next page, in which P p is the total transmit power of each primary user.
By using the solution similar to the CT method for a given realization of the channel matrices, we have a convex problem as follows max p s ,q s ,p p ,q p ,λ,p,q,x 1 ,x 2 ,x 3 λ, where x 1 = p p q s , x 2 = p s q s and x 3 = p s q p . Their upper bounds are denoted by X 1 , X 2 and X 3 , respectively. Here, ξ and ω are the upper bounds of q = (β g k + p j β hp ηp p ) and p = N p β 2 g k + q, respectively.
Finally, we use numerical methods to obtain the optimal powers of the system.

VI. NUMERICAL RESULTS
In this section, the performance of the proposed methods is investigated. In particular, we consider a MaMIMO CRN consisting of a primary system, a secondary system and a jammer as depicted in Fig. 1. In this network, we evaluate the sum spectral efficiency of the primary system in different scenarios. The number of primary users is K = 20 and the number of secondary users is M = 20. The coherence time of the channel is T = 200 symbols. The parameters that we use in this section are presented in Table 1. It should be noted that we use CVX toolbox of MATLAB to solve the GP and CT methods.
We define ρ and ζ as the ratio of the training phase energy to the total energy for the primary users and the jammer, respectively. Therefore, we have 1. Due to the variance of the noise is normalized to one, the power budget of each primary user and the jammer, denoted by P p and Q, respectively is measured in dB and, therefore, dimensionless.   (12). It is seen that in all the number of antennas, the performance of the three methods is almost the same. Thus, the three proposed methods are efficient and have the same results, hence, we can use the most rapid one to solve Eq. (12). It should be noted that since we assume κ = 1, the number of antennas at the SBS is equal to the number of antennas at the PBS. Fig. 4 shows the effect of the value of ζ that obtained from three proposed solution methods on the sum spectral efficiency of the primary system versus the number of antennas at the PBS. As shown in Fig. 4, the sum spectral efficiency of the primary system for the obtained ζ , i.e., ζ = 0.5, has the lowest value. To give an intuition, consider the denominator of the inner part of the objective function  of the problem 12, and also assume that the coefficients d k , e k , and g k are equal to 1. Then, the maximum of the denominator would be obtained for the equal value of p j and q j , or equivalently ζ = 0.5. This result means that we have obtained the optimal power allocation of the jammer to degrade most the MaMIMO-CRN performance. Fig. 5 illustrates the sum spectral efficiency of the primary system versus the number of antennas at the PBS in different power budgets (P p ) of each primary user. This figure validates the result of equation (11), which states that with the large number of N p , the sum spectral efficiency of the primary is saturated. Also, it is deduced from Fig. 5 that the proposed system model with a lower value of P p is more vulnerable to the jamming attack. Fig. 6 and Fig. 7 indicate the effect of the jammer's power budget and the number of the PBS antennas on the energy allocation ratio of the jammer, respectively. As shown in    6, by increasing the jammer's power budget in different ρ, ζ approximately tends to 0.5. Thus, the jammer can allocate equal energy to each uplink transmission phase to destroy the MaMIMO-CRN. Moreover, it is seen from Fig. 6 that by increasing the energy allocation ratio of the primary system (ρ), the optimal energy allocation ratio of the jammer (ζ ) decreases. This is intuitive, because, as much as primary system pay more energy in the data transmission phase, it is more beneficial to the jammer to transmit more energy in the other phase, i.e., training phase.
Similar results are obtained from Fig. 7, in the case that the number of the PBS antennas varies and Q is fixed. Thus, in a large value of Q or N p , the jammer has the vulnerable effect very easily. Therefore, the jammer does not need to know any information about the primary and secondary systems to solve problem (12) to have a destructive attack and just should allocate equal energy to each uplink transmission phase to degrade the performance of the MaMIMO-CRN. VOLUME 2, 2021 2227 primary base station antennas (N p ) with and without optimal powers of primary users (with ρ = 0.6). Fig. 8 shows the sum spectral efficiency of the primary system versus the number of primary base station antennas with and without the optimal powers of primary users. According to Fig. 8, when the jammer attacks the system with the optimal powers of the primary and secondary systems, the destructive effect of the jammer increases. Also, according to the proposed attack scenario, a jammer has a more destructive effect if it attacks the optimum MaMIMO-CRN.

VII. CONCLUSION
We studied the sum spectral efficiency behavior of a multiuser MaMIMO-CRN in the presence of a jammer. The pilot contamination within the training phase of the primary system was due to a jammer, which could optimally allocate its power budget to attack the training and data transmission phases of the primary system. We showed that even with a large number of antennas at the primary and secondary base stations, the jammer could destruct the sum spectral efficiency of the primary system. Moreover, it is illustrated that even in the case of a large number of antennas at both the primary and secondary base stations, for a large amount of the jammer's power budget, the jammer requires no process to allocate its power budget to optimally attack each uplink transmission phase.

APPENDIX A
Here we simplify the numerator and denominator of the right hand side (RHS) of the equation (9).
Assume that all channels are independent and with zero mean Normal distributions . Now, by considering (2), the numerator of the RHS of (9) can be written as follows, To simplify the denominator of the RHS of (9), the following terms are calculated.
where i = k, Tr[ · ] calculates the trace of a matrix, and the equalities a, b, c and d are due to the trace properties and also the independence of the channels.
where the equality g can be verified by considering (2) and the independence of the channels. The equality E{||g k || 4 } = N p (N p + 2)β 2 g k can be easily verified due to Normal distribution of g k . Moreover, E{h H p g k g H k h p } and E{φ T p k N H g k g H k Nφ * p k } are simplified using the trace trick and independence of the random variables, similar to (21). Finally, the remaining terms of the denominator are calculated in the same manner as mentioned, where for brevity the details are removed. Accordingly, we have,

APPENDIX B
We know that the derivative of the combination of two functions is calculated as follows In the spectral efficiency that we calculated, f (x) = log 2 (1 + 1 x ) that for x > 0 is a non-increasing function [14], and g(x) = (b k + c k q s + d k p j + e k q j + f k q s p j + g k q j p j )/a k is an increasing function w.r.t q s . Therefore, the spectral efficiency of each primary user is a non-increasing function w.r.t q s . Also, according to the rule that (f + g + h + · · · ) = f + g + h + · · · , the sum spectral efficiency of the primary system is a non-increasing function as q s is increasing.

APPENDIX C
After simplifying C 2 in (12), we have: since the powers and other terms in (25) are positive, the right hand side of (25) is positive and therefore the left hand side of (25) should be positive. Thus we have Since p s must always be positive, the only allowed mode of inequality (26) exists with the condition a 2 m − γ m b 2 m ≥ 0 as follows Eventually, C 2 is obtained as follows q s ≥ γ m p s c 2 m + f 2 m q j + e 2 m + g 2 m q j The inequality (28) is a homogeneous function, therefore, to plot (28) we should calculate the horizontal and vertical asymptotics of it. These asymptotics in our problem are positive and equal to It should be noted that to obtain the intersection of C 2 with C 1 and C 3 , we should find the largest horizontal asymptotic of C 2 for all m : 1, . . . , M.
Also, calculating the derivative of the fraction in (28) shows that its derivative is always negative. Therefore, the homogeneous function in (28) is always decreasing.

APPENDIX D
By finding the intersection of the boundary of C 3 with that of C 2 with largest horizontal asymptotic, the optimal value of p s is obtained as where which is defined as The optimal value of q s is obtain from q * s = E smax −ηp * s T−η . By using q * s and p * s and setting the derivative of the objective function in (15) equal to zero for a given realization of the channel matrices, we have a quartic equation as follows where in which We now use the following solution to solve a quartic equation as ax 4 + bx 3 + cx 2 + dx + e = 0. The roots of this equation are obtained as where p = 8ac − 3b 2 8a 2 , Therefore, by using (32) and 0 ≤ q j ≤ we find the optimal value of q j .

APPENDIX E
In order to maintain the feasibility of the optimization problem (12), the horizontal asymptotic obtained from (29) should not violate condition C1. Therefore,