From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC7493DA7F8 for ; Wed, 15 Apr 2026 15:24:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776266660; cv=none; b=rmEq635vPEWW2a+TJwSkpKDjkd/5e97wdEKp1u80G4NyNanfEJr2+ieAC4VmwZb6N2bSF08z/UHJR43IWihw1fOZIYt4YxOxoa3hygInqhI6a0C+38yNQ/9jGAsglWAYw5sdUW7/ukcROdV08D5NvOUzneD0nxDBFr6vTt71oaE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776266660; c=relaxed/simple; bh=vjc6ewOixUAkEFbKufZxohywyup7gceJzPn8Lf06IiM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rIqSMU4SbnHbNPXxNjXY4vK8PFmq/rhUb3c4WPuyhGHtdoUnyjBacPPZFLiOz1+ZUPOK6Dc3MAxhjoklOp+zuD7JqiRCJkNrExHJEYzKe1steJYMX2UIs0iGdh89cRzbYEYOw3hQ4SA1Mm0UEhGxz1UDu+5/EJkOWteQMwT7t9w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QSuh7l/r; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QSuh7l/r" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-488a88aeec9so92331415e9.2 for ; Wed, 15 Apr 2026 08:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776266655; x=1776871455; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1sRBIoBJHuDYE6CTHJ4z2pA/y9OruR1tPFVV/uxkhD8=; b=QSuh7l/rtLoo4ReT2LtqWbFs19cI6pq3o7Na9g9eQqUEpIiiI4i7ziny4j/f/gWeC8 VkYdTQ+ccz5mkJ3K/NzayV928pMEmRayFSz2bmRZIfKPcCYOUomt+BffKzvAL1yDQIgc qGeRKS37HEz4C/oM532YhPMri0Ytd/zNR6j1x/uoYzDL7M7kREPCknipc5UciQB4JRLj b1+zMJCGoHDg7e8JOfoiNyJlCvSBt5O6O2xQwnxlG1GUHjFJXg8GDw77EDradcSakQsi YT9XwaxaaxQpaydDIYk+YoWU+aMEpx3ksc+SWI5TnUwCZmTEC8XHKX/Lj9zyfx6QLO/0 Sh3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776266655; x=1776871455; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1sRBIoBJHuDYE6CTHJ4z2pA/y9OruR1tPFVV/uxkhD8=; b=Sqlit55kqc8uv2ybjXZUlg3QL1IHs8jqjD7ja8U6v+yK1acDGZMDpMmVWr5/lDT243 fej9kR24Ly7zngcJMjZPXn//yjUa9uD4oD4eFshhCxAnb6qB6S9CVc+UTW9IyOC+QTQp VG4dnGGuuAPAEVB++gODw4c1OF8WMj10V/VJ10OjJw9s9FpcMKrwX70CSRyXqhogxsiB 1owHR0ZatXpO4HZkzMmxfyQah9vRHszrVNkV41giEMPVULHOcI8DzaV+Nrre0Zp6w4YS QC8P5w9bBzB/GSy4PZEgBmRCfmP373v4L8gdn7p3iPP0kWvAU0OHCFHdzgJ/0u5YJavX WvYQ== X-Forwarded-Encrypted: i=1; AFNElJ+FViSFKCfbJAo7oXBfyZKLqFniI0cF4oiBZwYA1kPuj1YUIVGtucwsvr/wYeuVhSeH3RRTT4Elr1UB3nk=@vger.kernel.org X-Gm-Message-State: AOJu0YxM35pALGhBiwzK8qw9yrKpBJLErMDjPyAlrGxzyw8fwHe4PRj0 sdyn29tsaqwCfsKygu1oGWagEDOvkqkNb9+YcI6HIkbuLsGbCguS/1NV X-Gm-Gg: AeBDiet6AFrdiz/hbcYF8Qu1knsOSlfAGzF25RcEY4gnFw7nnnZEbhBODpbVPKecDX8 iDDfOkONdGB+DlGXne75Ds/ND+NrWXoaYdEbDD5/kbjFkXiHHgNsWov1cNE2Q0yLXb3+NMtgLcK f5xg6KcxLXZo7Wr8UCh2RzzrNk4k7qaic3NoVGAy0QNW87NuQ2V/bgiLn11UPDZcTZIzdjrQp8t nKTTVDrXD8HPmsC5jq0yyjqD7W47BKI/X1RtrHC7dvtpGWRIy3tP4oFnub3GXGxORziYSIYJA9k x0QX+7/+gGXdF2hOhJvBqR18r+JvB7G7a01T3Rrof9yb3BsZ5uNPQZmpaAUIbmDK2w1mCzLu4/6 aEOJbe08k1v/iw1i6+KFK/+VModYxfh8+EJ3oUYQrYwifoKKtbtecvuuLTAXzQMYmo2UP8C0hzY yl887cxxpBc2KLtRf5SPI= X-Received: by 2002:a05:600c:820a:b0:488:81b1:ae36 with SMTP id 5b1f17b1804b1-488d688688fmr309421925e9.23.1776266655063; Wed, 15 Apr 2026 08:24:15 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488f1dd87a6sm54988135e9.2.2026.04.15.08.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2026 08:24:14 -0700 (PDT) Date: Wed, 15 Apr 2026 18:24:10 +0300 From: Dan Carpenter To: Delene Tchio Romuald Cc: gregkh@linuxfoundation.org, Ethan Tidmore , Sam Daly , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag() Message-ID: References: <20260405101548.124829-1-delenetchior1@gmail.com> <20260405101548.124829-2-delenetchior1@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260405101548.124829-2-delenetchior1@gmail.com> On Sun, Apr 05, 2026 at 11:15:44AM +0100, Delene Tchio Romuald wrote: > In recvframe_defrag(), a memcpy() copies fragment data into the > reassembly buffer before recvframe_put() validates that the buffer > has sufficient space. If the total reassembled payload exceeds the > receive buffer capacity, this results in a heap buffer overflow. > > An attacker within WiFi radio range can exploit this by sending > crafted 802.11 fragmented frames. No authentication is required. > > Add a bounds check before the memcpy() to verify that the fragment > payload fits within the remaining buffer space, using the same error > handling pattern already present in the function. > > Found by reviewing memory operations in the driver and tracing > buffer pointer manipulation through rtw_recv.h inline helpers. > Not tested on hardware. > > Signed-off-by: Delene Tchio Romuald > --- > v3: > - Rebased on staging-next > - Sent as numbered series with proper Cc from get_maintainer.pl > v2: > - Rebased on staging-next (v1 was based on v7.0-rc6 and did not apply) > - Removed Cc: stable (will be added by maintainer) Wait, what? That used to be a thing in net, I don't know if it still is a rule there but so far as I know, it's not a rule in staging. I made checkpatch complain if you CC stable but you don't have a Fixes tag. Could that be what you're talking about? A bunch of people have asked for Fixes tags on these patches as well. Please, do that? :P > > drivers/staging/rtl8723bs/core/rtw_recv.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c > index f78194d508dfc..717e0594d983a 100644 > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c > @@ -1132,7 +1132,13 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, > /* append to first fragment frame's tail (if privacy frame, pull the ICV) */ > recvframe_pull_tail(prframe, pfhdr->attrib.icv_len); There is no error checking on these pull calls. They're supposed to return NULL if pfhdr->attrib.icv_len is too big. (There is a similar caller earlier on the line before). > > - /* memcpy */ > + /* Verify the receiving buffer has enough space for the fragment */ > + if (pnfhdr->len > (uint)(pfhdr->rx_end - pfhdr->rx_tail)) { Remove the unnecessary cast. Otherwise it looks good to me. regards, dan carpenter > + rtw_free_recvframe(prframe, pfree_recv_queue); > + rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); > + return NULL; > + } > + > memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len); > > recvframe_put(prframe, pnfhdr->len); > -- > 2.43.0 >