From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A04E7396573; Tue, 28 Apr 2026 20:59:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.13.80.246 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777409996; cv=none; b=FFKsWVXqKj4ynr13+/5fgniQaHHAYNS9qdgAChWp0d/470c6zNdz490JpSk9QeS6wtv15/wlLu2PPqqh3Rr6NwChm8UQ0zUqzftvoIf45f8ubJTavkw6YupVCuEm5I2b+ITA35tjAklRfbnspjsqfz4mD8bZo2TmorsF2xHOBIE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777409996; c=relaxed/simple; bh=gJ5lkg0cTU4+nmb3wXY+poqfWNLYx0UBwrrG+u+ZiYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bXbVh3dLecxgopLbpVINu8eYoNQ/cLczcw0Bnm0bERel67iBayS0oa6+qhLDw4B661xpj+OIE6bEmv00GZDNgulHW0U46hyLJA/gDyYXdSkHkGAySCivkBCP42xWPRKjYxQpRa0UA/enxRQcoSBs5Mh+VU3cI7oOZ56bwjWNgSU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b=cMBIqItF; arc=none smtp.client-ip=194.13.80.246 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b="cMBIqItF" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 477FBA542E; Tue, 28 Apr 2026 22:59:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1777409986; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=R3fSEmRTZkVpxmyYMZywqZShe9mXH4lfAvPNdV5j8n0=; b=cMBIqItF74Eqi1KNtJbHlFY8hjuUA9tzY9pMiyBqNVRtbVeu5rAb/2NELLcF88QXMdHV/D e13bsYW4UdJKLl0luXCTAT+ONwpimCbq3mtM0OeXvzwVTRi2TsAOw2jxV+myYZBl1JJLId oe+KZZgXp2nTUtd1Na0k7H42uFqXRjS4QqHkeeV9OCO0ynYgX7OBo1dqjqsMp1RNDy0W8l el7K9NH57hG8LHnVjNkAZfJ6oRxSBHJ+vNe2IoIsp5/254h1ZDLCPirE081CUv1ltB5ZZW Ttm5thAFq4T0VoM50B5ZokAZMv3L7kR51jhdvRMTNiKtSR0gyhRxJoKfT/BbGw== From: Nicolai Buchwitz To: netdev@vger.kernel.org Cc: Justin Chen , Simon Horman , Mohsin Bashir , Doug Berger , Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Eric Dumazet , Paolo Abeni , Nicolai Buchwitz , Mohsin Bashir , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next v8 7/7] net: bcmgenet: reject MTU changes incompatible with XDP Date: Tue, 28 Apr 2026 22:58:44 +0200 Message-ID: <20260428205846.2625550-8-nb@tipi-net.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260428205846.2625550-1-nb@tipi-net.de> References: <20260428205846.2625550-1-nb@tipi-net.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 Add a minimal ndo_change_mtu that rejects MTU values too large for single-page XDP buffers when an XDP program is attached. Without this, users could change the MTU at runtime and break the XDP buffer layout. When no XDP program is attached, any MTU change is accepted, matching the existing behavior without ndo_change_mtu. Signed-off-by: Nicolai Buchwitz Reviewed-by: Florian Fainelli Reviewed-by: Mohsin Bashir --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 02ad2f410d6c..4d1ec68ec0c5 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -4085,6 +4085,20 @@ static int bcmgenet_xdp_xmit(struct net_device *dev, int num_frames, return sent; } +static int bcmgenet_change_mtu(struct net_device *dev, int new_mtu) +{ + struct bcmgenet_priv *priv = netdev_priv(dev); + + if (priv->xdp_prog && new_mtu > PAGE_SIZE - GENET_RX_HEADROOM - + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) { + netdev_warn(dev, "MTU too large for single-page XDP buffer\n"); + return -EINVAL; + } + + WRITE_ONCE(dev->mtu, new_mtu); + return 0; +} + static const struct net_device_ops bcmgenet_netdev_ops = { .ndo_open = bcmgenet_open, .ndo_stop = bcmgenet_close, @@ -4095,6 +4109,7 @@ static const struct net_device_ops bcmgenet_netdev_ops = { .ndo_eth_ioctl = phy_do_ioctl_running, .ndo_set_features = bcmgenet_set_features, .ndo_get_stats64 = bcmgenet_get_stats64, + .ndo_change_mtu = bcmgenet_change_mtu, .ndo_change_carrier = bcmgenet_change_carrier, .ndo_bpf = bcmgenet_xdp, .ndo_xdp_xmit = bcmgenet_xdp_xmit, -- 2.51.0