From patchwork Tue Jan 18 19:33:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 12716825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3251C433F5 for ; Tue, 18 Jan 2022 19:33:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348501AbiARTda (ORCPT ); Tue, 18 Jan 2022 14:33:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348760AbiARTda (ORCPT ); Tue, 18 Jan 2022 14:33:30 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E28DDC06173F for ; Tue, 18 Jan 2022 11:33:29 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id n16-20020a17090a091000b001b46196d572so263242pjn.5 for ; Tue, 18 Jan 2022 11:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EtNhvDKyXQZ6Jo36sZZYMctRg/Y7isVGvsp0Av2OLNI=; b=BdL5H9cYY+49MxXn/iNc78kLpAnP1DypS2/R4UfayzZ09NM0ONhgKl+LRx0Gu3cakI K2K8w8c1rNuqroSg3BXmfl7zGIaeGTmES1D0niOyRHVWEoDGR3RzsWZGNO/sigNlPpwV thDIWoCH/zMpN59d549rmUf5ock/JsxhOy67o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EtNhvDKyXQZ6Jo36sZZYMctRg/Y7isVGvsp0Av2OLNI=; b=53QRwT5hVT70fc2wxF8LrWc2O/TYyo4dZ1s1jq1P2bmXEvvE1lkSmJxKNeY0n73ass WyaTKfuKS0ut39RB50oVd4nJe3ephxs4gHiD0KqfYT9Sgcj6v9pNj2jKmpcSf8awdPt+ AaJh0K+WJbaQpmluYkMlAgJ7tIlTvkJ1eW0CABOMdTYeYOqnjZUX9Xi3imT3x/XDaZIR dsRGU3Pse3i025+F3rlQ4p3rLqgiU4GU6+2dZuCDcQDtsIhN1786QnIdqocUWpE9COjd BjHJ4IHq12GEsWj+sYfZSQd/lTSXwB5lVT1UdNlae/xAaeDCB37DPY8qbE/sluyjtUaR 6vjg== X-Gm-Message-State: AOAM533dz7S0ZTGvdpo3HwlE/OfBfNqduVriFcVTGwKd3PFBudnPDwF6 irRdJ2E26zGtMqXgHNYGUFZNOg== X-Google-Smtp-Source: ABdhPJwgE8jcCT3labTDwao+nHGvfWqRwKzFNqt9hExsgXilGxYF0m09Y3u3MTDb4o9vay68AQtaOw== X-Received: by 2002:a17:902:aa4b:b0:14a:cff4:19ec with SMTP id c11-20020a170902aa4b00b0014acff419ecmr5946219plr.60.1642534409435; Tue, 18 Jan 2022 11:33:29 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 25sm3508985pje.22.2022.01.18.11.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 11:33:29 -0800 (PST) From: Kees Cook To: Greg Kroah-Hartman Cc: Kees Cook , Larry Finger , Phillip Potter , Michael Straube , Fabio Aiuto , linux-staging@lists.linux.dev, Florian Schilhabel , Christophe JAILLET , Zhansaya Bagdauletkyzy , Ivan Safonov , Martin Kaiser , Yang Li , Nathan Chancellor , Hans de Goede , Dan Carpenter , Marco Cesati , Joe Perches , "Fabio M. De Francesco" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v3 1/3] staging: r8188eu: Drop get_recvframe_data() Date: Tue, 18 Jan 2022 11:33:25 -0800 Message-Id: <20220118193327.2822099-2-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118193327.2822099-1-keescook@chromium.org> References: <20220118193327.2822099-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4934; h=from:subject; bh=91pfgNSNKQZ90Z5sOLt9nzmWsWo2UUEN0XKGD4U7vGE=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBh5xYFlQv2coVuKsjKL2V15ndg7Erkujlv2Soj3VY3 WBrgQfuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYecWBQAKCRCJcvTf3G3AJnjaEA CynCag1EmCrN2PCAl/92wBGlf4AvWgcHIHj6wnKvOw5aWiYVAqAo1X8Qwi+EKTR5MZUut7Q5EMdIHW uJ9QmMBEn3KKzX7RPfIWkz5winwPnvc7Xbue6U01mHxVkSjoh/aBuI8Whk4xxHll/onynWc9S3NwTR ciSzWlzxLnjr5FD4FLKHTvn3Ma8ggFIY+Hduqjud3Xyhpp74zl3dS7nt3YD1Zy/cAIq4RwXjkEqrgZ qVdnn/CZezaCzhRqkkRMA8x50L3spzYIK+1J9HxHDNkRuXWTv4Y8cznBKyzXPKmlNN0TMYU36RADnz SZc3tBVZeWsz9TWOFrEqfh/zCf7VdN51lJF63PljlnOHi3LOgvVlKHLDwpjPDThBwTX17uvKqdnAFE xTHa/z83bIofJg3uHxPOiF9eTP/O6rX4k/ggqxipSX0ow0xiDVVHIc17ypBm7SfunZFrYF3wRUttiB cqQENioI3v+tVIo996Y4NrODehhbe10kuEYQ2PQVnW8L4pHprLF6wjHVx8pMK4J+PANzx1I1xMihtO h6QaBVEeK+MD0imfaKC8ZlFG687xOOogHzI/TlYP2/fhLBRwJJtuiID1hhZ4zELVH3E1fYSmkVJ2gp VQ02QBXboNpzL+1REJ+FQn45ylj2NyFBAv27HMc56y3ATUMeX7fOGCHW6GvQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org When building with -Warray-bounds, the following warning is emitted: In file included from ./include/linux/string.h:253, from ./arch/x86/include/asm/page_32.h:22, from ./arch/x86/include/asm/page.h:14, from ./arch/x86/include/asm/thread_info.h:12, from ./include/linux/thread_info.h:60, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:78, from ./include/linux/rcupdate.h:27, from ./include/linux/rculist.h:11, from ./include/linux/sched/signal.h:5, from ./drivers/staging/rtl8723bs/include/drv_types.h:17, from drivers/staging/rtl8723bs/core/rtw_recv.c:7: In function 'memcpy', inlined from 'wlanhdr_to_ethhdr' at drivers/staging/rtl8723bs/core/rtw_recv.c:1554:2: ./include/linux/fortify-string.h:41:33: warning: '__builtin_memcpy' offset [0, 5] is out of the bounds [0, 0] [-Warray-bounds] 41 | #define __underlying_memcpy __builtin_memcpy | ^ This is because the compiler sees it is possible for "ptr" to be a NULL value, and concludes that it has zero size and attempts to copy to it would overflow. Instead, remove the get_recvframe_data() entirely, as it's not possible for this to ever be NULL. Additionally add missing NULL checks after recvframe_pull() (which are present in the rtl8712 driver). Cc: Larry Finger Cc: Phillip Potter Cc: Greg Kroah-Hartman Cc: Michael Straube Cc: Fabio Aiuto Cc: linux-staging@lists.linux.dev Signed-off-by: Kees Cook --- drivers/staging/r8188eu/core/rtw_recv.c | 6 +++++- drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 4 +--- drivers/staging/r8188eu/include/rtw_recv.h | 9 --------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 51a13262a226..946e659ae97a 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -1188,7 +1188,7 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) struct adapter *adapter = precvframe->adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - u8 *ptr = get_recvframe_data(precvframe); /* point to frame_ctrl field */ + u8 *ptr = precvframe->rx_data; /* point to frame_ctrl field */ struct rx_pkt_attrib *pattrib = &precvframe->attrib; if (pattrib->encrypt) @@ -1223,10 +1223,14 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) eth_type = 0x8712; /* append rx status for mp test packets */ ptr = recvframe_pull(precvframe, (rmv_len - sizeof(struct ethhdr) + 2) - 24); + if (!ptr) + return _FAIL; memcpy(ptr, get_rxmem(precvframe), 24); ptr += 24; } else { ptr = recvframe_pull(precvframe, (rmv_len - sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0))); + if (!ptr) + return _FAIL; } memcpy(ptr, pattrib->dst, ETH_ALEN); diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c index 90d426199f52..bf93ff3af140 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c @@ -128,7 +128,7 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, struct phy_stat struct rx_pkt_attrib *pattrib = &precvframe->attrib; struct hal_data_8188e *pHalData = &padapter->haldata; struct phy_info *pPHYInfo = &pattrib->phy_info; - u8 *wlanhdr; + u8 *wlanhdr = precvframe->rx_data; struct odm_per_pkt_info pkt_info; u8 *sa = NULL; struct sta_priv *pstapriv; @@ -138,8 +138,6 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, struct phy_stat pkt_info.bPacketToSelf = false; pkt_info.bPacketBeacon = false; - wlanhdr = get_recvframe_data(precvframe); - pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) && !pattrib->icv_err && !pattrib->crc_err && !memcmp(get_hdr_bssid(wlanhdr), diff --git a/drivers/staging/r8188eu/include/rtw_recv.h b/drivers/staging/r8188eu/include/rtw_recv.h index b43a46887343..920f33235e00 100644 --- a/drivers/staging/r8188eu/include/rtw_recv.h +++ b/drivers/staging/r8188eu/include/rtw_recv.h @@ -296,15 +296,6 @@ static inline u8 *get_rx_status(struct recv_frame *precvframe) return get_rxmem(precvframe); } -static inline u8 *get_recvframe_data(struct recv_frame *precvframe) -{ - /* always return rx_data */ - if (precvframe == NULL) - return NULL; - - return precvframe->rx_data; -} - static inline u8 *recvframe_push(struct recv_frame *precvframe, int sz) { /* append data before rx_data */ From patchwork Tue Jan 18 19:33:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 12716828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 629B4C4332F for ; Tue, 18 Jan 2022 19:33:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348749AbiARTde (ORCPT ); Tue, 18 Jan 2022 14:33:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348768AbiARTda (ORCPT ); Tue, 18 Jan 2022 14:33:30 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25B2FC061749 for ; Tue, 18 Jan 2022 11:33:30 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id o64so274956pjo.2 for ; Tue, 18 Jan 2022 11:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aqX8dLAZk8wfc9NVjjSeOsdVYBfiblTeQKsEfk0Fjss=; b=XvICBIfInqBnoQKXRCnh+jMizVc1BJ/LqR/HbC+DCiPY4ODJx7pUDBy3bwYPLW7G1z g2vBeVHFvcmNJAoW0RKG79PAoDxvCtw1jAdzQrBG52Tw1TBmzvfLkkvfKYYb9a+6TJpr CauKKebA7W0rR1F5QodXJ3pR6yTlVTGALUAVw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aqX8dLAZk8wfc9NVjjSeOsdVYBfiblTeQKsEfk0Fjss=; b=Ime/PP7uyrbjtCUNurTgs8fDEImF9ggz7R44YAiCHAwbcXVogTy9D0za3QAz9ZGu48 bJL4z1Sbee2R0YdWP56j/aEjeh9DvNzc2QO88XjOovoPyid783paynvhNJBC3TNsnuKo qj1/ljodlUdDolw4MIkNUBlsatlC1N5huo8GqfBOFWrmE8CbY9gNa8XoAXGVXf1cdNKX 1OMZZY5qzUUt+itHk8D3Te6FfZ7TDTYu4rvlr7XnhNJslY1I1/fpfeoOfcHR6f5v/8Yu IGfpDAzXGUWFxXKm8lR9fXBXCWBQzccopcE0qtBV49uCsDAr0MDL1YxrYr2dSIiX8InW DhEQ== X-Gm-Message-State: AOAM530HASJu7E8V4anercnGzS4sILPtAnrYbGUU9oRNWbR4p98hir5E a6xMPLwatUuN7INJE68M30kE5w== X-Google-Smtp-Source: ABdhPJwU6yiePnJ9CTwtfjgrkn0os5MnxJeX8V5zhEo4TiSJFvZi/O/uKQo0nhs7FrcZRzy7jWp99Q== X-Received: by 2002:a17:90b:4b07:: with SMTP id lx7mr54874pjb.115.1642534409706; Tue, 18 Jan 2022 11:33:29 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id i11sm15581824pgt.68.2022.01.18.11.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 11:33:29 -0800 (PST) From: Kees Cook To: Greg Kroah-Hartman Cc: Kees Cook , Larry Finger , Phillip Potter , Michael Straube , Fabio Aiuto , linux-staging@lists.linux.dev, Florian Schilhabel , Christophe JAILLET , Zhansaya Bagdauletkyzy , Ivan Safonov , Martin Kaiser , Yang Li , Nathan Chancellor , Hans de Goede , Dan Carpenter , Marco Cesati , Joe Perches , "Fabio M. De Francesco" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v3 2/3] staging: rtl8723bs: Drop get_recvframe_data() Date: Tue, 18 Jan 2022 11:33:26 -0800 Message-Id: <20220118193327.2822099-3-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118193327.2822099-1-keescook@chromium.org> References: <20220118193327.2822099-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5268; h=from:subject; bh=ibysZA3Vsz9MiNMr6rGOGIbY1SMbUQc0iY8tYFGxqvE=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBh5xYFV20uWNTLjehe9N+JdiBXmh+Hsq1bR5aQ4fMw ff3gYgGJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYecWBQAKCRCJcvTf3G3AJprJD/ 4ltN1DpOJHvt+JLFjQCfe3dGV8uLWTfTcNnDe/mNhoZS+gp7yH4bb+KHC9UdPIXjbQNFNcwebtdJgF /ViDS3Aj3RtlgHSA1FPzisXBkEH8W9rIpMLFkwP45A+5dAxmijTY0s+2DYzJ2lZyGctH4Oq6tIHiA6 pJdTQtOocXEOAVoJg79iu6k/qJmkq52DgLfuU2oqVY35bxGWDh24arhvhjvclcBeyuc18cC5oS+Cqm BhdnkwrTZPigJaQHg1+TWcIj7qhLf4yFk49SO850Sm6pMCkoQyo9LfoD9yxIMWbEpiOr8zx2BlR7WI YUZtuV2gElL1RGZmlHkCCHSArr94V2++re5cHqblywGFwpdmmoUfHV0tHPNrRDLlH+VZqrbh2M0ifr AyIeyybyfdA8rECmBcYBSHdSaMHzgOtTOngGh1sH3oZ5QmRKOzTB3lhLkpvS4D579TmdNVY9Lg35CR M5Zbo8OpnYfVxG+VweQj9NPDGPNCJSvisBz+F/BAU2YsIfJBrw7yfmu/xOa/SY5jktAgz7SAA96cDN d9ugDYT/s47SFTI750cdcygYVIkrtpsRU4Vca4MLtd7SlYvk+Zf5N6hnSXLP8j5kKETfAmM+Lnn7OA F4dp0qIxxHK8NzvCVgaTMA8vSrqhfSA4r9LPnAVA4FMusUpKEIuM42KoYd4g== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org When building with -Warray-bounds, the following warning is emitted: In file included from ./include/linux/string.h:253, from ./arch/x86/include/asm/page_32.h:22, from ./arch/x86/include/asm/page.h:14, from ./arch/x86/include/asm/thread_info.h:12, from ./include/linux/thread_info.h:60, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:78, from ./include/linux/rcupdate.h:27, from ./include/linux/rculist.h:11, from ./include/linux/sched/signal.h:5, from ./drivers/staging/rtl8723bs/include/drv_types.h:17, from drivers/staging/rtl8723bs/core/rtw_recv.c:7: In function 'memcpy', inlined from 'wlanhdr_to_ethhdr' at drivers/staging/rtl8723bs/core/rtw_recv.c:1554:2: ./include/linux/fortify-string.h:41:33: warning: '__builtin_memcpy' offset [0, 5] is out of the bounds [0, 0] [-Warray-bounds] 41 | #define __underlying_memcpy __builtin_memcpy | ^ This is because the compiler sees it is possible for "ptr" to be a NULL value, and concludes that it has zero size and attempts to copy to it would overflow. Instead, remove the get_recvframe_data() entirely, as it's not possible for this to ever be NULL. Additionally add missing NULL checks after recvframe_pull() (which are present in the rtl8712 driver). Cc: Larry Finger Cc: Phillip Potter Cc: Greg Kroah-Hartman Cc: Michael Straube Cc: Fabio Aiuto Cc: linux-staging@lists.linux.dev Signed-off-by: Kees Cook --- drivers/staging/rtl8723bs/core/rtw_recv.c | 11 ++++++++--- drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 3 +-- drivers/staging/rtl8723bs/include/rtw_recv.h | 11 ----------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 41bfca549c64..36a50bccef08 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -465,7 +465,7 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre auth_alg = adapter->securitypriv.dot11AuthAlgrthm; - ptr = get_recvframe_data(precv_frame); + ptr = precv_frame->u.hdr.rx_data; pfhdr = &precv_frame->u.hdr; pattrib = &pfhdr->attrib; psta_addr = pattrib->ta; @@ -1510,7 +1510,7 @@ static signed int wlanhdr_to_ethhdr(union recv_frame *precvframe) __be16 be_tmp; struct adapter *adapter = precvframe->u.hdr.adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - u8 *ptr = get_recvframe_data(precvframe) ; /* point to frame_ctrl field */ + u8 *ptr = precvframe->u.hdr.rx_data; /* point to frame_ctrl field */ struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; if (pattrib->encrypt) @@ -1546,10 +1546,15 @@ static signed int wlanhdr_to_ethhdr(union recv_frame *precvframe) eth_type = 0x8712; /* append rx status for mp test packets */ ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr)+2)-24); + if (!ptr) + return _FAIL; memcpy(ptr, get_rxmem(precvframe), 24); ptr += 24; - } else + } else { ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr) + (bsnaphdr?2:0))); + if (!ptr) + return _FAIL; + } memcpy(ptr, pattrib->dst, ETH_ALEN); memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index c0a1a6fbeb91..74e75dc970f7 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c @@ -81,7 +81,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe, struct odm_phy_info *p_phy_info = (struct odm_phy_info *)(&pattrib->phy_info); - u8 *wlanhdr; + u8 *wlanhdr = precvframe->u.hdr.rx_data; u8 *my_bssid; u8 *rx_bssid; u8 *rx_ra; @@ -100,7 +100,6 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe, struct sta_priv *pstapriv; struct sta_info *psta; - wlanhdr = get_recvframe_data(precvframe); my_bssid = get_bssid(&padapter->mlmepriv); rx_bssid = get_hdr_bssid(wlanhdr); pkt_info.bssid_match = ((!IsFrameTypeCtrl(wlanhdr)) && diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h index a88b7c088a86..44f67103503a 100644 --- a/drivers/staging/rtl8723bs/include/rtw_recv.h +++ b/drivers/staging/rtl8723bs/include/rtw_recv.h @@ -385,17 +385,6 @@ static inline u8 *get_rxmem(union recv_frame *precvframe) return precvframe->u.hdr.rx_head; } -static inline u8 *get_recvframe_data(union recv_frame *precvframe) -{ - - /* alwasy return rx_data */ - if (precvframe == NULL) - return NULL; - - return precvframe->u.hdr.rx_data; - -} - static inline u8 *recvframe_pull(union recv_frame *precvframe, signed int sz) { /* rx_data += sz; move rx_data sz bytes hereafter */ From patchwork Tue Jan 18 19:33:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 12716827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 778B0C43217 for ; Tue, 18 Jan 2022 19:33:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348804AbiARTde (ORCPT ); Tue, 18 Jan 2022 14:33:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348764AbiARTda (ORCPT ); Tue, 18 Jan 2022 14:33:30 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17AAAC061747 for ; Tue, 18 Jan 2022 11:33:30 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id w204so265208pfc.7 for ; Tue, 18 Jan 2022 11:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JVJkLfE2tUggtTCpMG+tdwRyZZTh5Rd5QGL9vpP/ZEg=; b=g721b9PV5pFDMLvhDVYCpBc5RAeNBuEMEgE7jfHljCciVS5a7sPVyQfknRKnLE/uoC l8lo2bAthTzW9tc3GPlzRHy9Q6jdlxn5H/PoIJcJel6+UvGKsYePd13MmKiq5FUSMzJy tnfGuKlV5r5/hEMZUm3hVbQ01LyRllYNMm3zI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JVJkLfE2tUggtTCpMG+tdwRyZZTh5Rd5QGL9vpP/ZEg=; b=HbPoMNeO7hUlbufxN7Ibty0HYsPe+HFmsO92gfiNRXIUOj41Ev9Ya9BZMqn1OEOMrY PBLRBr42s5zoNKARqHdHz48aplg1WGhBcnL+tIJcqLu1tqIQELbmbL+8ebaAenFHHf18 Ctc+dmdisRaJE2oSp5I4e/FmwS5JCEBALrzTkcHZ/JZdyCg+5RwcQM4E6P0zDQfweVHd x9YkWwR+u5MdPchpsMqV7i4SI98gZWjJ3iokC1CSdQXdaB0oESpG+BSYhaD/pL2qQbI9 pmdxcBiZgAsjeLA0hY7eGYK6py3D3OTUcFFqDgCLMD0kdCIn3ZMbRpBCi2T8Esf+J9iD T0LA== X-Gm-Message-State: AOAM531hHeSguZ2eIoL4+yT83gAk+0dhV9pyi1fFk0zwnL5NNfqcvMWE OHSHHz3IK5YGhNLm79zHBS61bg== X-Google-Smtp-Source: ABdhPJyEpZi3+z7FY8aNfNGNuIAHQjLjmRXWbGHQpeZ+vsxoVZNYr7DUZ1yUs4/fDXulosSry5M7OA== X-Received: by 2002:a62:8288:0:b0:4bf:9105:9b90 with SMTP id w130-20020a628288000000b004bf91059b90mr27379160pfd.37.1642534409560; Tue, 18 Jan 2022 11:33:29 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id ip2sm3454254pjb.11.2022.01.18.11.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 11:33:29 -0800 (PST) From: Kees Cook To: Greg Kroah-Hartman Cc: Kees Cook , Larry Finger , Florian Schilhabel , Christophe JAILLET , Zhansaya Bagdauletkyzy , Ivan Safonov , linux-staging@lists.linux.dev, Phillip Potter , Michael Straube , Fabio Aiuto , Martin Kaiser , Yang Li , Nathan Chancellor , Hans de Goede , Dan Carpenter , Marco Cesati , Joe Perches , "Fabio M. De Francesco" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v3 3/3] staging: rtl8712: Drop get_recvframe_data() Date: Tue, 18 Jan 2022 11:33:27 -0800 Message-Id: <20220118193327.2822099-4-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118193327.2822099-1-keescook@chromium.org> References: <20220118193327.2822099-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2445; h=from:subject; bh=XHDbZYvHjtX5XE+fvqLot3IPxWTcVvutOvUckzfUyJE=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBh5xYGpjf+WvdMrHHu3ltX7bJM0Si0bgtIKG4p1vX5 Md4EugCJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYecWBgAKCRCJcvTf3G3AJpcMEA CMnOnxa3aOF4a14rLvcHN/2u9L+e1WKONG8TQ5Jkv75xlfriXHKkzVuqSbunj+byUJfFzgZ6Pby3nN ltgaKKPmNCXvWg1hDGEDZj8DmL9ZMdJC1qALqCW7Q6FYQHNDJvjgZ5P6TmriQ/FVUQjZJfpEvz8kH+ fb9dpZgKFQCKU7uH2N+sWbJuJMaBgSvDx/PdixZDRGIkQohyJiZuFb7OOSEZD3db74riqroawj4/+F U0PP1B4ugRx7J2TyL3MFIkZnqEmp8o259E3gKDYZZ65ssw6lgIctZGPfKSr5Jj0+5uJbyPioVk5tOI otshCsPa1JrDybMNg9HRhUyNjG/3TvHMHRpNec5Arql/eBdw6rPPgxG/F5KY8XTKJdqS289MWq1mjZ dzoKwt2RMTpeFlc2SCM2RvVeBILrvGPpMErJBht6WjcRIMCgDeqVWA/GhkGAiKv0JZdO9GrcDZ8B75 IwhBwcP4Y9JIb5iEWD8k6Vou4soh3OEUAwPqqtPIzURVNJPpoLSbTVNADAxf3p9eoaXpr7C5HL7mvD PX6uVGkWWr0njpoZYVbY4jjtip4Rjj6E0XhZw5WyEhECyxnLZNgZul4YSfQe74nYUTACVHz6way8SK fTvYtglk10Ra2bE+kencV7d+XFT2Kh71hFejbcxV98EKFycOLabhiQ35d+zQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org As done for rtl8723bs and r8188eu, drop get_recvframe_data(), as it introduces an impossible value (NULL) for the compiler to check code paths against which could result in nonsensical warnings. Cc: Larry Finger Cc: Florian Schilhabel Cc: Greg Kroah-Hartman Cc: Christophe JAILLET Cc: Zhansaya Bagdauletkyzy Cc: Ivan Safonov Cc: linux-staging@lists.linux.dev Signed-off-by: Kees Cook --- drivers/staging/rtl8712/rtl871x_recv.c | 4 ++-- drivers/staging/rtl8712/rtl871x_recv.h | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c index c23f6b376111..66cc50f24e29 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.c +++ b/drivers/staging/rtl8712/rtl871x_recv.c @@ -234,7 +234,7 @@ union recv_frame *r8712_portctrl(struct _adapter *adapter, u16 ether_type; pstapriv = &adapter->stapriv; - ptr = get_recvframe_data(precv_frame); + ptr = precv_frame->u.hdr.rx_data; pfhdr = &precv_frame->u.hdr; psta_addr = pfhdr->attrib.ta; psta = r8712_get_stainfo(pstapriv, psta_addr); @@ -593,7 +593,7 @@ int r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe) struct _adapter *adapter = precvframe->u.hdr.adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - u8 *ptr = get_recvframe_data(precvframe); /*point to frame_ctrl field*/ + u8 *ptr = precvframe->u.hdr.rx_data; /*point to frame_ctrl field*/ struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; if (pattrib->encrypt) diff --git a/drivers/staging/rtl8712/rtl871x_recv.h b/drivers/staging/rtl8712/rtl871x_recv.h index 1c8298bde033..0760bccbf389 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.h +++ b/drivers/staging/rtl8712/rtl871x_recv.h @@ -139,14 +139,6 @@ static inline u8 *get_rxmem(union recv_frame *precvframe) return precvframe->u.hdr.rx_head; } -static inline u8 *get_recvframe_data(union recv_frame *precvframe) -{ - /* always return rx_data */ - if (!precvframe) - return NULL; - return precvframe->u.hdr.rx_data; -} - static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz) { /* used for extract sz bytes from rx_data, update rx_data and return