Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3012215pxb; Mon, 18 Oct 2021 06:35:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd5r5rCirbJ1uMAcIEjbjYRCa6AAuBavXqcyIAbgUlm0dAY125JI4yjEnrk9W5kZfdmlI2 X-Received: by 2002:a63:b203:: with SMTP id x3mr23870724pge.239.1634564111663; Mon, 18 Oct 2021 06:35:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564111; cv=none; d=google.com; s=arc-20160816; b=kCSrJqFzm5UuIT+4+pLvYGErE8lL7IjP7n1V1JdGB+GX73imANTOOo+fy6zTk9Qwcv MI7c6i/++SONX1jsdsPse3phCaOg0GdwU55yNg8j+7VW6JBsIiD3jODOEm9Bii3yXqjT EODlrBdn0oSvV+dkWxIWKIVu5P0/8JsWhxsmnH1DVIigFdeTzHuQ1WDwVjBo5wkopeko hEaqu6fCMQtNfEzmZveE1EHx7JdieR3/LxC1N8zd/DxJIjfUsmAy/XzYlDBaYM4Tl+FB n96NmsoRYGELXWuSLmC7vMwPm0vPx6EK3NF1/tF9kB63/Kz2Bejvy1p9iQDPsVcoJOXj 8DtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kyR62fNOEnNvsnWbwevt+3JO/TF+vTfVE5DbetZWAfI=; b=WzGon8EoeTBVQUZh/DEFI0mEdeqPqalqTlPOjgayeCtvtuDnP5k/XBFgo0ZGl46FGB frg8f8H1UyOIvNqg92nrpGuFJnofQ7B1VGlh0K1UQVArqFXdx7Qj0KzZAN6aGFJvSrHm GZVpVv+rvlgUepWUGdB1TYrNLf4xVQfvAV1nN04DX82VY1jMaX+mmnOAW91yAcgL2XbR K4ZbOkOmxpLiy0jhvoBd/C5IayP8NCQm/mRhMfURpLdKMGHZaHCWM2vQLcI4iEYdYJFi Rzx5JYr3+X8IBlFxjBsMW7G1XkleKuRg/7QnjHcfwouqHWQdZZ/W2ACG77RPrSuXDLM8 N0eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OVPAmiJM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a12si19378940pfh.148.2021.10.18.06.34.54; Mon, 18 Oct 2021 06:35:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OVPAmiJM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233240AbhJRNfy (ORCPT + 99 others); Mon, 18 Oct 2021 09:35:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:41820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232288AbhJRNeR (ORCPT ); Mon, 18 Oct 2021 09:34:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C06E861374; Mon, 18 Oct 2021 13:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563809; bh=aDrrtYirxl9DD6ssBjNnq8RVSx5xf1PvKge7TK53Mxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OVPAmiJM5GfPBvQ3dL6Ar+jS+NoWSWtW25fOahyFJ5ojynemN4BYFA0MTmkyr+aqC WmP+jsqNB+lCJh5tuYej7O3o7wVOUGdHfscAoJ/sWYYRlJl2E+xI351l6O02GnrHUk b8Nx4YOSmUv+7Msu9tempR9t/359nWHPggZT2D2I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joe Perches , Ard Biesheuvel Subject: [PATCH 5.4 23/69] efi/cper: use stack buffer for error record decoding Date: Mon, 18 Oct 2021 15:24:21 +0200 Message-Id: <20211018132330.229106611@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel commit b3a72ca80351917cc23f9e24c35f3c3979d3c121 upstream. Joe reports that using a statically allocated buffer for converting CPER error records into human readable text is probably a bad idea. Even though we are not aware of any actual issues, a stack buffer is clearly a better choice here anyway, so let's move the buffer into the stack frames of the two functions that refer to it. Cc: Reported-by: Joe Perches Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/cper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -25,8 +25,6 @@ #include #include -static char rcd_decode_str[CPER_REC_LEN]; - /* * CPER record ID need to be unique even after reboot, because record * ID is used as index for ERST storage, while CPER records from @@ -299,6 +297,7 @@ const char *cper_mem_err_unpack(struct t struct cper_mem_err_compact *cmem) { const char *ret = trace_seq_buffer_ptr(p); + char rcd_decode_str[CPER_REC_LEN]; if (cper_mem_err_location(cmem, rcd_decode_str)) trace_seq_printf(p, "%s", rcd_decode_str); @@ -313,6 +312,7 @@ static void cper_print_mem(const char *p int len) { struct cper_mem_err_compact cmem; + char rcd_decode_str[CPER_REC_LEN]; /* Don't trust UEFI 2.1/2.2 structure with bad validation bits */ if (len == sizeof(struct cper_sec_mem_err_old) &&