Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2506495pxp; Mon, 7 Mar 2022 17:24:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyb/MtH22V0/oU9NERTA6vgIhJm7SETvoXzEDmON7G7oGoZ/53pd31TBCHfhNXEOuT8gHsT X-Received: by 2002:a17:902:f68b:b0:151:d869:3b16 with SMTP id l11-20020a170902f68b00b00151d8693b16mr12552986plg.85.1646702649698; Mon, 07 Mar 2022 17:24:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646702649; cv=none; d=google.com; s=arc-20160816; b=dsD+PnwvjVQxPQT23NzUjkMDk4H7jmXEjmvgbRp4bXYibA8zOxzYam66vvPU+U5m6x AGL6yEQwTob+Nl5HwZSvOt2ixyAgXw5QWsUYDiLbjxTY8XtxD0iSd08BIhgMhuLrA+fD /o/DK/xVLkD6PlsGsgUHsXzrlH2Y5u+Lmu5XElnog0jKK2/t/ClAWBHnZq4MBXPIUhYn V79ErQN7yoDB6HB6jNX/JbVrWu9+PLuGecSUx5zDk8tRIMLywZy4RNdToJIBUH0LiIbl E4wC/wQlY07y0yWoqsYIOdlDIodQW+fpKxJ0ZKcs69LiYMTdVwtoyqEEqd3AnnDSVBlY 3cgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=824w31sz3AEThlb14ikJs21AnVwPrOxIQO0R0+Md1/A=; b=ROQwPIbNvFgdD5gHUzNG9c/W+iPk/fYs4bh/st1pt5VLJR2eZKoAN/QffZNwtm67rQ aKlMRMXuJ9HN50Xx3PSJEqPFHi79CG7j8gGQyUsKbt5nf0f7KWXmTJqoH3bmXviuAyhe St52ELMiM4VsRVs09o2O6baN9T2BMS1DbdwxLxabESlo9dPcLzDB7v5+xlfL/ZkFvIQt AE7ADf6CUzl+/z0SbV8UPRDm7hy5tqqxaqFAiD5l2uDZBc85hWlgT0sK2rGkZr5Ci7j5 kisjaWvgzF/OdGlqhn6sAZTDQ4NX2fur667YBFPkjoHTccJxVP2VtTnVZkAvly0xd0zn sd3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HndUH1Xb; 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 d19-20020a631d53000000b00372edd40f78si14740133pgm.386.2022.03.07.17.23.52; Mon, 07 Mar 2022 17:24:09 -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=HndUH1Xb; 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 S241668AbiCGT5j (ORCPT + 99 others); Mon, 7 Mar 2022 14:57:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235127AbiCGT5i (ORCPT ); Mon, 7 Mar 2022 14:57:38 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C109289CC9 for ; Mon, 7 Mar 2022 11:56:43 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id p8so15250751pfh.8 for ; Mon, 07 Mar 2022 11:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=824w31sz3AEThlb14ikJs21AnVwPrOxIQO0R0+Md1/A=; b=HndUH1Xb9cowgiuAXkvKN+0oL9Mvyg+dNEvZzV5bYrd+whqiHS1WKyVIAKTlTywur2 JawTwVaKQDro31jXhHitKZju/U8Zqfsj6I0vftpI4J3YgDuvm4jZQ0rEj9RnAKq0Il+m sZDafCgOTzehP8uErNlnGCfHJdd593ME2FJJk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=824w31sz3AEThlb14ikJs21AnVwPrOxIQO0R0+Md1/A=; b=OGxE5gnL/OJz5jyDcT2ASg5gLSV76KC4zwv0jqsNNX/jZJPFQmgNMrgWcoaw8thNRg iXgF7/kuw4e8c2qP89OnZY1mCevJbxfF7wSOGQA8i4QsrOfaMznFU3dtVJong8nu0jTi SRMF4Il4TSI9aIu8p4cXdp0oygNq5XxO7tZ0L3wPE2ZiD3FbE/rvolVke3PvhWTqC861 GcaU/w9FURLjNVLPo7rKP+nqIIBSzEV15xrG0q66ijpSnNi6VWBtO50jIuyeCJcqSalW jpo26pxkyeUZuvPzrlqYUQL+QfjyIZAmQjOdcFnDHVEMtLGEUHTdDBoP9NAD4RRiZ28l /2uA== X-Gm-Message-State: AOAM532uH+7hgzo/Xy5UHLFEAAOVa6h7cNx2nQjdamJHye29coplgUSL qEXY68451Chz+5/1MWQsDHFFMeNmrD7xTg== X-Received: by 2002:a63:2c53:0:b0:373:7234:adf2 with SMTP id s80-20020a632c53000000b003737234adf2mr11138988pgs.111.1646683003219; Mon, 07 Mar 2022 11:56:43 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c34-20020a630d22000000b0034cb89e4695sm12838449pgl.28.2022.03.07.11.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 11:56:42 -0800 (PST) Date: Mon, 7 Mar 2022 11:56:42 -0800 From: Kees Cook To: Max Filippov Cc: linux-xtensa@linux-xtensa.org, Chris Zankel , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 2/2] xtensa: use XCHAL_NUM_AREGS as pt_regs::areg size Message-ID: <202203071156.8BA231E@keescook> References: <20220306064435.256328-1-jcmvbkbc@gmail.com> <20220306064435.256328-3-jcmvbkbc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220306064435.256328-3-jcmvbkbc@gmail.com> X-Spam-Status: No, score=-2.6 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,T_SCC_BODY_TEXT_LINE 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 On Sat, Mar 05, 2022 at 10:44:35PM -0800, Max Filippov wrote: > struct pt_regs is used to access both kernel and user exception frames. > User exception frames may contain up to XCHAL_NUM_AREG registers that > task creation and signal delivery code may access, but pt_regs::areg > array has only 16 entries that cover only the kernel exception frame. > This results in the following build error: > > arch/xtensa/kernel/process.c: In function 'copy_thread': > arch/xtensa/kernel/process.c:262:52: error: array subscript 53 is above > array bounds of 'long unsigned int[16]' [-Werror=array-bounds] > 262 | put_user(regs->areg[caller_ars+1], > > Change struct pt_regs::areg size to XCHAL_NUM_AREGS so that it covers > the whole user exception frame. Adjust task_pt_regs and drop additional > register copying code from copy_thread now that the whole user exception > stack frame is copied. > > Reported-by: Kees Cook > Signed-off-by: Max Filippov > --- > arch/xtensa/include/asm/ptrace.h | 7 +++---- > arch/xtensa/kernel/process.c | 10 ---------- > 2 files changed, 3 insertions(+), 14 deletions(-) ^^^^^^^^^^^^ Well that's always nice to see in a fix. :) Thanks for digging into this! Reviewed-by: Kees Cook -- Kees Cook