From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 007CA2DEA98 for ; Wed, 1 Jul 2026 14:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782917586; cv=none; b=XlwJwhJ3n+gzIpKOuIvntbEM0Pg60hu3EPfkobddmPxZIC0vxiDRztdXRzehV/s4xX1Wighbvvhv3v7xzVQwGzMynTY6aC2GBpcnrmLWiGMAIyt6WvAAECEBk1Jq8qSu7aH1U2wjj2e3PHlGPqa/UEX7mT9Tmb6t9pX9UvnIaTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782917586; c=relaxed/simple; bh=mzaX6C6vuZHr13pss6u4zN5KYvfwiAcxJDMYW//l64s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ov6OnqziZpBgTfiP5ZQfTTSmT68xEFGFa9z3NCzZw547VHF86fv0JAdvY2zYHILZo4Ueu4vsjYQ+kWZkHK/k18afMe9fnkQwtjX2lCc+LT8fp3qHnVIW0e3y005s7ZqY+olUpG4brXCpqpqw3UWP0UnhVTkjMiAme0GKdnnkSS8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SqW8jIk8; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=oATqSGD6; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SqW8jIk8"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="oATqSGD6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782917584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xZhnJ37qmK4wXhmEG2SVGmBhlYiKgFgvUvUlcftgiQY=; b=SqW8jIk8LSi/aKw9AUBYyT8yq4w84w8ByNGKTUnWx8hpXlcEtdmB2v5g5rr9r2RDMLwKVM DjqkjpU0kVovXkrBebPUvF6Jvw6TQYguDY9wQL+nJ2oQo3FGB7OxlB31TVQUfPqwGeygGu aAMWLEBHo3RLYZpE869ZcmhKiWXdPcw= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-439-uCVNIVPiM-eZwfOPOv7lrw-1; Wed, 01 Jul 2026 10:53:02 -0400 X-MC-Unique: uCVNIVPiM-eZwfOPOv7lrw-1 X-Mimecast-MFC-AGG-ID: uCVNIVPiM-eZwfOPOv7lrw_1782917582 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4926d371224so6805125e9.1 for ; Wed, 01 Jul 2026 07:53:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782917581; x=1783522381; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=xZhnJ37qmK4wXhmEG2SVGmBhlYiKgFgvUvUlcftgiQY=; b=oATqSGD6QB4+JHQLokL1cfhuSCvDiuARY9u6a2AlBCGtQ5jI7zWzj42amiLVfBAAke t+e5nhJvSyloVtzuB9VjZCkaXVpap4TDIAYSt18EZg5QouoToWqHs6XX5CK9Tj7102Jc qsI34T8LPEmiVmKBVkDVMM+CawqfunpDdy3uPGCIodRi2KhNiLG9MZdswmjIAdsC69+y o/j2RjXABYdEpDoKzM4sGDr7k9Gn3lL5DRbzg5QkXGJPIFRfC2rZ+MrdvBne0LejzDq6 ljrLzhKI7PP6DclPrXsmLu7f5PtVH8FBz0+GWDIMjAAjIPEnatyi3KqXmezl6kJMkdZm 6nQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782917581; x=1783522381; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xZhnJ37qmK4wXhmEG2SVGmBhlYiKgFgvUvUlcftgiQY=; b=iaRxytBdoNsTHwb8St126bbPKTK5DjI/exOKDQoL09MIuUadsFsRainDe0th1uSEyI O/ljquDoP6mVuuJtSWcsP7KcwCqdXpYvlb4ZfGQwfTvO8nR59j93NxcTlV+E8+dCNPkr pnWOdevy7vjw88vdkqQiIc+QOAneoulEjENUItNKyc0UCVrOf5tZXNGT7u0O+DYilUqL YN2KSFNpfFV+Q1XzcHgYMqqoPwE3GQpaVvEbpzi5wZntCWzOP2ynFkS5wuTigIeW+88u YS31VrJ9UmaDiF1Q8ksbBIM9LdSVnfDbB9HOwfD5XzKP6wZk6BUYXLypBN2sH0OaRvOh 1lvw== X-Forwarded-Encrypted: i=1; AFNElJ99BJHTtYOnYPLStZPFRd46W5VTBCgjFFK43peKBHh4JUp9qJblXglyfDlHzoVDYg8qIxN/4qJg5hsJHhQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyExRXetpfolmulZCGfJkzJz+2cVtrqfNzUt+4FG6vecmR6fwTe 8SOIAER4qkaEtYwN/1u5NR8kaIm8mLQuwhsqukaE4vbLm5zDwuMdV2BIt1j8Yf4B3UTiXw4LaQ0 mk4eXeFzShYWjPDO9aR9V8FTKBO7TuRSdrRisb4A3cqmxk2XpgB7ekJ51o61Ayto5Gw== X-Gm-Gg: AfdE7cnhOTP1LwDjMjWmi2iOMzFc2RUOWfMCWFM87TmWbzfhYwgQxZCNVt7irSfOn3b lpxsUPPnXwbcHwfTi8MJKVZQlxwrDffG70hGfRVHXdm/oJGx+6DVNCTZ+D2Yh0yvKpGXoaH18lg /YU4o3ia3u4dB/AiBjqsS9LZVNUNiBD1sZWcgirnfJkBBRcwB2Vq0xuX34X15N1Ev4v99dhOSF2 UIS5yhClGxdtchc1e1JutRl0AH0PWqyzhlKW4w967Up/j869s+KuqtvFI2hG3qgswTFv5hytRAP WqH8NvOm1CZqd+kZ036HacZFmcSq7pvDimNX6/GHOqVY0GG3tLfksgKN3j3JBaWvZUQpR8ive5o Amjtlij5DUy3sSVZFvMd/T0tmoUA5tWFaoyIpDnBkRlNwlwbNWGD3zeHFZ8l34NNiclWKQ/iBC+ rrvzebp4WGzg== X-Received: by 2002:a05:600c:64c5:b0:493:bc4b:b8c with SMTP id 5b1f17b1804b1-493c3df3541mr15223475e9.38.1782917581637; Wed, 01 Jul 2026 07:53:01 -0700 (PDT) X-Received: by 2002:a05:600c:64c5:b0:493:bc4b:b8c with SMTP id 5b1f17b1804b1-493c3df3541mr15223095e9.38.1782917581187; Wed, 01 Jul 2026 07:53:01 -0700 (PDT) Received: from ?IPV6:2a0d:3344:5521:6b10:2eb7:f61a:75:4534? ([2a0d:3344:5521:6b10:2eb7:f61a:75:4534]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493bfe616f5sm38773975e9.1.2026.07.01.07.52.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Jul 2026 07:53:00 -0700 (PDT) Message-ID: <2e617b47-2209-44ed-89e8-94a7f67b356a@redhat.com> Date: Wed, 1 Jul 2026 16:52:58 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] xsk: fix memory corruptions in net/core/xdp.c To: Clement Lecigne , "Fijalkowski, Maciej" Cc: "Lobakin, Aleksander" , "edumazet@google.com" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "kuba@kernel.org" , "sdf@fomichev.me" , "horms@kernel.org" , "john.fastabend@gmail.com" , "ast@kernel.org" , "daniel@iogearbox.net" References: <20260629072300.1664622-1-clecigne@google.com> From: Paolo Abeni Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 6/29/26 1:15 PM, Clement Lecigne wrote: > On Mon, Jun 29, 2026 at 12:34 PM Fijalkowski, Maciej > wrote: >> >>> >>> From: Clément Lecigne >>> >>> Commit 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb conversion") >>> introduced a vulnerability in the handling of XDP_PASS for AF_XDP zero-copy >>> frames. >>> >>> Note: Currently, this specific AF_XDP zero-copy conversion path is only >>> reachable from the drivers/net/ethernet/intel/ice and >>> drivers/net/ethernet/intel/idpf drivers. >>> >>> When building an skb, xdp_build_skb_from_zc() uses the chunk size >>> (xdp->frame_sz) for the allocation. However, napi_build_skb() automatically >>> reserves space at the end of the allocation for the skb_shared_info >>> structure. >>> >>> Most high performance UMEM applications use 4K chunks, where the >>> corruption cannot happen. However, if the UMEM is configured with 2KB >>> chunks (a very common configuration to maximize packet density in memory), >>> a standard 1500 MTU packet will trigger the corruption because the required >>> space exceeds the 2048 byte chunk size: >>> >>> Headroom (256) + Packet (1514) + skb_shared_info (320) = 2090 bytes >>> >>> Because 2090 bytes > 2048 bytes and __skb_put() does not perform bounds >>> checking, the memcpy() writes past the available linear data area and >>> corrupts the skb_shared_info structure. This can lead to arbitrary code >>> execution if pointers like destructor_arg are overwritten. >>> >>> Additionally, in xdp_copy_frags_from_zc(), the allocation size is set >>> strictly to the fragment size (len), but the subsequent memcpy() uses >>> LARGEST_ALIGN(len). This mismatch results in an out-of-bounds write of >>> up to 7 bytes, which triggers KASAN warnings and is unsafe despite typical >>> page pool allocator padding. >>> >>> Fix the skb allocation in xdp_build_skb_from_zc() by dynamically >>> calculating the exact truesize required using SKB_HEAD_ALIGN() to >>> properly account for the headroom, the LARGEST_ALIGN(len), and the >>> skb_shared_info overhead. >>> >>> Fix the out-of-bounds write in xdp_copy_frags_from_zc() by rounding up >>> the allocation request using LARGEST_ALIGN(len) to match the copy >>> operation. >>> >>> Fixes: 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb conversion") >>> CC: Alexander Lobakin >>> CC: Eric Dumazet >>> Signed-off-by: Clément Lecigne >> >> Hi Clement, >> >> Do you have a reproducer for mentioned issue or is it only a fix from >> theoretical POV? >> >> To be clear, we were addressing headroom issues in this series: >> https://lore.kernel.org/bpf/20260402154958.562179-1-maciej.fijalkowski@intel.com/ >> >> so I wanted to ask if you are able to have this malformed setup for >> 2k chunk size. That series should not allow for that. > > I didn't manage to build a malformed setup and only used a LKM to reproduce > the issue artificially. Note that we don't accept patches addressing issue for OoT modules. I read you reply as the critical setup can't be obtained with the vanilla tree. Please clarify otherwise. /P