Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1752528pxy; Mon, 2 Aug 2021 09:23:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw87gVFzqgd3+0x6Dux0xhN2cT2FOk/3Ip5ryX/rG3GANhWkVnkqICWNw6DWlsoM37+QoKX X-Received: by 2002:a6b:8f8f:: with SMTP id r137mr1019832iod.185.1627921434771; Mon, 02 Aug 2021 09:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627921434; cv=none; d=google.com; s=arc-20160816; b=YEyN1qv40M/td/AWX4Q8cvFCVWriLURdkgHlealhB84XXVoFSCKsilwxUSCo/ChMOD 8soUWFobeI+btiYmOyhITA5f9If0yjXRPfiAiJXb5uTvSRwbNLcZlYi4R3rXfy2T45Rb E9YEQ+F6LHrJiHLFN/CCvtduY5boBw/uRGcAAvKp8xaaPIlOPed8oGBQO+ZWwwKsBSsU ZgUxbG4HKbyCqMr9iHwdKBH3UDBW8TdmC5QZnUBFyqJnLMK0MSZsMu4HILzfIckeqv0A 6GYhbsHWLMYE45j50Fdfsv4jWZGaQEuTzT/QmfRbj+tN+U4G5B1rwNFt7ylRw0t5rBnd PnDw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JaILGVZ5ZfAh5yd44e+vxSRLCop37r4sy9cxjRO/kVU=; b=AOnCWxL2eciY1GwPx9jUufDrUTyUIHwEQDFbvPeCq4xDcVXsa0zw4AXimtC0ZjyWmd eqskSY8PZAHYFf40Ej2Akeut+s57qagFgzTG5ZmeGv5Td+vH7tY3hEgN8Rj3rewGlC1S y/ojxEz1UpBlf3GDQPF2AHmNHjSVvTPYcZAXgGJF85xzcsiE0u0WyyAXj7OLPQnLejBC dlrmbn58+KnuEPiOIXWQR60TK2YVmhSASvFPik+IIC9X9krsm/fQvFO3chVEP538LsHd dD+Hyx46sE/Q4GsiBG9vOmZr2lBCvu595H2T+ZII3/SuS/A8IP6yEqaH24bbJMbAKgkb zm7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aw1kgIMm; 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 d187si13505263iog.56.2021.08.02.09.23.36; Mon, 02 Aug 2021 09:23:54 -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=aw1kgIMm; 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 S232390AbhHBQXg (ORCPT + 99 others); Mon, 2 Aug 2021 12:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232391AbhHBQXg (ORCPT ); Mon, 2 Aug 2021 12:23:36 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4371C061796 for ; Mon, 2 Aug 2021 09:23:26 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id dw2-20020a17090b0942b0290177cb475142so6595965pjb.2 for ; Mon, 02 Aug 2021 09:23:26 -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:in-reply-to; bh=JaILGVZ5ZfAh5yd44e+vxSRLCop37r4sy9cxjRO/kVU=; b=aw1kgIMmRz0YMmD8jXYt7yhGZxHLHmcNQFLrG40MdDJ4dxtp5Dp6z04FghrmAgWxls ibbc21J6Lj1o0KA7GwJpBkMxWoCQKSfGPfoyBryQnP/vDd6QBrsp3tbdnfeGJcBe4xv4 fS1shEaQqJCHHvIk5MIu8rA0hZEvPYJj50Zzs= 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:in-reply-to; bh=JaILGVZ5ZfAh5yd44e+vxSRLCop37r4sy9cxjRO/kVU=; b=PFxNCa0ZrOzWEpgvbF9zgZT0R+E54s3OVHEjbXHy8hriRmMQSoS6qim9YK+w9SuMVb b7qKZIuVyYqSQIusiG/cp+a3qInCpbVSfEPDPJoUqbnjJU6RhK/aZICK35UBwaJq47xa +N9ZpmgJH91EsiT6k8Y0dbKLQOkOjrAbBJbNimVdxRjvwSzgJiHlH4MmjZbgzpZ8cGCA CR8xdJxT9MSPB54sSlVs0wwpDy7Of1E931JztiOW6b1sOogDWSh8sVVSvg1aX3L5rXUC 8ryP4xgotCEOEvZZTZGRLawYbwpDX0FaAcUQM2JjDGCIm7RQDDakm48U8BmHvQlW6HrG cZOw== X-Gm-Message-State: AOAM531CObSAkXhcOT3SHrHwvlrJP0LH8uDnb4iGA3+60nfqsyNhyD6N jS0Rb73lhHaz3D8eFRu3anaiEQ== X-Received: by 2002:a63:4a49:: with SMTP id j9mr2250552pgl.20.1627921406097; Mon, 02 Aug 2021 09:23:26 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s193sm13206950pfc.183.2021.08.02.09.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Aug 2021 09:23:25 -0700 (PDT) Date: Mon, 2 Aug 2021 09:23:24 -0700 From: Kees Cook To: Shai Malin 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" , "linux-hardening@vger.kernel.org" , GR-everest-linux-l2 , Ariel Elior Subject: Re: [PATCH 42/64] net: qede: Use memset_after() for counters Message-ID: <202108020922.FE8A35C854@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Mon, Aug 02, 2021 at 02:29:28PM +0000, Shai Malin wrote: > > On Tue, Jul 31, 2021 at 07:07:00PM -0300, Kees Cook wrote: > > On Tue, Jul 27, 2021 at 01:58:33PM -0700, Kees Cook wrote: > > > In preparation for FORTIFY_SOURCE performing compile-time and run-time > > > field bounds checking for memset(), avoid intentionally writing across > > > neighboring fields. > > > > > > Use memset_after() so memset() doesn't get confused about writing > > > beyond the destination member that is intended to be the starting point > > > of zeroing through the end of the struct. > > > > > > Signed-off-by: Kees Cook > > > --- > > > The old code seems to be doing the wrong thing: starting from not the > > > first member, but sized for the whole struct. Which is correct? > > > > Quick ping on this question. > > > > The old code seems to be doing the wrong thing: it starts from the second > > member and writes beyond int_info, clobbering qede_lock: > > Thanks for highlighting the problem, but actually, the memset is redundant. > We will remove it so the change will not be needed. > > > > > struct qede_dev { > > ... > > struct qed_int_info int_info; > > > > /* Smaller private variant of the RTNL lock */ > > struct mutex qede_lock; > > ... > > > > > > struct qed_int_info { > > struct msix_entry *msix; > > u8 msix_cnt; > > > > /* This should be updated by the protocol driver */ > > u8 used_cnt; > > }; > > > > Should this also clear the "msix" member, or should this not write > > beyond int_info? This patch does the latter. > > It should clear only the msix_cnt, no need to clear the entire > qed_int_info structure. Should used_cnt be cleared too? It is currently. Better yet, what patch do you suggest I replace this proposed one with? :) Thanks for looking at this! -Kees -- Kees Cook