Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

qeth: BRIDGEPORT "sanity check"

Forbid enabling IFF_PROMISC reflection to BRIDGEPORT when a role
is already assigned, and forbid direct manipulation of the role
when reflection mode is engaged.

Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Eugene Crosser <Eugene.Crosser@ru.ibm.com>
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eugene Crosser and committed by
David S. Miller
ff1d9291 9c23f4da

+12 -4
+12 -4
drivers/s390/net/qeth_l2_sys.c
··· 86 86 87 87 mutex_lock(&card->conf_mutex); 88 88 89 - if (qeth_card_hw_is_reachable(card)) { 89 + if (card->options.sbp.reflect_promisc) /* Forbid direct manipulation */ 90 + rc = -EPERM; 91 + else if (qeth_card_hw_is_reachable(card)) { 90 92 rc = qeth_bridgeport_setrole(card, role); 91 93 if (!rc) 92 94 card->options.sbp.role = role; ··· 186 184 { 187 185 struct qeth_card *card = dev_get_drvdata(dev); 188 186 int enable, primary; 187 + int rc = 0; 189 188 190 189 if (!card) 191 190 return -EINVAL; ··· 205 202 206 203 mutex_lock(&card->conf_mutex); 207 204 208 - card->options.sbp.reflect_promisc = enable; 209 - card->options.sbp.reflect_promisc_primary = primary; 205 + if (card->options.sbp.role != QETH_SBP_ROLE_NONE) 206 + rc = -EPERM; 207 + else { 208 + card->options.sbp.reflect_promisc = enable; 209 + card->options.sbp.reflect_promisc_primary = primary; 210 + rc = 0; 211 + } 210 212 211 213 mutex_unlock(&card->conf_mutex); 212 214 213 - return count; 215 + return rc ? rc : count; 214 216 } 215 217 216 218 static DEVICE_ATTR(bridge_reflect_promisc, 0644,