From nobody Thu Apr 2 17:11:21 2026 Received: from mail115-95.sinamail.sina.com.cn (mail115-95.sinamail.sina.com.cn [218.30.115.95]) (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 09F733002CF for ; Fri, 27 Mar 2026 06:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.95 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774591207; cv=none; b=OiRmbZmyye05QFvOfPJmtGVGGkEDaTHZnGJ+nvjhn3/wkR1Mnsfcu3V+h5i+C+orB8VkbNPnDJxpWs+PxaMKZ0txyDQ+zh8j5GYd0KrszYEK4WRk3dg1Oq13c1Oz5K/QVQhFhMSo4BUZIu8J02D0X5TKMajNTHWoPGEOijSQksQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774591207; c=relaxed/simple; bh=gNPN+lsNLG2GUPRQKoAWKY0ykON4ZP/tO61Pm6Pb82Q=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JOOWWgUrjrta2LSEjrWxG4pl4Rw+1zyl1I3KrRq3IwK0WBCNo+zGpohuEpjFsQPqM+qOOnqViPMAkrWU9eAVz/Z9Qm0L9PRLvjsPkoV2u/Ltobt2lizowxgtaNSOit7ioPkg02hCurDE221NMS/UArCp27AD7tlNz9syMv5cigQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=KEK9ifUU; arc=none smtp.client-ip=218.30.115.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="KEK9ifUU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1774591203; bh=fJ+PW7eX9qy32TknMnIEOu3LYMXyYnqf2Eu5m31NLNc=; h=From:Subject:Date:Message-Id; b=KEK9ifUU/f6TSGcoKgp+B22pU+p6U/cjIli7zJLMqoA03v0p1DgQnlY+T+eOKiUYX +JJOXanBglSAeFR4J4XnwRhoIZkd/Ezy+8NPsXcfyAHlNt/zl8UCa7JdixxmZOUacK NbOX/EGLYhdgIUCocSdzB2IOWgIXxrKPFN4auVPk= X-SMAIL-HELO: pek-lpg-core6.wrs.com Received: from unknown (HELO pek-lpg-core6.wrs.com)([60.247.85.88]) by sina.com (10.185.250.23) with ESMTP id 69C61CD700001811; Fri, 27 Mar 2026 13:59:53 +0800 (CST) X-Sender: johnny_haocn@sina.com X-Auth-ID: johnny_haocn@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=johnny_haocn@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=johnny_haocn@sina.com X-SMAIL-MID: 3599558913296 X-SMAIL-UIID: 758896704EBF4874B582EB967FDEA279-20260327-135953-1 From: Johnny Hao To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Alexey Nepomnyashih , Jakub Kicinski , Johnny Hao Subject: [PATCH 5.15.y] xen-netfront: handle NULL returned by xdp_convert_buff_to_frame() Date: Fri, 27 Mar 2026 13:59:50 +0800 Message-Id: <20260327055950.2618928-1-johnny_haocn@sina.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexey Nepomnyashih [ Upstream commit cc3628dcd851ddd8d418bf0c897024b4621ddc92 ] The function xdp_convert_buff_to_frame() may return NULL if it fails to correctly convert the XDP buffer into an XDP frame due to memory constraints, internal errors, or invalid data. Failing to check for NULL may lead to a NULL pointer dereference if the result is used later in processing, potentially causing crashes, data corruption, or undefined behavior. On XDP redirect failure, the associated page must be released explicitly if it was previously retained via get_page(). Failing to do so may result in a memory leak, as the pages reference count is not decremented. Cc: stable@vger.kernel.org # v5.9+ Fixes: 6c5aa6fc4def ("xen networking: add basic XDP support for xen-netfron= t") Signed-off-by: Alexey Nepomnyashih Link: https://patch.msgid.link/20250417122118.1009824-1-sdl@nppct.ru Signed-off-by: Jakub Kicinski Signed-off-by: Johnny Hao --- drivers/net/xen-netfront.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 4b19d54fa2e2..310bc1f7d404 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -982,20 +982,27 @@ static u32 xennet_run_xdp(struct netfront_queue *queu= e, struct page *pdata, act =3D bpf_prog_run_xdp(prog, xdp); switch (act) { case XDP_TX: - get_page(pdata); xdpf =3D xdp_convert_buff_to_frame(xdp); + if (unlikely(!xdpf)) { + trace_xdp_exception(queue->info->netdev, prog, act); + break; + } + get_page(pdata); err =3D xennet_xdp_xmit(queue->info->netdev, 1, &xdpf, 0); - if (unlikely(!err)) + if (unlikely(err <=3D 0)) { + if (err < 0) + trace_xdp_exception(queue->info->netdev, prog, act); xdp_return_frame_rx_napi(xdpf); - else if (unlikely(err < 0)) - trace_xdp_exception(queue->info->netdev, prog, act); + } break; case XDP_REDIRECT: get_page(pdata); err =3D xdp_do_redirect(queue->info->netdev, xdp, prog); *need_xdp_flush =3D true; - if (unlikely(err)) + if (unlikely(err)) { trace_xdp_exception(queue->info->netdev, prog, act); + xdp_return_buff(xdp); + } break; case XDP_PASS: case XDP_DROP: --=20 2.34.1