Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp215201rdb; Sat, 30 Sep 2023 01:21:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyiIFaNM33AANAdvw3W5YY2iKREYLciSMe4qCmv3gVyIOGYlAlsK19wKAmJ/QaTvEXHmwF X-Received: by 2002:ac8:7d81:0:b0:410:a9dd:bd07 with SMTP id c1-20020ac87d81000000b00410a9ddbd07mr5571462qtd.10.1696062080360; Sat, 30 Sep 2023 01:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696062080; cv=none; d=google.com; s=arc-20160816; b=hA4CCxb1z9WwwskXWl471+AMwddaPRwjM1ZaPnoh6cl7U3E154xssz2PLnUyGCbovY WPMiAx8gJxu0G6tZLK39pJETOpablfZAsfxG7izTf/h9S+f3Rbyw1ve3ixNiUArsILOu 3k8RYzqpzLRBYhpPE6g29X6k6O9/0WkDwApIZ0M2vCA/dzlzWIYq8er0osFNa8TdTogL moHtNwfO33SJ/7jrS14M513yAPBM3wVifBEL+Ys4BRrd5nxHv2S4wWliAekWqog4EQIa z52LXCsOQy0o1YqeU4/e1SuFpnSPePsT8mb0zEoQOcsKmpGMS2EYq1AS4iSSZWzCaC4/ 239A== 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=XxXRgVO4X0oKRg65wlMjf/8hMDTc8L5/nBKtcjEkozU=; fh=Taqr259LeJK7aO1qzkAG/XltVrz0n6eEuNSqbPgLzxc=; b=YtUtieCKQqqQMRj93Y0rfoNhOw03G0UTjuEC2cI4UVaR8x0aTJDdm4rqzbTWtMlp7P kC7NE2G0wlDAdu8IADgZLoDToQB8NWWFRJurcHdktG8Vp90gMFBm3zZO93SODWOHlf32 FqzhEkjQJPle/eolTsZtqqourEwkw+wMUgma5T3sD1+uvrh6X4JCUgu3F48tJU1stYfX JPBwOVTkEDRwci/+IwgeTi3cwPFw3WFasVECVRqqhen39jXIeRnCVnbApb21NzrHJ2p1 raL20jr2sti1whUPwLectBiqDcozJ1dmVjGX6xk0/LFVokU6rDIeuYHehBcLmI6MFQsY z2CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Hmj/u6JX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m123-20020a632681000000b00578bea2771asi24774741pgm.176.2023.09.30.01.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 01:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Hmj/u6JX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 6B1CE83FF768; Fri, 29 Sep 2023 16:44:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233179AbjI2XoB (ORCPT + 99 others); Fri, 29 Sep 2023 19:44:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjI2Xn7 (ORCPT ); Fri, 29 Sep 2023 19:43:59 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE71DF3 for ; Fri, 29 Sep 2023 16:43:55 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c3d8fb23d9so112314905ad.0 for ; Fri, 29 Sep 2023 16:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696031035; x=1696635835; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=XxXRgVO4X0oKRg65wlMjf/8hMDTc8L5/nBKtcjEkozU=; b=Hmj/u6JX3APrdAtp+lWft1v2b2K7cwvLYfnu+z8b3s1WYhckbuHMr1IBmkzPir84R3 OAavnQIx9fgd/xcemBXRDE/upbNAdSLRlMyRXMsxKRzbg/ZLzjopNvNYTGqGeiPnE0in MNE9wzIU6E9nvj8sf2u8oxRs7Br/+50ZuWb9U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696031035; x=1696635835; h=in-reply-to:content-transfer-encoding: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=XxXRgVO4X0oKRg65wlMjf/8hMDTc8L5/nBKtcjEkozU=; b=ulb6O+uL9iuq69nM+c/Z/bmejDttbHODBA8FUj/rkMC7EkMwRhgjfkmWd9IPHqmg74 YfAxVLD3MjEpoVMClVYEAsucCgE5vEXGrhCAlPqa1G5GllD3qgx8x5pGms7NGOtQsaw4 ZNx21MniwKGdzZWWly6nKijcW3fX9iky8PEMYfY211if3+YmrtQj8Ooqr3Z6PF6flr3H 3/z9TAoOVWOAcztCJ3m71w5BcY4kG9NM3jBARQHj9tDa2JUF1ZdXxVWfRZCOtxE/bufj RIVTnDf6APvKAF8gIOcNyYKJiAX6ExwUCGm9SzR4FQEQ6rgCGvc8tESQXlKMy21H5rYb zGuw== X-Gm-Message-State: AOJu0Yz60ejuw7Mo8hEH+n+GZiaLpxHOV5BBO7nTC91o9Jg3dhES5w76 ldyAK33WJ3ZYdUl1vhsMBHrIzQ== X-Received: by 2002:a17:903:25d4:b0:1c6:112f:5d02 with SMTP id jc20-20020a17090325d400b001c6112f5d02mr4765528plb.55.1696031035416; Fri, 29 Sep 2023 16:43:55 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id f9-20020a170902ce8900b001c5076ae6absm17466616plg.126.2023.09.29.16.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 16:43:54 -0700 (PDT) Date: Fri, 29 Sep 2023 16:43:53 -0700 From: Kees Cook To: Song Liu Cc: Jens Axboe , linux-raid@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] md/md-linear: Annotate struct linear_conf with __counted_by Message-ID: <202309291643.BF67044DA@keescook> References: <20230915200328.never.064-kees@kernel.org> <169601526973.3013632.16756928162777602693.b4-ty@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 29 Sep 2023 16:44:40 -0700 (PDT) On Fri, Sep 29, 2023 at 04:40:13PM -0700, Song Liu wrote: > On Fri, Sep 29, 2023 at 12:21 PM Kees Cook wrote: > > > > On Fri, 15 Sep 2023 13:03:28 -0700, Kees Cook wrote: > > > Prepare for the coming implementation by GCC and Clang of the __counted_by > > > attribute. Flexible array members annotated with __counted_by can have > > > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > > > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > > > functions). > > > > > > As found with Coccinelle[1], add __counted_by for struct linear_conf. > > > Additionally, since the element count member must be set before accessing > > > the annotated flexible array member, move its initialization earlier. > > > > > > [...] > > > > Applied to for-next/hardening, thanks! > > > > [1/1] md/md-linear: Annotate struct linear_conf with __counted_by > > https://git.kernel.org/kees/c/9add7681e09b > > Hmm.. > > Jens pulled this into his for-next branch and for-6.7/block branch > earlier today: > > https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?h=for-next&id=e887544d7620f1d3cef017e45df7bc625182caff > > Do we need to do anything about this (drop one of them)? Whoops! Sorry, I hadn't seen it picked up. I'll drop it from my tree. Thanks! -Kees -- Kees Cook