Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2469143pxj; Mon, 10 May 2021 03:51:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoZ20ficS5tbOPTuTjSz75vRsmz6/5AKyjzustr8y1i1tlNsRGPa5yddfL39OJX6tFmiVw X-Received: by 2002:a5d:8c89:: with SMTP id g9mr17592011ion.27.1620643916711; Mon, 10 May 2021 03:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620643916; cv=none; d=google.com; s=arc-20160816; b=ZG2+T4SdmojAv8mjEorFQHpCtJ3GIBaF2L/jYnMV4ucDZe2WKYGwxQbQP54wBC8Ywb Lo2THY9x6OWsCfJ5CLcgoYZ7aDGDtqmy2vvWBoPQvcq6eEUwtW4HXAgXDU6DY7M1HY5k a/DDRLpQ3o/hfwpUDazrOngiCoMuCwOfAouB15ftpfifClZbnBRxTjgb6qZObusGr4ph GgY05qRjEpmwyadwrdT1mVSNGugbJ3CeoOkMV9BebcTXWxfje7+XeQPOmKGRlH+/MpC3 hcpND/yPHfa0cjBFcXrt4ivUM4Tm5X/2S3dQfYyHC63ETseOjq0wPaLiFKaTTLIlu3gW D5iQ== 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=TYPubZ1Zlzb+Enq45ENuVHZhIRqzbvsNOPOeCuzB0p8=; b=J+c/aGP3l1WAv7m80z4QwEIWqcNMJwtcHaqO5e69xIcOKjEceDquz0nosO1vetFCmc Bb/JCuQiZ1t/VuJiVNe2XXMN4U827JyS0HHV24zI+PlNRSyhpngnCxI2BQAA4EAJZVYk XC9BaoYGg6b3JW5USyZKkQf3f50vnm/a+oUI8KJW1K0KS6+pOFbCwL+r2+r6nNy6U0tS hbAAZYnV7E81v46g5ekriwpQDAykvMML6KT6B8NmewrJi4vHmn7tldj/c/Rdq9qDFHPS Jxe9h1FsF3n9WZyaSM3XsMQ15B4VFEbCkAZKsn/FdjeHvd63DA+jTffeBsVu/3yCLYxK IPDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KPEzW2mV; 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 a5si15833113ilq.155.2021.05.10.03.51.41; Mon, 10 May 2021 03:51:56 -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=KPEzW2mV; 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 S232210AbhEJKvX (ORCPT + 99 others); Mon, 10 May 2021 06:51:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:50010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231802AbhEJKlE (ORCPT ); Mon, 10 May 2021 06:41:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F1A56191C; Mon, 10 May 2021 10:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642715; bh=+hon7tRePnHNKSbakAjM6yRj1+EL6QAEwD/NoxkqwHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KPEzW2mVYih2JXzkaUCcKQcKcPbXl72rcjRgDODXHYSQDwaHvVt0kf8Ooo6DPZspX sGNFdaAq5BwPpqJGe3rSs7zLRY7jyYKETYtOjgBj8Pe3/Je1LF0eJWE8EzyFN3hm7Y qQWMJqRaahEjzB2JFZ6FYTm5uZabm3QDeq1MVaKU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Serge Semin , Miquel Raynal Subject: [PATCH 5.10 022/299] mtd: physmap: physmap-bt1-rom: Fix unintentional stack access Date: Mon, 10 May 2021 12:16:59 +0200 Message-Id: <20210510102005.586549859@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Gustavo A. R. Silva commit 683313993dbe1651c7aa00bb42a041d70e914925 upstream. Cast &data to (char *) in order to avoid unintentionally accessing the stack. Notice that data is of type u32, so any increment to &data will be in the order of 4-byte chunks, and this piece of code is actually intended to be a byte offset. Fixes: b3e79e7682e0 ("mtd: physmap: Add Baikal-T1 physically mapped ROM support") Addresses-Coverity-ID: 1497765 ("Out-of-bounds access") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva Acked-by: Serge Semin Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20210212104022.GA242669@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/maps/physmap-bt1-rom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mtd/maps/physmap-bt1-rom.c +++ b/drivers/mtd/maps/physmap-bt1-rom.c @@ -79,7 +79,7 @@ static void __xipram bt1_rom_map_copy_fr if (shift) { chunk = min_t(ssize_t, 4 - shift, len); data = readl_relaxed(src - shift); - memcpy(to, &data + shift, chunk); + memcpy(to, (char *)&data + shift, chunk); src += chunk; to += chunk; len -= chunk;