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 41392C25B48 for ; Thu, 26 Oct 2023 17:18:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbjJZRSh (ORCPT ); Thu, 26 Oct 2023 13:18:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjJZRSh (ORCPT ); Thu, 26 Oct 2023 13:18:37 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4917E116 for ; Thu, 26 Oct 2023 10:18:35 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c8a1541232so10235405ad.0 for ; Thu, 26 Oct 2023 10:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1698340715; x=1698945515; 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=Xw07DRWLKz2p8vG1tYsMr3W7FGieeNrenFoAi4zFRnI=; b=HadBnEolRBsouoN5HKIQwrdKGT90ph91wFGZO1Kh5BqVkPACw6uQi6tPd9qfuGP5dz CyoAoLWht3zZNY4Gd6Mib7/yZdbWBCsVAg6kuvQRJrw2aJnC9DLN1yzLhSNERggO6nNX j8y9WPuWqJUdQ21PwjJL3VJWbH3ZyDOQiocKs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698340715; x=1698945515; 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=Xw07DRWLKz2p8vG1tYsMr3W7FGieeNrenFoAi4zFRnI=; b=KthehYG133DmHnxsRyrz9sXN5PhXOrBC050dCDTH4SFhQYhkHcuo755p7q3nKnnLab FwFoFGeNJfVnupeSlRL9L1s87tjYW4sI0Ef2bOS+qb4WpIvY/76DSKnZRic8nW0TFcNF Lznw8hnDTYPhyzRAQgjhKUEzzLx+OM41dfLvfarSRNplbw6Qz0Cs3FswfT9tToQwgQzC vgLcAAOCC8JKqyeDGgZnsYYefVb67gWkmz3Rmwnibk8WhBUCkX2UaH4Bohe43Nt9Y0Zs eKOg+FaGRx1Ert6a0TCHPLVYYCJIfYp7PF5Ns3rD+foTXGqP1KagrEqLPgHan60a+lq+ OShQ== X-Gm-Message-State: AOJu0YzC6PfM3ZhPby7qqRQImmC564K62yrwehzm0Ikz5U0cqQu2cymU f1wMLHgvO1rEHVoQa8RGDfdpJg== X-Google-Smtp-Source: AGHT+IHJaeoDvNexJ51nTj9W7C9gqugA0dotXJMCxzzBW0CIkG528rxu+gpmgCcu1OYKpZe+Tr0uBQ== X-Received: by 2002:a17:903:40cd:b0:1c8:7822:e5c3 with SMTP id t13-20020a17090340cd00b001c87822e5c3mr143766pld.47.1698340714728; Thu, 26 Oct 2023 10:18:34 -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 b3-20020a170902d50300b001b8622c1ad2sm11228966plg.130.2023.10.26.10.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 10:18:34 -0700 (PDT) Date: Thu, 26 Oct 2023 10:18:33 -0700 From: Kees Cook To: Christophe JAILLET Cc: Robert Richter , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Sergey Temerkhanov , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Borislav Petkov , linux-edac@vger.kernel.org Subject: Re: [PATCH v2] EDAC/thunderx: Fix some potential buffer overflow in thunderx_ocx_com_threaded_isr() Message-ID: <202310261016.2D17ACACE@keescook> References: <91ec35cd8e2e86fa3d24c2e8ea6970e0437cdfd2.1697908406.git.christophe.jaillet@wanadoo.fr> <202310241629.0A4206316F@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202310241629.0A4206316F@keescook> Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org On Tue, Oct 24, 2023 at 04:39:36PM -0700, Kees Cook wrote: > As the replacements get longer, I would encourage you to use seq_buf > instead -- it does all the length math internally. For example: There's some ongoing work to make seq_buf easier to use: https://lore.kernel.org/lkml/20231026170722.work.638-kees@kernel.org/ Perhaps we can add an "alloc" and "free" pair too, to handle this case: > msg = kmalloc(OCX_MESSAGE_SIZE, GFP_KERNEL); > seq_buf_init(&s, msg, OCX_MESSAGE_SIZE); But perhaps it's overkill... -- Kees Cook