Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp60071rwb; Thu, 12 Jan 2023 15:59:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXsi7UKWYFatJkHTPH+WVTFroQ+j1qDPEUSwL0vR/lMYJxOqn7Lw89CkQMdJ58gtq+M4BrSc X-Received: by 2002:a05:6a00:d5e:b0:589:a782:470c with SMTP id n30-20020a056a000d5e00b00589a782470cmr7072620pfv.2.1673567973593; Thu, 12 Jan 2023 15:59:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673567973; cv=none; d=google.com; s=arc-20160816; b=T7rqxUlKd6JxbT+bOoF08/Ha8KHtyNByHr49CXdvJVCaATifyArTACh21mUSJEOfON 0bhel9cHfPcgxLOitSroHMiCEzG8otRW2wiCqVDRGA2/zzi19OwW4TENDVl8CV3b745u pmh/1So7HpOVTDHs1Q5fHT5fH9dyG1oF5w38SH9Cj6fV4B2n5Fnk9DQ5242nrgWSE6oF gzMQcbxPwAcPkCGVYpPo1dP1qOfAdhk1F14ZHJdJvrBlhuWVfz6mAr93CufBXWAhFuot 5wFU3E0E/+aZsgZ34lKS+JGQRF1znD9aY12EKZvOWgwHuZHi0Kx/TolXkkT6vhbKJuaJ Rfig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=uzvQTLIl4IsQotVAdtAgGVmuDwl5Q4M7f6FylARn+9c=; b=H5SUNi8mfuZCPSNrJusyO5UzasJ36vUWl9Fk4CJ9zOoYN2XtIyI3VIUbEJW7PTnVvf RkFjPomPqI4buNqG6icHfmpB7uG1ya9I1rXMNAY4jBekp4X2WwaFyIPOANUlqEq0Iyrj 1RNmmSMnOkLzFVTCh1xwoVd6cog1ZLrPKauX4zKMSVITH9zw/7ThnjVShUpfXw59RXvi DQ1vR4GaiePsrXy5pEz20P/5e1EF7tq6ZLGvWNzare5+/dPf4/d4V0kvEJ26WkFhKxiq lRCsKAg3QtrELJVEzCXGNLzzgA30Dg3Q7Ty/Ta3EZ5di5EvfTPubO9RxTk3dwcWgS9KK KMKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Nr7Y/Wha"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17-20020a056a001a1100b005820fba237fsi20435610pfv.302.2023.01.12.15.59.26; Thu, 12 Jan 2023 15:59:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Nr7Y/Wha"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232583AbjALXZn (ORCPT + 52 others); Thu, 12 Jan 2023 18:25:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232283AbjALXZm (ORCPT ); Thu, 12 Jan 2023 18:25:42 -0500 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1766E625CA for ; Thu, 12 Jan 2023 15:25:41 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id cf42so30689939lfb.1 for ; Thu, 12 Jan 2023 15:25:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:from:to:cc:subject:date:message-id :reply-to; bh=uzvQTLIl4IsQotVAdtAgGVmuDwl5Q4M7f6FylARn+9c=; b=Nr7Y/WhaVdcQbYBYZpdYD/bbkZMdH3A1fULa10XQvTpJcJ2Rd+q6iOILylAXcrvZ3W k1VWAbetLG8bycRtyxz2WigmGfmShkeg0a/1AYKtaaFgQG+ldxw+gUWxfNfXFV5ayAP1 4hoOHp9cv2c5vAE3yc/2HIZgp8HSFfmy36gec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uzvQTLIl4IsQotVAdtAgGVmuDwl5Q4M7f6FylARn+9c=; b=1aAYdI6sYO1y6MLGB98pdQ5hXMbDaZQWVWsJYhBywz5EcxaGBcfYAI2F0U15GtXTsl ZqyLs9fCcQgtwCM5EhORbKbGDuHSEWAU6z5XWOj5tn4rEBvqL4bVACyvAeFr+lV6y15C V5d2zzD72OOaYe1Ox4ZoqpyEnUU5kjq9MOaexl4bI3kLiuAxw+jIUaE2x7X/AZwva7E1 Jw6GsTgJeTB8fRXiCEDKAz0KvYPMGP26yBRq617UDjJhAtemgi/6SO/d6UlU1ZOwizJK r9PcSo2wDHOLvMtqtY975YPZ8K4sHYUsiD2qspA33W3smqMPTP48Sq7o2swXp9scH4yR A23g== X-Gm-Message-State: AFqh2kpCodMte4k/7C33usIZAy9cPQlB5gTCzUBbkxgC+T/s+sKGGr4T wYjucIA7c48ihPR8fB4p8RT9Whxo1B4Y3bxCxfhCVw== X-Received: by 2002:a05:6512:2346:b0:4cc:6ce7:6614 with SMTP id p6-20020a056512234600b004cc6ce76614mr1205998lfu.83.1673565939472; Thu, 12 Jan 2023 15:25:39 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 12 Jan 2023 15:25:38 -0800 MIME-Version: 1.0 In-Reply-To: <20230112230312.give.446-kees@kernel.org> References: <20230112230312.give.446-kees@kernel.org> From: Stephen Boyd User-Agent: alot/0.10 Date: Thu, 12 Jan 2023 15:25:38 -0800 Message-ID: Subject: Re: [PATCH v3] firmware: coreboot: Check size of table entry and split memcpy To: Jack Rosenthal , Kees Cook Cc: Paul Menzel , Guenter Roeck , Julius Werner , Brian Norris , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Kees Cook (2023-01-12 15:03:16) > The memcpy() of the data following a coreboot_table_entry couldn't > be evaluated by the compiler under CONFIG_FORTIFY_SOURCE. To make it > easier to reason about, add an explicit flexible array member to struct > coreboot_device so the entire entry can be copied at once. Additionally, > validate the sizes before copying. Avoids this run-time false positive > warning: > > memcpy: detected field-spanning write (size 168) of single field "&device->entry" at drivers/firmware/google/coreboot_table.c:103 (size 8) > > Reported-by: Paul Menzel > Link: https://lore.kernel.org/all/03ae2704-8c30-f9f0-215b-7cdf4ad35a9a@molgen.mpg.de/ > Cc: Jack Rosenthal > Cc: Guenter Roeck > Cc: Julius Werner > Cc: Brian Norris > Cc: Stephen Boyd > Cc: Greg Kroah-Hartman > Signed-off-by: Kees Cook > Reviewed-by: Julius Werner > Reviewed-by: Guenter Roeck > Link: https://lore.kernel.org/r/20230107031406.gonna.761-kees@kernel.org > --- Reviewed-by: Stephen Boyd