From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2BFCCD612F for ; Mon, 9 Oct 2023 20:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=I+5syZzpOL/ly5t4itCHY/IQf+n767/O7GCDPrnRYwk=; b=1nlRWcVe4mbV8T x9jHrwQ5aufmFzU9QGvuCiEYqwEoRLuk1TR8RZASqIeJSFG+pXFsHwYtWQtHt4aqho8n4SbftUXYy 9xvqM4MLnFjx+AJvEWVi2Wpb+YuVQsd9Ka4fpisY0Csw2j67QrhdS1NWllSX3YMrTUW1hZHMFsK+9 oJYsSVQBEtb/EHk88BLdE+U85aQa5MWULT3IBMdCEGWKjIVa6JowsfUFPCqWR3DE8dpxmWpVvprWH L4eX4DtH/OF41sznHwZBUSVh0aR+0/xonA0llWIP1WMANV4avGnQtnx0ChgyrQE5yp9HpgeRIY5w3 L8kYM7H9McsbqZrpO+5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpwQC-00BWt9-2y; Mon, 09 Oct 2023 20:00:08 +0000 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpwQ9-00BWs0-2I for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 20:00:07 +0000 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-57babef76deso2703245eaf.0 for ; Mon, 09 Oct 2023 13:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696881603; x=1697486403; darn=lists.infradead.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=XnnNZrfQHu6U702fU9qv9YujuMNy/CqVElyAPuDlNS8=; b=etPPSnzmJgzQYzJLjCfaPs3lrXtlSK0BY7Fxbw0vC2ycifMhWx8OJ/rsbHe5xG+hj6 tBoLjBe7adqQipQF5SIJ5rWyTnn2YUTyXEztaEnLHbzxVD6smSlGZCuDQ9DHo6Gj2/7/ odQemWvjtx8YAQKvKPWUqdfny0MuOiNhihE94= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696881603; x=1697486403; 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=XnnNZrfQHu6U702fU9qv9YujuMNy/CqVElyAPuDlNS8=; b=fKYkmoL5BOZoORikvyJkquT+Lkk3a/XBPQpMrMTZz5tVQnTr3pkhOfLVsqkrD72H4h bpjs1TjAUNDCigreRHgcg+1vbPotUEfMEiT3dALNVwz/v9DO3dkmTL7zasEh2PfH/GZl fi4UlemM46s4G4hMpRAqEMK9+omaDEFCCcK7DRnZfXZ59yAqA4Y+/5l7jyaDlE6DgzVt AXaLXzjzZUD6CT5U4LvvibW6ol6+ynqS042+AID80fPxpAoS9+lxLzFguqbfunQ1h4Lr O/hfsmhBTp8MjesV7LSIOfXGpAgW28pAQHNIcO3PkzXtBXum17+smAOW8th4jpH7b7D3 24lw== X-Gm-Message-State: AOJu0YyAEz1Jfik0nowdlKLrDs0Sp2DiMqgyc0zpIHVFt0YgE9FnPIQ2 g2+N5NKogKraYEKSW/xFwWQL+A== X-Google-Smtp-Source: AGHT+IFr2diKV0FUnPCKvbVJgM9zVEQvrx9lAF5Q6PUGXjcm/39HFBRDZ6m3k4XI8U3B8QraX/ZFbw== X-Received: by 2002:a05:6358:42a6:b0:143:321:f36b with SMTP id s38-20020a05635842a600b001430321f36bmr14035556rwc.18.1696881603565; Mon, 09 Oct 2023 13:00:03 -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 b21-20020a170902d31500b001bdc8a5e96csm10053257plc.169.2023.10.09.13.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:00:03 -0700 (PDT) Date: Mon, 9 Oct 2023 12:59:58 -0700 From: Kees Cook To: Christophe JAILLET Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Heiko Stuebner , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] mtd: rawnand: rockchip: Use struct_size() Message-ID: <202310091259.1D9E73DAE@keescook> References: <481721c2c7fe570b4027dbe231d523961c953d5a.1696146232.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <481721c2c7fe570b4027dbe231d523961c953d5a.1696146232.git.christophe.jaillet@wanadoo.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231009_130005_835444_CFB24A97 X-CRM114-Status: GOOD ( 14.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Oct 01, 2023 at 09:44:04AM +0200, Christophe JAILLET wrote: > Use struct_size() instead of hand writing it. > This is less verbose and more robust. > > While at it, 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). > > Also remove a useless comment about the position of a flex-array in a > structure. > > Signed-off-by: Christophe JAILLET It seems the consensus is to keep the struct_size() changes together with the __counted_by annotation, so yes, this looks correct to me: Reviewed-by: Kees Cook -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel