From patchwork Sat Jan 15 04:24: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: 12714318 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 34539C4332F for ; Sat, 15 Jan 2022 04:24:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232463AbiAOEYn (ORCPT ); Fri, 14 Jan 2022 23:24:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230334AbiAOEYa (ORCPT ); Fri, 14 Jan 2022 23:24:30 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF3A9C061574 for ; Fri, 14 Jan 2022 20:24:30 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id 128so4530155pfe.12 for ; Fri, 14 Jan 2022 20:24: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=EtNhvDKyXQZ6Jo36sZZYMctRg/Y7isVGvsp0Av2OLNI=; b=hUzYCGC55NH+cf3c7waBsuULipT4Kpa+W+PA6ihbTRK8lLC1JncQ1OMXHYRbROa0zh OUzv4bFaAIKnuyK/uvPaI7YxbRKSxMKkgFIqg2n9QlkWLPo4sIsWOLmi7EMma/m0sahy zThEmlNRip4lD3IG4ClYwZ2LyVwmVEvoF9OMc= 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=z+0U3Psru0AEWpM7zuelcul8hlO7s2IsiB1HUlMWgbbHC5yYauoo3SFhjAUqls15sT Dkfldf+jAhtoApP+kZxQ8wtjP35qGXKRkV86Rct4nMiKdvlH7PwM02lFstKFrjL0m8Zg cLbawKtDj+ZVcy/cdCT2t1fUnBAv9XNsGpHS2oKPl8R8DffbK9htH24UMavM4XxKVwQn +BQqxLRNtWOUtySQZmSFjKfrIEFgr7Pv2ojXHwamtcUnGPMSa1GLJQJl3m3Bb3dDj06i 9tP0nvxq0W0A/Lh82RkEnOyorck+4M974ibACpRxio72aE8aZm2Ql4uEFzyPhtnlJrk4 VIcw== X-Gm-Message-State: AOAM533COcv7VtUUNL63TJlmTSOh7QGN8OoNF4jBhfKRLAB2DpLV/ZSF uCqkY8+cyIPUKa3tv6q7Dv7T9w== X-Google-Smtp-Source: ABdhPJz5tCXujzY8OghCUBQNUBHDa22zyVcbaZ6BUO5ym91jHLtpezu5wFeJRQOAchTuClwI1F033A== X-Received: by 2002:a63:d114:: with SMTP id k20mr4198126pgg.75.1642220669870; Fri, 14 Jan 2022 20:24:29 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q9sm5777743pgv.71.2022.01.14.20.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 20:24: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 1/3 v2] staging: r8188eu: Drop get_recvframe_data() Date: Fri, 14 Jan 2022 20:24:25 -0800 Message-Id: <20220115042427.824542-2-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220115042427.824542-1-keescook@chromium.org> References: <20220115042427.824542-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/cbcAmAcsmYgBh4kx6lQv2coVuKsjKL2V15ndg7Erkujlv2Soj3VY3 WBrgQfuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYeJMegAKCRCJcvTf3G3AJv0xD/ 92Y3jbnr8L5D4H7cCfqWdvnWn/NXAJodrOeNxdk7ul/0rRz3EqIiZVoWUOpJ3pq0fQ+s87Wf+pCt3u ebrZiFUNQBMQvVLQOPZsuH93QLbMHK0heQuRM6ogcPNx3Q9FzCDJszz96ZEOrv2aqLmZJu8Z5FzGIa sVAn6r+vbNgmU/BmjefnN0RzUArx+gL6rBYRSnzg99cHhI6A1qw9b8VUfCgdoMxnRzPg67sbxcy3b1 zUwdhsxXS5HyLenfz9vUp3jxU2pDd0Mjba2njaWMdllw4h+KAm7u7AZEKYOB8IQlJuDYsdqAb3IZYy 8RaG9xNmBczKAy+kzccVKpw67WfHtrxMt4jqQXyTHpXQIVm37im+BNOKRfgWKv1ecJxQQDKKwWLjFy P0ysyE0vtPd035lKVYTEpqyeRhdLYJqMcsJrifdHtw09jyMbHvY1WNByaiuQNx0gy//DuJ16Catjdr I7BaJB0Y60TaSe1A2DZxavoy7hiUYd8fiI1egvTtjquDEEGBRYg685JnWmDv20JfNgqqeVZkCDqiIh aLlHB9oJ8VLOJEggpNZbNkBnWPEDfIZOR5pZx0N2Gubu2kQj+40PRI6Wd+aBl7IQaQm6NY5lcQFzK5 Ysnrr8OM78uiOjOYvzfOrApU+bmpXeKc6nVmm6vqJ5CjXlGUtJpsokZYMxlw== 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 Sat Jan 15 04:24: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: 12714320 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 328F2C433EF for ; Sat, 15 Jan 2022 04:26:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230491AbiAOE0e (ORCPT ); Fri, 14 Jan 2022 23:26:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbiAOEYb (ORCPT ); Fri, 14 Jan 2022 23:24:31 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11DE8C061747 for ; Fri, 14 Jan 2022 20:24:31 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id g2so4422388pgo.9 for ; Fri, 14 Jan 2022 20:24:31 -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=MkesN9KWjSVv/K/BwDv4IWH7+poIeTrqlxSPCmZ0Qp4=; b=OvtNBGAIw/KZDU1aYaf2wr6DUwwH76kziXBSgSi1C/Soc4HBS2mLNv36xO96AoA1Jg y50BYGjmv64cF1L3VhGrDvxK5jfpH0tb5+v5g9/rcgaKvrb24ehk4+f3tO62mrDCokTO xPXZJiaC7nAmMWdvqZ9sT8Qv0V5VFCoKyOSw0= 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=MkesN9KWjSVv/K/BwDv4IWH7+poIeTrqlxSPCmZ0Qp4=; b=Cj0NPZadSITBQxK/Enei5UIJo9jeK3MVJ/PmHEd5I9kjzsWZ7Crb8hcIVldW2rP4cL Fy6wXCfNLWOHAOhpTdCohQI1yEXY7FCrjO5vnUBboGiq61AMKpK+l9CNS5WKAHhZRUAz RGa/iWr71HXnvO1LMB2RJH5qxruQAxHiFibYkp6CeqbkelHRMmUuBaAtuPZEpZrzQmKi A58ep9QVCNYwUf/bBUCGgtOm7NoBjlUHwRBXkCbauPZGBfCp69IgVYemWLcG4ArWhwf3 sFHcF4fwIOskzAuFqoOTwL1R97g2jsy+9hgqPLmmyYC+LcVlh0TrU9l3Pwc17D94d2qp PLHQ== X-Gm-Message-State: AOAM530H4HKpqZKmt5G7zhIOrK6yZsROCqpgmWzYCGmjXDFW40/Fl/NK pURtS41MJJe4v9qeTGVL5UIiww== X-Google-Smtp-Source: ABdhPJxSuLNJa9YR5ljfxzcuGsLA96PC4Kf+o9mQ9v2a6LmQr3n605NBmESGzo5iKBOC28izNz/bpA== X-Received: by 2002:a63:9249:: with SMTP id s9mr10748342pgn.124.1642220670598; Fri, 14 Jan 2022 20:24:30 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id gm2sm12289154pjb.21.2022.01.14.20.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 20:24: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 2/3 v2] staging: rtl8723bs: Drop get_recvframe_data() Date: Fri, 14 Jan 2022 20:24:26 -0800 Message-Id: <20220115042427.824542-3-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220115042427.824542-1-keescook@chromium.org> References: <20220115042427.824542-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5267; h=from:subject; bh=Z6Wfwf6J3jPxC9N20ooqglvng7tGlFpo9yMXY4ONGgY=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBh4kx6rMJrMC8W6yDUxFp3e6Z57hAL5JlEjMqwbMfu kf+UFhiJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYeJMegAKCRCJcvTf3G3AJlkjEA CN3vYikUMRVE1xXmmwivQxstd/0eGne+wIQ8+LnWOwICl8klblpN1AFhgS3Y/9hgjAS5x57pVHmCRx av8TgSTDdrseku8EpUGz/ljcMWrxLNMMKpIXznB1RUzXihOdbCB0ivOpbPZWcxtUruGf/WaQHGDMx1 0FA7jJrzJqr6HTIJni65+NxZAsnxr0Qm7FMFbqmk57Iu1PfFN3Q3L8UqQsDLHeZ49ZUKntwxk0l445 1a2KS0Bq9HBnDOvUlF2k7199hZx6KWlF/FCwqaif350logcFak5t7TZic6Wk/aH/4KuLf95Tfto6yn P+bvZvEsZBCbTLJXcA0g222Rj0w6vd3GuZJn4sND0kLN/STj8cVQZJL6K6I1s7K+5oTSmNi7h9zCzY 26u1cRWYThdRbK4IyWxfYBfzlRP2kCwFUmhwx8CeHObDk6hu1LE6fz7hP8B+TGxd+hk/u7Qc3JYkNW WO3QK5gjydWXyZfch1Fho8xmjPf9QvbJKk3Q7nSUURiXKXthQzj2DpkVqh25x+PMkgb/prjw7BrTHT TGoppmDZ8RVlx5vwDpS8v0XnqAQ+LJPxUXS4cIqC49eMjOHx3/dgcGQmED5ACd8YfDtvSRAKB2jvoS iaM74RSQP6mtEgk2fPhOcaLO4WBObxhAyQHw44WpMWddwxgRDusr/rQPAGBA== 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..ffb455688a7d 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 = precvframe->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 Sat Jan 15 04:24: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: 12714317 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 F1091C433EF for ; Sat, 15 Jan 2022 04:24:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232426AbiAOEYb (ORCPT ); Fri, 14 Jan 2022 23:24:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbiAOEYa (ORCPT ); Fri, 14 Jan 2022 23:24:30 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4C0DC06161C for ; Fri, 14 Jan 2022 20:24:30 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id pf13so15203975pjb.0 for ; Fri, 14 Jan 2022 20:24: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=3IlqdjSCw9fn2cQPvzn1XJmEWy/5ZU80Qr6iGup90/4=; b=PSr6XCQSrvIx2D9DCagVuTK95ye7Q8ksV7u0dgJ13iOuZTyGSX56JQbkOmcDH3rXMj nm0CgQsvKldP39vdACMvf+aaf0faqqfBYEMDJyhPwp20l2sQ0si+cvtfCAECxIOc5P9V cyYurILSG2cB5zStQOaom9yULzzJqHIg2O60s= 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=3IlqdjSCw9fn2cQPvzn1XJmEWy/5ZU80Qr6iGup90/4=; b=Tj8niGf1qxqulWG9OoyQpsfZ+nbvUVnd6LFwGGMbxjBMw/1AwCqhwytPFnfPydRq0x CgfFx+rzukkyzNRxAu2DA7IsWjKSASplDukeM4JRgCXZs4JXZX5cnNNFjiqQxg2M6lb6 NJd4n5uBzkPMme8XVJ+OpVAiglNTCzwWE6bp2AdsTEHGTappDA/X/6iDAOCBz16xJE6T KhOPm+D9jd7gve/RDqCtsHTNgz4Q6qMPHGiWxnBQfGxby8yt9W4g1BpLwPPwsFd/zrnm rrwqcaoFl1FG3qKlfOjgz6zsznN1sfvOPwVa7zYUxIuX8D6l0moJhM2NXM74/nI2HDgn A1FQ== X-Gm-Message-State: AOAM533rZEhOVTpyIyOB3ZIMiKMSYEbTzBXwxFuH45DNXGS6HqFkke+G d8FIOfLN68n5mEmJYV48Q/uOCA== X-Google-Smtp-Source: ABdhPJzOgXLX9FGHPckbQPJWuZVFYwDThRwB5pEspdEkZm1ZzItf8sExNcQiArsQljfkBB2x/JzA0Q== X-Received: by 2002:a17:902:c10c:b0:14a:922d:39d5 with SMTP id 12-20020a170902c10c00b0014a922d39d5mr4285944pli.66.1642220669728; Fri, 14 Jan 2022 20:24:29 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s24sm6614673pfm.100.2022.01.14.20.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 20:24: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 3/3 v2] staging: rtl8712: Drop get_recvframe_data() Date: Fri, 14 Jan 2022 20:24:27 -0800 Message-Id: <20220115042427.824542-4-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220115042427.824542-1-keescook@chromium.org> References: <20220115042427.824542-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2444; h=from:subject; bh=XALIzCjDjV/dc1s/Cum+fXM6T7eQf++MOdcsN2qRBWk=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBh4kx71MTNBgFhaHYjw2TdY9QrTgQSd4EUNHHod4d3 aZ6LfIOJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYeJMewAKCRCJcvTf3G3AJkw5D/ 9WGI+fo2Cjmg+40ISmphWU4B5hsYvQ2mUQEAAUi5z36vrDOJmaSoEz/mXfhZ4ttl4yscNKDT5Jt8oD E32BlH8dsHOzdDkHAVYXXtMXWDHvSgIHdOA9L2fwkY4LTYYRelsmSSbpZYZFvA+tkGL52cRkV6xOfL rkSLipCVvi9exLM+nyCWAMGn3AtL9TIaE5oLKaB8Z6/dS0pXUb9yaMwwdD9QGq5XJCr3OgAE73MHco 5ExyXiPhbP6+mxQxrysjyYulBzpRqzuIufeCZRbA67npJTLSQMTcHoH/cle3bh7nkGV/4cdckK85CI Z1+F3u34mwfkq3kodOh2lw6Iqavaw9FjZM7MnNa0ZtR19FCmaZmNaM3lFaiVS7B8kAc+GrRf1hm7HR Zz77BGSUenwdZvPL1BPCtxgkgCBFC2xvogGZK/ikpypd9yM/Nbdwc8dTdtiEvA8og0zP8M6zAcdd3H EmAhUUTzcpCv1rkP0efchMTATRCofoZa+G4y7pmb+FmcAZUMCpjzaUb6/jmd3yhgSjMxZgcCm/5fae XJa+x4a06Do9UxCfC8OVq2AbYsMTs8gEXGJVD/6ah26/WrWS1UEWw6o0K1lmoZZEgJYh/2+SZNH8ao mGahL2SWVp621gWMQb7GEBU35IKOcjEcCzSbV2yYKLf8ubWuhMrKQDwWpYEA== 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..a069e4d98eef 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 = precvframe->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