Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2519908pxb; Tue, 24 Aug 2021 00:39:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqO9cL6ue4aw4LG0HEreoXYzqs2/D6rN6Z70hhLDb+skh4vpSpURYQ/iexGpk73FoTqcNh X-Received: by 2002:a5d:9c89:: with SMTP id p9mr22236298iop.13.1629790785636; Tue, 24 Aug 2021 00:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629790785; cv=none; d=google.com; s=arc-20160816; b=iPdqDgVkbrO0F0v96V6+bEYAh640nhOw9I1Ygn1r8qv3NHfFGgAa97On5Hq8h/atY+ At6OD+ko3bYVE2BbyzBxgOKDlfPpmK40wh8crsuDRVR/XZ71Mni2d3qt75L6/DeKlakS t/LhDeiaqo0f6e3l9C8BOWl0l/E/V55DwBZExavT1slBBFuIYBMf6sAUJxqXMpbgXuf3 4mitGJlqG1UmO4LuqRaZbj50CAtKL1kkHhGQdJJr/+pO+OMHOeblM5Lb8ZbrOy3CyaNX YGmS6xqLFQGy9wfm9+emk4V7xV8MmuFa+yEIbALjGYSxCzr0qJDnYkYIDDV4hfAWLMog BxQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=FfPL365yk+KRlYSuy1BDRCenVV4aDSEQdz4isCK8hK4=; b=tzEp3z/USv24RbB/0SccA6nfWIA6d7gEprZVsKlMi+SkaddTXNvoGSwyNpGa8AlZfe ZydnDpG9hWOTmkjf9xHi5M5886Sd/dtr4Dv5zHqRisw9Yta7ggzWfRaJ6s4TMyi2xitQ ECcbd3ZR+DTqTTpRRM/+6R8ENu6TTVG1LyPC9JRLorinW33teCEogPSyN/imaSAW7EGV tc4NuvozXaFT5qyL3b012QOGXh4jAmPzoRGCChSi9L8cnCopEHa14A3vN/dQ34ybXyEC CCq8MZWRbxqB7tm8zul3dqLZ6JFvsT/5DHTrDsXuTG6GFnwhsb+vubDhaEwnOftUgQ1z +FGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si12724377jad.63.2021.08.24.00.39.32; Tue, 24 Aug 2021 00:39:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235110AbhHXHi4 (ORCPT + 99 others); Tue, 24 Aug 2021 03:38:56 -0400 Received: from mga03.intel.com ([134.134.136.65]:32305 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234616AbhHXHiz (ORCPT ); Tue, 24 Aug 2021 03:38:55 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10085"; a="217283964" X-IronPort-AV: E=Sophos;i="5.84,346,1620716400"; d="scan'208";a="217283964" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2021 00:38:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,346,1620716400"; d="scan'208";a="515317618" Received: from um.fi.intel.com (HELO um) ([10.237.72.62]) by fmsmga004.fm.intel.com with ESMTP; 24 Aug 2021 00:38:07 -0700 From: Alexander Shishkin To: Kees Cook , linux-kernel@vger.kernel.org Cc: Kees Cook , "Gustavo A. R. Silva" , Greg Kroah-Hartman , Andrew Morton , 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, Rasmus Villemoes , linux-hardening@vger.kernel.org, alexander.shishkin@linux.intel.com Subject: Re: [PATCH v2 47/63] intel_th: msu: Use memset_startat() for clearing hw header In-Reply-To: <20210818060533.3569517-48-keescook@chromium.org> References: <20210818060533.3569517-1-keescook@chromium.org> <20210818060533.3569517-48-keescook@chromium.org> Date: Tue, 24 Aug 2021 10:38:06 +0300 Message-ID: <87sfyzi97l.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kees Cook writes: > In preparation for FORTIFY_SOURCE performing compile-time and run-time > field bounds checking for memset(), avoid intentionally writing across > neighboring fields. > > Use memset_startat() 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. > > Cc: Alexander Shishkin > Signed-off-by: Kees Cook Acked-by: Alexander Shishkin > --- > drivers/hwtracing/intel_th/msu.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c > index 432ade0842f6..70a07b4e9967 100644 > --- a/drivers/hwtracing/intel_th/msu.c > +++ b/drivers/hwtracing/intel_th/msu.c > @@ -658,13 +658,11 @@ static void msc_buffer_clear_hw_header(struct msc *msc) > > list_for_each_entry(win, &msc->win_list, entry) { > unsigned int blk; > - size_t hw_sz = sizeof(struct msc_block_desc) - > - offsetof(struct msc_block_desc, hw_tag); > > for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { > struct msc_block_desc *bdesc = sg_virt(sg); > > - memset(&bdesc->hw_tag, 0, hw_sz); > + memset_startat(bdesc, 0, hw_tag); > } > } > } > -- > 2.30.2