Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp4108096rdg; Wed, 18 Oct 2023 15:36:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGS2uCMXPa3/KkhDy9AnfNTnNWXslchtYQXZQr08+4+YFwKKjTvol7zP3Sww+ce7izKJBBr X-Received: by 2002:a05:6a20:54a3:b0:17a:7c2:d4a6 with SMTP id i35-20020a056a2054a300b0017a07c2d4a6mr540628pzk.55.1697668592870; Wed, 18 Oct 2023 15:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697668592; cv=none; d=google.com; s=arc-20160816; b=NKKLL8Da0MyzFaFAZAIg5QvTRdCahZhFiv8Dr/W5/NNm+NUFE5zmRk/dZ7rCuAbU7e A30rRoE1M9pg8+aC0h6YmQsx8u1mmKaSaNFzpBaFKlkCtmHbQO9Ew/14qPLME/JcgBOz UcfIk0Srz3KIHk52dvz/mUMkvEONe2DK9Nhs7akodG6wjIZFEeuCgC4cyEwaAp7W7NmU MuhO3p1H2bBtRecB0Hjxma0x0Y+4HypJ6e0rApk7q38VoybDq2uNZ7xDHL/JvqH+RwQs kqT1blvY6ZguimoCTeSoXdghzqErngdW6JtR/H2ejqHaUdkHOcCnIK8gS5rGlJULgX7N v/jQ== 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=gU8UgFLtIwBMnNin+UfjeLA6KRbmnG6Wd91XkYWntpA=; fh=wGZ5NFjxrvWCmf9jcybko96on6/NUFzjkMY7CPpuTzc=; b=iQGdF1lKZRzY5O+knazStREjteJ3fULcRrWcz1MJofRrQhsQG03RD1DLtdFyb9F2Hi JekUlziW0Vpov4Tt3/aPqXhegtbx98yNUAC18TFeYlb+6yvXnrPw3Czl3JMTMBMuN8U3 +WbtFuBhJ/N06lQGep+UCpEk318NP+PpzAddmV8O2u6ONuNeiYUAYo+TiVW2iUdJnTje FdEKD8Xas/wK5gNdYJhERODnW/l404dE/fcuiV/eotTsBXLK+U/jXJ6KKj8DRDseL2Ny sw8KiIQ4L3OacCarx4CKhgFWL60Bo3IPl+VkCL35vhGiomE4scQKhZcaL/oL2zrBROKS oR+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="GQhkVl/9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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. [23.128.96.36]) by mx.google.com with ESMTPS id k26-20020a637b5a000000b00573fa8f2829si3195309pgn.383.2023.10.18.15.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 15:36:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="GQhkVl/9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 67EED8158318; Wed, 18 Oct 2023 15:36:29 -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 S231217AbjJRWgI (ORCPT + 99 others); Wed, 18 Oct 2023 18:36:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231199AbjJRWgG (ORCPT ); Wed, 18 Oct 2023 18:36:06 -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 78A8011C for ; Wed, 18 Oct 2023 15:36:02 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c9d407bb15so62379055ad.0 for ; Wed, 18 Oct 2023 15:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697668562; x=1698273362; 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=gU8UgFLtIwBMnNin+UfjeLA6KRbmnG6Wd91XkYWntpA=; b=GQhkVl/9fDceZRGSVUreqYnt3zuY5DMfBTEFTanW2ex901gUNulYVNrrmdTLIvHRt7 w54JVgMxU+iBiWwDff9UJNcaBR6Dyixjer5sedl1HZc/Vt5DHZLrAMffHaHQyWUOYFYS Sq/fV1rqYB1Sjq5yIIjAdwZqeYPzg/ybbts/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697668562; x=1698273362; 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=gU8UgFLtIwBMnNin+UfjeLA6KRbmnG6Wd91XkYWntpA=; b=MyTVcbNx26dTsXF3R0kaCICC1GvTDGaWMzwOzQ9U8+UNg/nGAE4/YNGNed2iXWykXi HBzUeblPXQYxD7pJLkFNrnzdi4Vha1TEOltRg/iwfcfIoKD9Qz6l3pm6vl4IXF5uap2Y DY+mXU9mOUry13v6eDdRF1ONIeKL9HZPrFdkbSxonE3T+Cagwla6amPB6Ec9CZor9AV0 eyHCzZuYYo+LM8UxunJ7IHWGiE3uPgmsNJGdt611ycHoU1DvxivBFrdR7zSq3AdPsue3 vdDlncqxuKrLFKzbyICaAD2/xMXVTRFMwLAlgO8fx3qXyfKYuXGXgGEn0o0GIEyNSRkA VvEQ== X-Gm-Message-State: AOJu0YxyngBL5CaMfqYOGJuKw7qOAUa9iC+xZRhLnMLlGn+12n7afoId qWW7HR85vPBNZ5wKgI+jYZGgyQ== X-Received: by 2002:a17:903:2342:b0:1c7:5f03:8562 with SMTP id c2-20020a170903234200b001c75f038562mr729819plh.30.1697668561892; Wed, 18 Oct 2023 15:36:01 -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 iw6-20020a170903044600b001c0a414695dsm453085plb.62.2023.10.18.15.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 15:36:01 -0700 (PDT) Date: Wed, 18 Oct 2023 15:36:00 -0700 From: Kees Cook To: Kent Overstreet Cc: Brian Foster , linux-bcachefs@vger.kernel.org, kernel test robot , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] bcachefs: Refactor bkey_i to use a flexible array Message-ID: <202310181534.54934E68@keescook> References: <20231010235609.work.594-kees@kernel.org> <202310131637.D0C66BFBA@keescook> <20231018220407.b5dvm2ehibcqvhzq@moria.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231018220407.b5dvm2ehibcqvhzq@moria.home.lan> 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]); Wed, 18 Oct 2023 15:36:29 -0700 (PDT) On Wed, Oct 18, 2023 at 06:04:07PM -0400, Kent Overstreet wrote: > On Fri, Oct 13, 2023 at 04:44:21PM -0700, Kees Cook wrote: > > On Fri, Oct 13, 2023 at 07:26:11AM -0400, Brian Foster wrote: > > > Hi Kees, > > > > > > I'm curious if this is something that could be buried in bch_val given > > > it's already kind of a fake structure..? If not, my only nitty comment > > > > I was thinking it would be best to keep the flexible array has "high" in > > the struct as possible, as in the future more refactoring will be needed > > to avoid having flex arrays overlap with other members in composite > > structures. So instead of pushing into bch_val, I left it at the highest > > level possible, bch_i, as that's the struct being used by the memcpy(). > > I agree with Brian here - I'd like this buried in bch_val, if possible. > > I also went with unsafe_memcpy() for now - that's now in my for-next > tree. I'm not seeing any advantage of DECLARE_FLEX_ARRAY over that - > perhaps later if we could use __counted_by that would make more sense. This won't help here because of the combination of -fstrict-flex-arrays=3 and -Wstringop-overflow (the latter is in W=1 builds). The builtin memcpy still complains about the 0-sized destination. I'll send a v3 with this in bch_val. -- Kees Cook