Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp569167pxb; Fri, 13 Aug 2021 01:06:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywaKVap/39auKi0klZCgWN1VRMWGt2r4PPX7e1lleldPUEgjKLZ/mi0sAGSAl8xMm87ttN X-Received: by 2002:a05:6402:27d1:: with SMTP id c17mr1559098ede.178.1628841996527; Fri, 13 Aug 2021 01:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628841996; cv=none; d=google.com; s=arc-20160816; b=Ibaov+r6CCqRGJh8AchUmgPpKFkIGToDdmkld8VA7f8uOZvJph8MfyvJdJH2LZXx5t dc6949H5JS8W0GuXdsQ6AP57NI7x0cB/i/1VOlJ4uZ4EXCgLqmrfMb3Wk1zQSXUROkJL nWukfIEMDJsXWStFOLLKe0YW/bU5AwcANRY6yoT7DtHxog0qbaMy9tY/hX5g814mJYau rEUeBUpPcKQx1cdufIgwarfYf3vNa5KMsKbucrCcFBaGSu8HjWeE4/PQXUkOEd6RUFRV HvOESlBDChuJASoulMHgk6ZljiDLWtVwfSWBoEqgY4IwtQ2akcGyM78pJ+AsPxk7Lk3v cukw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=9+EPWKLBRJolwP8aFlJWDp26AmwHK39v/QqkRv5Vil8=; b=xXjEOJCGlTEW1ICaXmlBRayFxrwba4PyyRa/BduAnwc8OZUw4+Y8GylK7KVT/kr1tR ulWLzjsb7ifNidkFinv2Pb3h3J7EYeuEOn3o2uISogBN269BUJ/5eXyVQh3ZoHcdaGIj nn2MXEkuWWLSYCTe0zf5/YOlL5u1PmPq2GAKKlP8i0tnvvhrq/EVWG0moBjFFeCgX4w8 406ZW9GbzhjfPTdlc6m1VFK0164DULFEYf0adHKiegODB52WuTisc2iJwhO7Xsb7JGdh HIt2o6p2dyNisAJKvbgOOCegsIe0sjFJ6qj++x2mdRg12CRXX3TQwjDnQWEwBloehN5B tmbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b="RWx/A0yy"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n16si1039482edy.42.2021.08.13.01.06.05; Fri, 13 Aug 2021 01:06:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b="RWx/A0yy"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239699AbhHMIG0 (ORCPT + 99 others); Fri, 13 Aug 2021 04:06:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239706AbhHMIGS (ORCPT ); Fri, 13 Aug 2021 04:06:18 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18C7C061756; Fri, 13 Aug 2021 01:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=9+EPWKLBRJolwP8aFlJWDp26AmwHK39v/QqkRv5Vil8=; t=1628841857; x=1630051457; b=RWx/A0yybpo4f43qP3+gm2rYqp46XcDtPuQ/qCtOtmQX1sN IaKQfQbgauZRKQ08xv90/STdI9sNn4MnFUHmnjEgCx+qxPHmwyC9BiA/Cji5p17lFePE/IoTS+L+U +rPq0E2H+oMcV4gwxgZ49mqraPgiENWJtYWf2rIX8RviJxn2i4ZdCjWlFRZjguPCMp2M/7VbguDY2 b28LPcjcGkqeJydXiT0dCR6XKhITnbW58xUjTsAZurvCFbzIJhjmhHB8qOkFZMQBazNcXy1Dxxe5N A09aXoGbBW8l7D6CS2EBQMuWv2SFtw/QVRB6DJFWqXdXD2qazECg+tjPmp0o9xZA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1mESAk-00A9Tn-Sj; Fri, 13 Aug 2021 10:04:11 +0200 Message-ID: Subject: Re: [PATCH 10/64] lib80211: Use struct_group() for memcpy() region From: Johannes Berg To: Kees Cook , linux-hardening@vger.kernel.org Cc: "Gustavo A. R. Silva" , Keith Packard , Greg Kroah-Hartman , Andrew Morton , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-staging@lists.linux.dev, linux-block@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com Date: Fri, 13 Aug 2021 10:04:09 +0200 In-Reply-To: <20210727205855.411487-11-keescook@chromium.org> References: <20210727205855.411487-1-keescook@chromium.org> <20210727205855.411487-11-keescook@chromium.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Tue, 2021-07-27 at 13:58 -0700, Kees Cook wrote: > > +++ b/include/linux/ieee80211.h > @@ -297,9 +297,11 @@ static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2) >  struct ieee80211_hdr { >   __le16 frame_control; >   __le16 duration_id; > - u8 addr1[ETH_ALEN]; > - u8 addr2[ETH_ALEN]; > - u8 addr3[ETH_ALEN]; > + struct_group(addrs, > + u8 addr1[ETH_ALEN]; > + u8 addr2[ETH_ALEN]; > + u8 addr3[ETH_ALEN]; > + ); >   __le16 seq_ctrl; >   u8 addr4[ETH_ALEN]; >  } __packed __aligned(2); This file isn't really just lib80211, it's also used by everyone else for 802.11, but I guess that's OK - after all, this doesn't really result in any changes here. > +++ b/net/wireless/lib80211_crypt_ccmp.c > @@ -136,7 +136,8 @@ static int ccmp_init_iv_and_aad(const struct ieee80211_hdr *hdr, >   pos = (u8 *) hdr; >   aad[0] = pos[0] & 0x8f; >   aad[1] = pos[1] & 0xc7; > - memcpy(aad + 2, hdr->addr1, 3 * ETH_ALEN); > + BUILD_BUG_ON(sizeof(hdr->addrs) != 3 * ETH_ALEN); > + memcpy(aad + 2, &hdr->addrs, ETH_ALEN); However, how is it you don't need the same change in net/mac80211/wpa.c? We have three similar instances: /* AAD (extra authenticate-only data) / masked 802.11 header * FC | A1 | A2 | A3 | SC | [A4] | [QC] */ put_unaligned_be16(len_a, &aad[0]); put_unaligned(mask_fc, (__le16 *)&aad[2]); memcpy(&aad[4], &hdr->addr1, 3 * ETH_ALEN); and memcpy(&aad[4], &hdr->addr1, 3 * ETH_ALEN); and memcpy(aad + 2, &hdr->addr1, 3 * ETH_ALEN); so those should also be changed, it seems? In which case I'd probably prefer to do this separately from the staging drivers ... johannes