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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4DCBC54EBE for ; Thu, 12 Jan 2023 22:20:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Pb/mIABgX3dj1V0+ra6vIAhd3QWyppZiUMOoC2y9eDI=; b=dKF0dZ/UgIodN/ Ms8r9jlD+GA/fivCFGUgWh+GN0P9FrzzNYwY2TNqA9zQ/2UjZX7bxoswsWu4OkIK/o26b9QcWXoWh +67HzbCfdFpA3UNDWCCdHzPy17EPKnufqq9X0lFiSyyGxgkyOqQmaNi+D+smVNoR+iwMyCBAXIjZH qHNu3DbB/2KJsfyNS0G0h2+dvoF7tTKjWf961jB6y7rlztkm0lhKid255yryNvCDfNV/dE+WUtUsk 2WOFF0sZ7NWFjkXJdeX7fOUWNtZ/HkeBzJ+UHvCmwc4Zd7s3EIFio2vB8Dw2rgMhLIWxPtzTTV3Q2 /B/RSnV7sWx2MdANNRkQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pG5ua-00HMLk-Vc; Thu, 12 Jan 2023 22:19:06 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pG5uU-00HMK8-Pn for linux-arm-kernel@lists.infradead.org; Thu, 12 Jan 2023 22:19:00 +0000 Received: by mail-pj1-x1029.google.com with SMTP id v23so20554828pju.3 for ; Thu, 12 Jan 2023 14:18:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=LkkUAtBsGFEoG00/GsPhmmMLZLnu+OFTAhqGuV8pKmk=; b=J904GE6h944gQLvbjHlZg6sS2pePuFhi/XeoAULK/s0say4QLq7uyoAbHFO69N25NZ ACi+onPLfeHJNv7VYdXYA2g3rcT/ByOYTrCPHVfhWZhBuLuUZJTptCjYZTvGCA5ROM6Q BNkfA3qPS1sy0zQHtJZJ7z/es/a+pcKYXLoWs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=LkkUAtBsGFEoG00/GsPhmmMLZLnu+OFTAhqGuV8pKmk=; b=6Uoi6F8jMgCo80D25oVzHlvat5DsN12KO2W0xGW3pueRV/tpUyp/tbrR0CyK6HXVoF EImKB0+rCGTkmObAoXF8Z7k0Qdi5x+HpmLssRqGxTteeIo+6y8gvziatsF/e6O++upho jaGrw/RKna8SyZddnwFepI9APrGpFeExo4vlDX7h5JfASnbWECf3aooDCdMKzJ522aNj ZjDPfNGgX/vH9asKmu3YBJGre7xybPJWUXCL05bpacZiRntFTPVYqDDETpfCWEGrXmTN 1EQX7zEta2LHi94tydP+HEjjhNG1w0hX3BPhlLGL+xEuQw6Y6Id3YFLjn6fUKJ4b2EOt 8ltQ== X-Gm-Message-State: AFqh2kou2TeyAlCB8BG983wikxPAEPBYFweWoqQHrXJn30+s3q4sQIxE u5ncQ0wJ2dW6MtZQDpZ/hfSuvA== X-Google-Smtp-Source: AMrXdXt3b/bvmbDeMHndqi/fCqQFrGpzqIGB2g16KNmmr9McDQAUOSupvD+MN9W4KT3Pn1yTbpeTWQ== X-Received: by 2002:a17:902:ec04:b0:192:4f85:b91d with SMTP id l4-20020a170902ec0400b001924f85b91dmr7751672pld.46.1673561937770; Thu, 12 Jan 2023 14:18:57 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b00189618fc2d8sm12640526plh.242.2023.01.12.14.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 14:18:57 -0800 (PST) Date: Thu, 12 Jan 2023 14:18:56 -0800 From: Kees Cook To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, Sami Tolvanen Subject: Re: [PATCH v2 2/2] arm64: Stash shadow stack pointer in the task struct on interrupt Message-ID: <202301121418.F0B875E8C@keescook> References: <20230109174800.3286265-1-ardb@kernel.org> <20230109174800.3286265-3-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230109174800.3286265-3-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230112_141858_862047_AD068817 X-CRM114-Status: GOOD ( 15.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jan 09, 2023 at 06:48:00PM +0100, Ard Biesheuvel wrote: > Instead of reloading the shadow call stack pointer from the ordinary > stack, which may be vulnerable to the kind of gadget based attacks > shadow call stacks were designed to prevent, let's store a task's shadow > call stack pointer in the task struct when switching to the shadow IRQ > stack. > > Given that currently, the task_struct::scs_sp field is only used to > preserve the shadow call stack pointer while a task is scheduled out or > running in user space, reusing this field to preserve and restore it > while running off the IRQ stack must be safe, as those occurrences are > guaranteed to never overlap. (The stack switching logic only switches > stacks when running from the task stack, and so the value being saved > here always corresponds to the task mode shadow stack) > > While at it, fold a mov/add/mov sequence into a single add. > > Signed-off-by: Ard Biesheuvel Reviewed-by: Kees Cook -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel