Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1763070pxy; Mon, 2 Aug 2021 09:36:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNWk7fdVgRoOGfgXgJ6KvtHhqmxEB5ulneIc+9z19hy4p+KFgFurhJKpC26bTXLWt+Nixx X-Received: by 2002:a17:906:8152:: with SMTP id z18mr16706608ejw.419.1627922185319; Mon, 02 Aug 2021 09:36:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1627922185; cv=pass; d=google.com; s=arc-20160816; b=jBeL3cR5eGjbR3biyMO9r4WVVePQixN7ttN2USwUQfPEnUZXsav5FIpfk0DiwnMYmP gssoO6IRs/EHarOt3YjUUT6tooZCcZYWr1O6lmcNDqhL79GnGQGzHsdOlcD/tS2+m5KF Awwt8CTc8hbE1mGnQKxirNt5CUdxybBrg694dkqKcwx2uVaeS01s1/SJAetwYq3Vk/rb Hfelqivn2z0Gvq9zVu4LfKuPmuTFNk3L/2WTScuunjJ1YuNMH9plOYV/ANSqgwj2cilQ qBszpYVuRpZMQei4IYR5DsVmf3Ie04qDBEqBwnPBiHq8VCSo0aquuocNe2b44GAuNJh4 NeWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=Aqn/GgO4sjqodFwoIqRzBPmLwSWUto1BpH6b/fe8NME=; b=fncMwEEXHqXl9DUK2NxDzjlTJq5tUJdg83axzziuHRHrx35ISkvFHpf7pTJYdDoKci DCJia1smDzB1AqPttqBxv0VblYp3FhiwQfAQdIVDbuiy4TPYaNbl2b+GUheEpUvq7Dm1 p4t7zfCDspsm+P8k6RfUuIj5vIvQRyN6VOCZvL382WlQvP1RovNkfs5jIhR10vwbQM+6 IiOlnKBOkfuyVLBIC6Ghtt1QkLwsxOKIxmE07IrjxjMwGTHY0+CkKaKIyQqY+hyhgFth x6PVZT/u2zDlSmyUrhDlXs8LiMHCGMkgL0RozYYB6z8hVxDKVsA3hO75kgvGEOMGPMaM V2zw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector1-marvell-onmicrosoft-com header.b=pQD++wgZ; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); 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=fail (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s1si10164148ejv.457.2021.08.02.09.35.56; Mon, 02 Aug 2021 09:36:25 -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=@marvell.onmicrosoft.com header.s=selector1-marvell-onmicrosoft-com header.b=pQD++wgZ; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); 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=fail (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232297AbhHBQf6 (ORCPT + 99 others); Mon, 2 Aug 2021 12:35:58 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:12432 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230139AbhHBQf5 (ORCPT ); Mon, 2 Aug 2021 12:35:57 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 172GUNSS007186; Mon, 2 Aug 2021 09:35:42 -0700 Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2176.outbound.protection.outlook.com [104.47.73.176]) by mx0a-0016f401.pphosted.com with ESMTP id 3a6265332r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Aug 2021 09:35:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KKu1CYunTkf7+pkp3M976vKa58lRB8HA9jR1s4f1DJVYSOjdJT7Tmh0YcE8gBYV7HD7mA8HFbuPY7/he0sDErH9pgv2nod7rtZBGO6pS5FyhDnPWuQ89Ov0ZqKNTd8ddcpFdGwm5vb1HUJL6OV1IRXoGG+z3hhpqkf3wjjSGImgCTCOwVXLnuC3rEWhXPMhdErnzkT2henw3P5Y9fzNuMVaLWkcCCSNgHeC9Zkkkh95PrvXek7q/eWiF32+hFvI8/YL7JLa3A/rRmZTm1apw8b/jPoN9Us5glsKlJRe0dVsbbhpMXGBwOkrKZZhRuUMMlOLIo8fRWChMaEakZi5t2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Aqn/GgO4sjqodFwoIqRzBPmLwSWUto1BpH6b/fe8NME=; b=OO9YYU2616bl8OXBqleelvc7MAcIt0VRF7QW7CdydJsnbnTlxg1P+lo8uO9w+hxR9HUte5toaxDDeCkhO1TkXbYpzFbn5IcyEC+xVGzzUgUZWfRe2CyTNHkG9QItFAyJl2teLHWbpCC6gpH5QoIs/33dIeROjeukYp6J8GvwoE5qsfpsx1MF/ObmynyCPn/dS9MkROrsrnjWmsTV50uWOez+qqzG2Nbx7qOZz3HIlA5B8tyEa99qPVqukCF6f4zOgEYT0sLs2ZU4luA29c6BiPiAJ6fu0l6qo551Eo853HoHIBEP2qPLUyrwWzN6lQJ3XVb9ViDI9DGNw1oEGMYBMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Aqn/GgO4sjqodFwoIqRzBPmLwSWUto1BpH6b/fe8NME=; b=pQD++wgZD4xS6Wi/TaPICZV36/nMIaWjfu4JWHphQOhDeOjgGjeJD5jHnS4c25ipd/0ExF1KOBC4lEuGBa77J6U5BuZia04IdAeUFiBK48a1pxhdPswoWPupm10CIaKpjOTp0kPkqDGXgNlPfthxqgVze8Mrk87mMIkl1B/F2HE= Received: from SJ0PR18MB3882.namprd18.prod.outlook.com (2603:10b6:a03:2c8::13) by BYAPR18MB3064.namprd18.prod.outlook.com (2603:10b6:a03:10a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Mon, 2 Aug 2021 16:35:40 +0000 Received: from SJ0PR18MB3882.namprd18.prod.outlook.com ([fe80::6513:d2ca:d44a:537c]) by SJ0PR18MB3882.namprd18.prod.outlook.com ([fe80::6513:d2ca:d44a:537c%9]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 16:35:40 +0000 From: Shai Malin To: Kees Cook 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 Thread-Topic: [PATCH 42/64] net: qede: Use memset_after() for counters Thread-Index: AdeHu2WnTRdoaKwFSqaAMCIXmimw8Q== Date: Mon, 2 Aug 2021 16:35:39 +0000 Message-ID: Accept-Language: he-IL, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: chromium.org; dkim=none (message not signed) header.d=none;chromium.org; dmarc=none action=none header.from=marvell.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 84e4bf04-176d-4a11-a847-08d955d39087 x-ms-traffictypediagnostic: BYAPR18MB3064: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: M1zOZggx0KKdCkGkvPxFUwoiriex9E5a+Cwn6R0ed5hilD/gsN2i9C3dfhnleTawIMOkPLItqATHYfmMamlDC5keJndVm0DEFc/zak+6ctgQswwY7uBpJqiTqYwaq8TkzARjikZPCOJ9zDe0idEQrb1/RQZCPZyPNhdIhnGozzBazHYpXVarnbwSkhlHkiFdmk4xyUYKgjJNm1GpnIAcdJj2NQsTqeAfNkNbP6r5MXrHrqBy5nd0d7pYlvWNk25GNqj7pWdtrFdCnYyER2KTWmPhRvnDLWbHADLJ4cfQEbnuC+tufTziywbidBWmY8mOzAt6ofZK656Eld5pO2RsDE10PKwtb6YGUsT5RtQxKoWXWiyy/SLmHH2eCMH3gLzdECSQc6vVaeJQBqs1MEBDqf4+PRUolgVsftzTT3MdCPYyiOqDiifSOTcMc8j5EA6u5EX9d07MBj0p2p8ocv5Ku6bBKLryHuzHHoEfFiaY0DmZwUdhhZyYPCvmjgzH3cF0dfHkhRPR3+FODgE44HKBgYQ8aLni4IzMtJQBbnkl8peUb8q26RFqbGQ3XsbWBZaQDNcNU37ntn0m8uuJ76R9m0w8GNK1QoqZlsiDpon+Y8BYXSZEbjtlFE5MOvJ2c7D+RP0VxoWtva29N9Min69xXgh7PgWg9PH3mTPn7fM39DzLlqEw/uvSg0kTldscoyW9xZXqteYZ2Jdr19HFmTWkcA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR18MB3882.namprd18.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(136003)(376002)(366004)(39860400002)(26005)(8676002)(8936002)(186003)(66446008)(64756008)(66556008)(66946007)(66476007)(6506007)(5660300002)(2906002)(52536014)(38070700005)(9686003)(316002)(7696005)(54906003)(38100700002)(122000001)(55016002)(478600001)(4326008)(76116006)(6916009)(107886003)(86362001)(83380400001)(71200400001)(7416002)(33656002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?0aGPhJtrEbsiGt50IbhEOw44CngPsjfqoA2FpWc88KXgacu96/Ti+zkGTXwu?= =?us-ascii?Q?oyAO1aHeW2l8299+xy0TuStZ9uXLP5quDTmVT4jHlgJaaceaJSjsPSayvOaX?= =?us-ascii?Q?/mIfPkZxQ4YkogVI0aZ49xeRFs6LtTg9a9binCEODPVJZsRtMfbs0tm9QWqf?= =?us-ascii?Q?IuYXGjFduw89ErHt14KcFkLdQdgbpPPKchM+gru9LkS8cfVo6QJQWr3WGaw0?= =?us-ascii?Q?S+qwPaxSc5TuhG87ZMRbpR5xOQp70mUJYzfWhzPqsMvFYbLQ1gXcQ52dmlV0?= =?us-ascii?Q?mfoqbSXOraVHLUZKxsCyCR+PBshaVfocZldRTy2kqCX5vCXa+08bgP43/cnF?= =?us-ascii?Q?Em0QiO1W+otbj6T9NY3h5dNOL1DCojNCAMeA3JvWHXVOjStVcsTEYrIcRQ8F?= =?us-ascii?Q?w85fYHf0vHENrUh8bdRxShEKe5pPqiB8UjvrR9sxpL/kr1s4QvW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OZHZJU5kYxQN?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR18MB3882.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84e4bf04-176d-4a11-a847-08d955d39087 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Aug 2021 16:35:39.9870 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: UySO1HYRFB5385NWKQM8f4ddgP+fe/cT2PwmeTem7EtVvOADGIf5EU2cnh34qgpNuxixoNQd5H0ugPhHMj1SkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB3064 X-Proofpoint-ORIG-GUID: 5FxVOV93Oc6wFh5q-ZaL3krJVytn8HZK X-Proofpoint-GUID: 5FxVOV93Oc6wFh5q-ZaL3krJVytn8HZK X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-08-02_07:2021-08-02,2021-08-02 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Mon, Aug 02, 2021 at 07:23:00PM +0300, Kees Cook wrote: > 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-t= ime > > > > field bounds checking for memset(), avoid intentionally writing acr= oss > > > > neighboring fields. > > > > > > > > Use memset_after() so memset() doesn't get confused about writing > > > > beyond the destination member that is intended to be the starting p= oint > > > > 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 t= he > > > > 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 se= cond > > > member and writes beyond int_info, clobbering qede_lock: > > > > Thanks for highlighting the problem, but actually, the memset is redund= ant. > > 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. >=20 > Should used_cnt be cleared too? It is currently. Better yet, what patch > do you suggest I replace this proposed one with? :) In qede_sync_free_irqs(), just after: edev->int_info.used_cnt =3D 0; Please add: edev->int_info.msix_cnt =3D 0; Thanks! >=20 > Thanks for looking at this! >=20 > -Kees >=20 > -- > Kees Cook