Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp903881pxb; Fri, 13 Aug 2021 08:50:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFs/9J0Y0wTHDNYlq61Obb7W96lqIGINohGeyk/YZSN1xH/Qf//nFm/0YTX5B+lOD33Q+k X-Received: by 2002:a05:6638:37a9:: with SMTP id w41mr2924361jal.142.1628869816836; Fri, 13 Aug 2021 08:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628869816; cv=none; d=google.com; s=arc-20160816; b=aS8+juOKkgBvrArnPlInzqwvS2leHRStkTLoyCxpQWT84bybokGvbTI3qSn44C3Cld 6lx17o2yAh4uv5UE8UKcUlQImvvUhEW+01ry8q6FWkyWMcaoe1PG+s8AsML8pYwDvpIm sUMmjv9XcDSvCu6zF8gJoNys/dOlTSKxKQCk5+ro+bo+QSwHsifeg1j8XdrRBZiqsYdx p8/YIf40r/GH7gZlc77q9I0FId9J7DEqsRkX4cGfoe/h3bKPmtnEFaEFy0yL6UvcapAc cVq7BV84+W/H4Up17/m/Ew5yosrWcEaTS51dVZo3ZBwcTUZKB5Xz8l+bW5TI/fKFZsIR xIRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wwWCtmitPIziHrsVDs3e/WXMsT5Htg5FsOmnBCodSj8=; b=1CXxSPf9CqCgwA3Al8DR9ZnFfFvjlnDedQWVt8DzLqTgeACTi9EDQUcIg6ylEWQF9r uhA5IHPb9jIOgo2hRTt2SaoTZoFoH4YJ0ua9/hDDkMJxhALSx0NHTdUtQPVb9K9x9elz tMJwFsO7YgftYOSZQEwp3wvg5eE/XLg64wmW0AqlvYq9NIcXrH0+0ih89+bPJrxOFVP7 D3lc4PcTubrtcm2EtWOBitD3owh3zvUFt0e6X6DvZdq0jiXOesk0jm1znVJOD9ltDjSo vvSLUn+sZSGlVgYPXx36xNjwo3w95IE7jCXAhCQ2xrtQ8cJrqt9841b8AIdu7Kz03nQ9 cVDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IYdotH9N; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si1942300ilj.42.2021.08.13.08.49.58; Fri, 13 Aug 2021 08:50:16 -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=@chromium.org header.s=google header.b=IYdotH9N; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241276AbhHMPth (ORCPT + 99 others); Fri, 13 Aug 2021 11:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240849AbhHMPtg (ORCPT ); Fri, 13 Aug 2021 11:49:36 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7638FC0613A3 for ; Fri, 13 Aug 2021 08:49:09 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id n12so11828123plf.4 for ; Fri, 13 Aug 2021 08:49:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=wwWCtmitPIziHrsVDs3e/WXMsT5Htg5FsOmnBCodSj8=; b=IYdotH9NOHI+p6YKBepbynbdJfSmXJkJybgDCe1TtlsZi9d8s2ARhtWMwxaW4OtCLq bFaaxwtms7kw7v0QGyAhrDtCCioiCLcGglpFR8y2So3ynzX/1/r1QDH+OpSsyD4XSNXW e09KeqUi7PPKNy3dHFxjXD1hHHD+rZWpC+hMA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=wwWCtmitPIziHrsVDs3e/WXMsT5Htg5FsOmnBCodSj8=; b=S0oYLR9UZ/0uT0Al5cGd7XR6/p3DK6wCS+EaXdpHTkd6x3VwdSLt232f9kMKb9iC7j ZQSRYjqcFJIG71QWYZIGbs28bL4Kfi5zEmvZdjE1OfarXqbFJVXK+uMQPA+YrMrWEziS qLYov2o8DzuhT+xXhWlbczmMtqoQBNxRFxv8KOgMo/ZRfmgbyhbIa6rOnhvsn5yinCwI 91aa7JkVVs5aVrxq+Dz1aW30ZjvbFum0UrdhZE14kA5vBbHwhNy1e3cy6JPXUq7FWVQ+ J9BOfFQ+bkA0PpvA6l/jHS7KhdgAlAEA3GGDCH4LDKGAv5E6wIVs6uKmOCq4MbEIMbqJ Pmtw== X-Gm-Message-State: AOAM532c+drHbk5TLH8gPb4B6MGWRbkIcFLGBX+jIHovoNVt3jzJq/69 KS4wvd6iF1VMgd6VG38HtPQNcg== X-Received: by 2002:a05:6a00:150d:b029:3c8:e86e:79ec with SMTP id q13-20020a056a00150db02903c8e86e79ecmr3123596pfu.62.1628869748959; Fri, 13 Aug 2021 08:49:08 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id u21sm2725385pfh.163.2021.08.13.08.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 08:49:08 -0700 (PDT) Date: Fri, 13 Aug 2021 08:49:07 -0700 From: Kees Cook To: Johannes Berg Cc: linux-hardening@vger.kernel.org, "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 Subject: Re: [PATCH 10/64] lib80211: Use struct_group() for memcpy() region Message-ID: <202108130846.EC339BCA@keescook> References: <20210727205855.411487-1-keescook@chromium.org> <20210727205855.411487-11-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, Aug 13, 2021 at 10:04:09AM +0200, Johannes Berg wrote: > 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? Ah! Yes, thanks for pointing this out. During earlier development I split the "cross-field write" changes from the "cross-field read" changes, and it looks like I missed moving lib80211_crypt_ccmp.c into that portion of the series (which I haven't posted nor finished -- it's lower priority than fixing the cross-field writes). > In which case I'd probably prefer to do this separately from the staging > drivers ... Agreed. Sorry for the noise on that part. I will double-check the other patches. -- Kees Cook