Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp92799lqm; Tue, 30 Apr 2024 14:01:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTH/neD8NwyVl2Fo2NmVXZza5qczKiMQtON0Hl8UvmCEfN31d3cDXpgVQ13B92XIzPVCqzQfKSgzqmdMkjUHNTkBPN8N2cUFePRCm8Cg== X-Google-Smtp-Source: AGHT+IE+YAPEuTZGHYIw3KJ99yRsxYl5MXz48ok6WQnxox/hk2aHg+LPglw9QK/ucqjC5bxyWVUh X-Received: by 2002:a50:9f29:0:b0:56e:ddc:17ad with SMTP id b38-20020a509f29000000b0056e0ddc17admr364637edf.30.1714510868719; Tue, 30 Apr 2024 14:01:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714510868; cv=pass; d=google.com; s=arc-20160816; b=iFLqOJtzU1ETnXgSqjVm4PHfflohyWfKPCH1DzY3HcUXfI43i4oJvUSOkCOFlQlRn4 kml73V436MgI3Di+adPzJifBXW/BYcH8/6qq06ETRofllXKNcQ7fx59vJzyTCxB0UcmF wF2LEeFEHzEscmL2JJyMySgtP/ms3j0mx4aZcg2IfMpGAe3XNJEa2DnyJ41hQmltJNRE USlAxcH/lppYFqryRRX+6FMzvQtcBOUoXBzzuL4LLqQwBE0XeoKB8tI5hbEVZpdnxVgZ qqrt0Y38qRqZH6sQcrOiA5G5JC4HqcT4rUK4Ok8SqSyf+NxLt99va70gQkJqzGnKzEsw 6RmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+xIU8q6pWM6w3NaeJRA8h8N2JrHznXlpLpQKHyO9q7I=; fh=4zmEqYcBcWY241wZR91NmjjRbZEAI6HcAsFb+rStW8g=; b=bYVg5Ap8lD6C/GVSySg/z9XuIZmGmvxR9fkDT7cUs4IE1AbdsJomaDCe566yf3PV3a BzuEVxPd6jUe8GyCFFveyt/KFXd0Vdb1znDNDt4trBJr6Ron0TRO04mEdprzSkFnYUJl rzCcHTJT3nJQEgX58P5l/WsCz/fnFElhb9dtFMWOHja1CIDhFmjxzxC0QptMkQFf8rGt PGEGoaM/C9Zd2QNR0tNrfZ9eU3VEBfQY0yGkXqRP+w/WNShijzb842q2kw1LJHL/zLeu IsPvSZcDe918rX9Tf4GI4znR3iXWu/4AQ0ihXoLU8O6emK14gR8+TfE6lr9Ye1eVCFkm i8wA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QT+YxEKZ; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-wireless+bounces-7076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f18-20020a05640214d200b00572a1a636fasi545070edx.282.2024.04.30.14.01.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 14:01:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-7076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QT+YxEKZ; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-wireless+bounces-7076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 206FA1F24070 for ; Tue, 30 Apr 2024 21:01:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45A291A0B0E; Tue, 30 Apr 2024 21:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="QT+YxEKZ" X-Original-To: linux-wireless@vger.kernel.org Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 EF4511A0AF8 for ; Tue, 30 Apr 2024 21:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714510861; cv=none; b=BfbWi3nXihcOPwzp9Q/KLvATMRKaBssbjrcchtB4Y2hqBmRnYrHrPqkxldOrlO2FeZ4Cmb+qS3RqsFRqpfSPXhCH+IQRzDC5WXLyEWg/powhV5fTyI0T5RYaUxXY7TFKELtmGK9LKHj+uJ4gm3x8v450I5nBlHJIwMcmLCkkYjA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714510861; c=relaxed/simple; bh=9sgfqtMsWzv9o+g9mJtMOps7EusW138bXsllLt5r/dg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RlAIvLoHHDs0xfpZBRZSLkrKlV9dqkrBFz2DwBtnNnMrryZ/+5VdRu4A1FC9Nw3xDVm9UmkKhyFGPa+0v+CvNWw27P5rnAj8nU2M9uDk/s+pG8Qr3Z3zhrurVSrdGlAK+mGsKZRRW8hkDkESd2aRcYa82WStKhG592c6S1W/Hsg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=QT+YxEKZ; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-53fa455cd94so4748468a12.2 for ; Tue, 30 Apr 2024 14:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714510859; x=1715115659; 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=+xIU8q6pWM6w3NaeJRA8h8N2JrHznXlpLpQKHyO9q7I=; b=QT+YxEKZtYluZXnVbk5NdogepPybv1HDFeWh5NSGV45V3wCpBtvYa9QrKGLCNBS23m YpNSgCvLvbYH1kOop5lg3GIEXIW9J9hQNXIB5s4HZONXEDOtbxXnBlPVWsWVWWs88DE0 HYTfN2XDACzmZ0sH6mvc/LXFGSb0Aozqp4KLo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714510859; x=1715115659; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+xIU8q6pWM6w3NaeJRA8h8N2JrHznXlpLpQKHyO9q7I=; b=MTKbnRSYs6L5yrXX/UhLedhfwJzuuHNbRvgix697OmFJ8mfzGWMbVth7cdHHFcbR9S rmARGbtXn/vgsg6hlZoqUhDH0+Ud+db43me4XPIu1+xbpC2zA6YPjYSaA0x8pbkQzcPQ xmdE+YcP08ZUPklboc+QvSL9BlkGBCxwdYYnHDaXh3dSltOzyYksRA6/dMOS8ywSH+Rk GFlJvy9hIZXAZ4sZ952CePTOndTPVS7G3jk1ca04+gehDo0eC9q4oWOY79D9fYtRQsXg sN0c40ornWYVia8rLEVMHUv6+rpF/Pc16HqUC022LE4Vjo+5YIxbt6R3TXt2zD0Ttdnc dCoQ== X-Forwarded-Encrypted: i=1; AJvYcCWa1HqKfAs41VeFBo5/Mq1aFdRke3Q85EKHyqv1/SOgQW/wg0scv0gS3kG3yoW7Ef6Jg8+1rzwiVFJCNNKVHgL1QwKxxbedERGDQMrYN1I= X-Gm-Message-State: AOJu0YxWHqXsiQcsXFv0KGSGQK6qZiyzTkk2cnVgGvAbhIcIY1+wfN7y qzGUYuEnFhfVZ5hp/ojsCU+0U3XdivVBaZswSs6HEjoR+QTtLMTLdJE884Vfpg== X-Received: by 2002:a17:903:228c:b0:1e5:9da5:a799 with SMTP id b12-20020a170903228c00b001e59da5a799mr676864plh.6.1714510859313; Tue, 30 Apr 2024 14:00:59 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id j18-20020a170902c3d200b001eab1a1a752sm10560810plj.120.2024.04.30.14.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 14:00:58 -0700 (PDT) Date: Tue, 30 Apr 2024 14:00:57 -0700 From: Kees Cook To: Jeff Johnson Cc: Johannes Berg , Nathan Chancellor , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] wifi: nl80211: Avoid address calculations via out of bounds array indexing Message-ID: <202404301358.CEA4B3D@keescook> References: <20240424220057.work.819-kees@kernel.org> <9983345a-d590-4a78-94ca-6d96832860b1@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@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: <9983345a-d590-4a78-94ca-6d96832860b1@quicinc.com> On Tue, Apr 30, 2024 at 12:59:57PM -0700, Jeff Johnson wrote: > On 4/30/2024 3:01 AM, Johannes Berg wrote: > > This really doesn't even seem right, shouldn't do pointer arithmetic on > > void pointers. > > FWIW I argued this in the past in another context and Linus gave his opinion: > > https://lore.kernel.org/all/CAHk-=whFKYMrF6euVvziW+drw7-yi1pYdf=uccnzJ8k09DoTXA@mail.gmail.com/ I was going to make the same argument. :) For this case, (void *) is superior because we need to perform byte-granular arithmetic and we need to use the implicit cast to the assigned variable's type. The reason not to use the channels[] array is because we're not addressing anything in the array -- we're addressing past it. Better to use the correct allocation base. -Kees -- Kees Cook