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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9198ECD612F for ; Mon, 9 Oct 2023 20:00:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378512AbjJIUAK (ORCPT ); Mon, 9 Oct 2023 16:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377401AbjJIUAJ (ORCPT ); Mon, 9 Oct 2023 16:00:09 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68299A3 for ; Mon, 9 Oct 2023 13:00:04 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6c665b2469dso3282129a34.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=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=XnnNZrfQHu6U702fU9qv9YujuMNy/CqVElyAPuDlNS8=; b=C774o6WSf/gt2YrkMRsHjeigz24wLn36GDvorNU0gUCxqUjrVcUsHb/F5XpmpaHRb9 GI4v6CFdNJAWydxM1Gsft3erUrCeOjIn9yvdVpi8Cuvfd8MlGlVGiChGLhiq1yCUoicR pxLEmdRAdkdSZtOe55jC1HQc3RShNIEZNQI/M= 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=qWPYVj8xtpr3MJeF8yPgrJnTJuVljiv+73J/v2eRMQTfFc1ay4j6krch1EAAdFEtMe lJgxIn5D6PbzgdLT0QRqCb08DdHAMeGRQ+oqjzJoan8CDZVrkPm/8tl7rUc3O6vvb3BQ VHRe71bXQ6iMx7fKmdFkOsX7XfvEqTHgAOMf/xIbQyLLFGvwjtHQHiQVNyphd1iK5gJM SN1Lem83/jSCA97Q7Aa5ZQk6wvKQYN5fw7MvNSABoYi6KRrbfv89IimcJN2xaCY35DrM MX3VPlA+DJZfrSNZArxfqV185s7NExqLN809G1QomvRuTWJhWHwTzvfc0klC6MIOsNYz Z1ZA== X-Gm-Message-State: AOJu0Yxrb4wPKBJAqL8CIBkhdQk2JlzNZjyTp3Yva4aOTWfJsR3z8qUe eWo/aaZEfpNVWCWdpME/e/056w== 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <481721c2c7fe570b4027dbe231d523961c953d5a.1696146232.git.christophe.jaillet@wanadoo.fr> Precedence: bulk List-ID: X-Mailing-List: kernel-janitors@vger.kernel.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 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 F022DCD612F for ; Mon, 9 Oct 2023 20:00:15 +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=bWyAsV0qZjasnU0kyWIsLsJBOFSlmXpUSB5STX1pfyQ=; b=P8quTXpBy2cxpK LQaVUapLg6gK96NGtXaMHsJubw6Wvcb0mrtcTZTpqYmgn805uFQ7UOLcDWWg9QqqHewnX6PGb640U TFk/b2JtrPqhUd6fouw5YcmGMNTm1xKa85Mse4jUh/HRD28f6wSWO9F5ogAbu84/SvYpn8vszDKEa zyjt3+1x38gkxE7s9kgve5H/mOIxXOyuMruibuU7nL4xn7U91f24EgC2pbasGKLVyqQRcsqqZC3pE xRpB7K9P7sRNGtXD9nN2WmvpwqYWzVfR2WTz4SKagmkB3MNUdi/Px7u48s/pX2MyHq9EIJ2qi//rA Kb6KjMk3p28yN2WYpiNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpwQD-00BWtS-1N; Mon, 09 Oct 2023 20:00:09 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpwQ9-00BWs1-2I for linux-mtd@lists.infradead.org; Mon, 09 Oct 2023 20:00:07 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-57e3c2adbf0so2692790eaf.2 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=BoX6uHoCAJQgo305syH5OR33Gf3qoMIbKf1yI87RQe0d0bC/DKJfAKf6Z2PgvVUNmN blH0ffeY8v5qESjGcph71+9SBfyTrtNiglhFXKYrHWpll/SFtJ3Hzt2zmDetwai03mvf znxy6IEG9+uTRCAQgJqmAaeQoh+lcmo3Up0edMqX78QjuLs2JRa9fplEAzBQuPYSyCtk qd89v0rNzG8tllJn5FIKmlVELTks56+KOnJRqd1EXSHECcIBjJJMnbLsGtfikFkJcVyL OpDbZ1e/xFK/73KzgI5g0FDV9mQp9/sY5HKlED44vd6/kK9urfJnJiwhXMvnL+ZEWzgt udrA== X-Gm-Message-State: AOJu0YweRESDFHzzPsFBW5BlzONg63XW0ZQszgNHZmtGVbchng4z6hII A4WU0CJrjiTQffT99Tycdebcuw== 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_834167_206B3B4E X-CRM114-Status: GOOD ( 13.79 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=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 MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ 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 6737FCD6131 for ; Mon, 9 Oct 2023 20:00:29 +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=BCKnssN8XY873pjqxbEzCgDHYzyO2iDdh9kc5Frl2lE=; b=aSjFDX0w+QR4Jn nD6VoEdqZX9UPk4ptF1fyGVsTbpLJU0p9QOiugA/x1nMfUlu+XTeZU0cYJIEWCPLx3chLn0wr6Izg DH4neU9hxjM1iUeSZQu0hRpGra76k7EiPvWppTAHSlP/hTELT/CXvJy+SQzM2SDS003tpCi5tzh0u pCoeGj85vzxegumfgWXkeUTmIBryZpRgcvYlduH29Tvd0D7QTVd8GR4X4jwwAlhe7MgoCgrNlpAUn Du+XIKjYGqKgYTEcp3EuAHidKkEQdT0P9q/8y4SvHnzsvksIYpQFLCL4cL7Jg5Df0yaFzPHhsrf8c fjgjH4r/n3VIYixsZ9og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpwQE-00BWtu-1p; Mon, 09 Oct 2023 20:00:10 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpwQ9-00BWs2-2I for linux-rockchip@lists.infradead.org; Mon, 09 Oct 2023 20:00:08 +0000 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6c62cb79b02so3268261a34.2 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=s1bj3xwo0+/yU08Bsu/KFoqUrgWofFWF+Z11FC68/rUw0X24P2aXhi0/4Fo3IfOYo0 Sa9zSe/dwvT4wCXbYPIWCbuwlIKPkX8PX2Ygg4gaFAl6W83TDQgBLAt3sMdugtn1XBmJ nuDWVKryvZSjXw8wCAzjV6PMTcpGeEfYH8pFjiAUJclEiS+0IkCbP4lAVhk3yEY8ETkv ej2ZoHpzhoZ/Mv0cW5+dqMf4k9yHVTKAzy3jxxNpL1bFk2dH1yUGpKTKRI5SeJrFqK4+ jdmKDRKZbsEXdGq2PPEAFznaY1Z7B+/VeGQx5uqLXhrLnDU8Kd4yvdpPIE/+ayAjqK2G Ga7w== X-Gm-Message-State: AOJu0Yz0rGlTv91vXGL9BCBlWcojbYoLa9tTmT5im1VwO1vbUivdPtRZ fJFOlimg5VHyoB2so3PoG+eXGw== 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_834026_D367B9BF X-CRM114-Status: GOOD ( 13.17 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=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-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip 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