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 506C9C43334 for ; Mon, 25 Jul 2022 10:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232971AbiGYKOf (ORCPT ); Mon, 25 Jul 2022 06:14:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231654AbiGYKOe (ORCPT ); Mon, 25 Jul 2022 06:14:34 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B49B164ED; Mon, 25 Jul 2022 03:14:33 -0700 (PDT) Received: from zn.tnic (p200300ea972976f8329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9729:76f8:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id EA3AC1EC02AD; Mon, 25 Jul 2022 12:14:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1658744067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=UG3HyB+a1rEuod/npdxD9V9DqUguu9NB6mUos5iP184=; b=Lq3tyrIyax/V1WQYaRZGfpC21SBrLPnzksuggi9y9EcQCe2hA531lfI3iR6Bt3zL+gvQXB O6eRlG9m/yKACmGBma6zMLOGHb4J6Z87JoXhkWLUKft/IuJ2iYQHZmSxOynoRUYMk2bmCR eF4lXkhsCgLg9j+hESxedamBcCdpqbo= Date: Mon, 25 Jul 2022 12:14:21 +0200 From: Borislav Petkov To: Robert Richter Cc: Toshi Kani , mchehab@kernel.org, elliott@hpe.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] EDAC/ghes: Fix buffer overflow in ghes_edac_register() Message-ID: References: <20220721180503.896050-1-toshi.kani@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org On Mon, Jul 25, 2022 at 11:53:06AM +0200, Robert Richter wrote: > The dimm->label buffer must be pre-initialized zero. This broke with: > > b9cae27728d1 EDAC/ghes: Scan the system once on driver init > > since krealloc/krealloc_array() does not zero out the new allocated > buffer for struct dimm_info in enumerate_dimms(). This uninitialized > broken struct is then copied in ghes_edac_register() to the final > dimm_info destination. Originally, before b9cae27728d1, the struct was > zero initialized with kzalloc'ed by edac_mc_alloc() and directly used. > Now, that a copy is created first, this copy must be also zero > initialized. > > IMO this is the proper fix: Maybe, but this needs fixing too: /* both strings must be non-zero */ if (bank && *bank && device && *device) Obviously one of those strings are zero coming from that BIOS... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette