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 X-Spam-Level: X-Spam-Status: No, score=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DAC9C433EF for ; Wed, 8 Sep 2021 07:49:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D69A761175 for ; Wed, 8 Sep 2021 07:49:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351375AbhIHHuC (ORCPT ); Wed, 8 Sep 2021 03:50:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:48238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351120AbhIHHs4 (ORCPT ); Wed, 8 Sep 2021 03:48:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8569F61166 for ; Wed, 8 Sep 2021 07:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631087268; bh=g+KPm8DVe7Iqx7fs4fJUSuXyAmNC6ljwYldCl8uZcPY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=J0ah/Gbc6BEStYii3MQu7/yiQ+zrxiYuTepLreOq5Sbmtp1p2kc5fGlT2ni2SJPg9 LLEupvji7CZ95xmDVR2tkCxqDV4f4hOVvlcoTXWL5C798wqE3JurN6Q2Z4XGmGtY7X 1sXay84RqOToCvPCw3rjpilYZyc0sIiOg0SRyGcTHEccFJXn2GkfJyo1HWkmSacRiz mEc+wnCDo8I7FZZApUkc7a2ZjXCtbFinHbPhxuPEAKFdRx1JlaAUKjFzpj8rxgEIcJ 13gru/HpGhRf1NU6pWNs43WQVIjQa1SIwygAva87ggeu2Zkoe2WioiVHbIU5fpUeHi sR7VC3EKkxh3Q== Received: by mail-oi1-f182.google.com with SMTP id q39so2002093oiw.12 for ; Wed, 08 Sep 2021 00:47:48 -0700 (PDT) X-Gm-Message-State: AOAM53085Rt2DWcnQVmGhVcCjKmefGKyJXTY4v8QGRiQUn7F9vsljGsv haf+fASJ//hfYDklFjQIQCQNIRaEVzNjKarNYsU= X-Google-Smtp-Source: ABdhPJyS9VA1EqDPnto6QI61xcnEBBARNumEGt1UOSEs+dAjZ4s2lGUjjMxxKPshi0co05+lSMvEZgfDiEASfHERUHY= X-Received: by 2002:a54:418e:: with SMTP id 14mr1463170oiy.174.1631087267929; Wed, 08 Sep 2021 00:47:47 -0700 (PDT) MIME-Version: 1.0 References: <20210904060908.1310204-1-keithp@keithp.com> <20210907220038.91021-1-keithpac@amazon.com> <2d5e3f95-77ce-cd26-9020-3c1a8a65e799@canonical.com> In-Reply-To: <2d5e3f95-77ce-cd26-9020-3c1a8a65e799@canonical.com> From: Ard Biesheuvel Date: Wed, 8 Sep 2021 09:47:36 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/7] ARM: support THREAD_INFO_IN_TASK (v3) To: Krzysztof Kozlowski Cc: Keith Packard , Linux Kernel Mailing List , Abbott Liu , Andrew Morton , Andrey Ryabinin , Anshuman Khandual , Arnd Bergmann , Bjorn Andersson , Christoph Lameter , Dennis Zhou , Geert Uytterhoeven , Jens Axboe , Joe Perches , Kees Cook , Linus Walleij , Linux ARM , Linux Memory Management List , Manivannan Sadhasivam , Marc Zyngier , Masahiro Yamada , Mike Rapoport , Nathan Chancellor , Nick Desaulniers , Nick Desaulniers , Nicolas Pitre , Russell King , Tejun Heo , Thomas Gleixner , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Valentin Schneider , Viresh Kumar , "Wolfram Sang (Renesas)" , YiFei Zhu Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 8 Sept 2021 at 09:01, Krzysztof Kozlowski wrote: > > On 08/09/2021 00:00, Keith Packard wrote: > > Placing thread_info in the kernel stack leaves it vulnerable to stack > > overflow attacks. This short series addresses that by using the > > existing THREAD_INFO_IN_TASK infrastructure. > > > > This is the third version of this series, in this version the changes > > are restricted to hardware which provides the TPIDRPRW register. This > > register is repurposed from holding the per_cpu_offset value to > > holding the 'current' value as that allows fetching this value > > atomically so that it can be used in a preemptable context. > > > > The series is broken into seven pieces: > > > > 1) Change the secondary_start_kernel API to receive the cpu > > number. This avoids needing to be able to find this value independently in > > future patches. > > > > 2) Change the secondary_start_kernel API to also receive the 'task' > > value. Passing the value to this function also avoids needing to > > be able to discover it independently. > > > > 3) A cleanup which avoids assuming that THREAD_INFO_IN_TASK is not set. > > > > 4) A hack, borrowed from the powerpc arch, which allows locating the 'cpu' > > field in either thread_info or task_struct, without requiring linux/sched.h > > to be included in asm/smp.h > > > > 5) Disable the optimization storing per_cpu_offset in TPIDRPRW. This leaves > > the register free to hold 'current' instead. > > > > 6) Use TPIDRPRW for 'current'. This is enabled for either CPU_V6K or CPU_V7, > > but not if CPU_V6 is also enabled. > > > > 7) Enable THREAD_INFO_IN_TASK whenever TPIDRPRW is used to hold 'current'. > > Hi, > > Thanks for your patches. This seems to be a v3 but the patches are not > marked with it. Use "-v3" in format-patch to get it right. > > The email here also lacks diffstat which is useful, for example to check > whether any maintainer's relevant files are touched here. You can get it > with "--cover-letter". > > In total the command should look like: > git format-patch --cover-letter -v3 -7 HEAD > > Of course you can use any other tools to achieve the same result but as > of now - result is not the same. > Also, this ended up in my GMail spam folder, likely due to some antispam ID header being set incorrectly? 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 X-Spam-Level: X-Spam-Status: No, score=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36181C433EF for ; Wed, 8 Sep 2021 08:04:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id DEC1260F5E for ; Wed, 8 Sep 2021 08:04:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DEC1260F5E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OrGvgbJOxKtTRQPBqMOOthSeShWX7+vCiOrYC5btT00=; b=AnwDqV6B3pGNfd zRUxRoXCZdJjnbIHd5TtTqm5lcCKC14+dS1oqoi/XYbBez7yxhVIPR74EaLCU5QcF1YkMGq9+u1tp qCnt3AWWVhpaObc+94mT2h/BavEEwf7fnIl7kAX4U+D8WWGhtUj853ls3XbuVu1X8yf3myE+bLifP OEZZW85xVpdKDNsPbrwM4IsBiRWaj+k+2macVe0UDcO9bkYQZDTMguGbw4CCngfwiuQ7ydGFANEON ahHF3B7SokOIJTI0DGgcmkybKcaQvKWVPGV0UaeFqsfQ1kHwD5Vwaqm9PG4yvadaT6raBm/1vHA17 XunSNZl7xAeiPAJd8ldw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNsWQ-0062hP-S9; Wed, 08 Sep 2021 08:01:32 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNsJB-005yxN-2D for linux-arm-kernel@lists.infradead.org; Wed, 08 Sep 2021 07:47:50 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA3E8611C2 for ; Wed, 8 Sep 2021 07:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631087268; bh=g+KPm8DVe7Iqx7fs4fJUSuXyAmNC6ljwYldCl8uZcPY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=J0ah/Gbc6BEStYii3MQu7/yiQ+zrxiYuTepLreOq5Sbmtp1p2kc5fGlT2ni2SJPg9 LLEupvji7CZ95xmDVR2tkCxqDV4f4hOVvlcoTXWL5C798wqE3JurN6Q2Z4XGmGtY7X 1sXay84RqOToCvPCw3rjpilYZyc0sIiOg0SRyGcTHEccFJXn2GkfJyo1HWkmSacRiz mEc+wnCDo8I7FZZApUkc7a2ZjXCtbFinHbPhxuPEAKFdRx1JlaAUKjFzpj8rxgEIcJ 13gru/HpGhRf1NU6pWNs43WQVIjQa1SIwygAva87ggeu2Zkoe2WioiVHbIU5fpUeHi sR7VC3EKkxh3Q== Received: by mail-oi1-f169.google.com with SMTP id w19so2007423oik.10 for ; Wed, 08 Sep 2021 00:47:48 -0700 (PDT) X-Gm-Message-State: AOAM533fKyhZb6XQC4GFOUf4gtuNou8zRleTkbFgqCi/3oFrzp126fjK qkPSXY40PxJyMpGVZrUeG0kzw22xr7PIEu2+BtQ= X-Google-Smtp-Source: ABdhPJyS9VA1EqDPnto6QI61xcnEBBARNumEGt1UOSEs+dAjZ4s2lGUjjMxxKPshi0co05+lSMvEZgfDiEASfHERUHY= X-Received: by 2002:a54:418e:: with SMTP id 14mr1463170oiy.174.1631087267929; Wed, 08 Sep 2021 00:47:47 -0700 (PDT) MIME-Version: 1.0 References: <20210904060908.1310204-1-keithp@keithp.com> <20210907220038.91021-1-keithpac@amazon.com> <2d5e3f95-77ce-cd26-9020-3c1a8a65e799@canonical.com> In-Reply-To: <2d5e3f95-77ce-cd26-9020-3c1a8a65e799@canonical.com> From: Ard Biesheuvel Date: Wed, 8 Sep 2021 09:47:36 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/7] ARM: support THREAD_INFO_IN_TASK (v3) To: Krzysztof Kozlowski Cc: Keith Packard , Linux Kernel Mailing List , Abbott Liu , Andrew Morton , Andrey Ryabinin , Anshuman Khandual , Arnd Bergmann , Bjorn Andersson , Christoph Lameter , Dennis Zhou , Geert Uytterhoeven , Jens Axboe , Joe Perches , Kees Cook , Linus Walleij , Linux ARM , Linux Memory Management List , Manivannan Sadhasivam , Marc Zyngier , Masahiro Yamada , Mike Rapoport , Nathan Chancellor , Nick Desaulniers , Nick Desaulniers , Nicolas Pitre , Russell King , Tejun Heo , Thomas Gleixner , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Valentin Schneider , Viresh Kumar , "Wolfram Sang (Renesas)" , YiFei Zhu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210908_004749_200555_6DF3C2D6 X-CRM114-Status: GOOD ( 31.54 ) 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 Wed, 8 Sept 2021 at 09:01, Krzysztof Kozlowski wrote: > > On 08/09/2021 00:00, Keith Packard wrote: > > Placing thread_info in the kernel stack leaves it vulnerable to stack > > overflow attacks. This short series addresses that by using the > > existing THREAD_INFO_IN_TASK infrastructure. > > > > This is the third version of this series, in this version the changes > > are restricted to hardware which provides the TPIDRPRW register. This > > register is repurposed from holding the per_cpu_offset value to > > holding the 'current' value as that allows fetching this value > > atomically so that it can be used in a preemptable context. > > > > The series is broken into seven pieces: > > > > 1) Change the secondary_start_kernel API to receive the cpu > > number. This avoids needing to be able to find this value independently in > > future patches. > > > > 2) Change the secondary_start_kernel API to also receive the 'task' > > value. Passing the value to this function also avoids needing to > > be able to discover it independently. > > > > 3) A cleanup which avoids assuming that THREAD_INFO_IN_TASK is not set. > > > > 4) A hack, borrowed from the powerpc arch, which allows locating the 'cpu' > > field in either thread_info or task_struct, without requiring linux/sched.h > > to be included in asm/smp.h > > > > 5) Disable the optimization storing per_cpu_offset in TPIDRPRW. This leaves > > the register free to hold 'current' instead. > > > > 6) Use TPIDRPRW for 'current'. This is enabled for either CPU_V6K or CPU_V7, > > but not if CPU_V6 is also enabled. > > > > 7) Enable THREAD_INFO_IN_TASK whenever TPIDRPRW is used to hold 'current'. > > Hi, > > Thanks for your patches. This seems to be a v3 but the patches are not > marked with it. Use "-v3" in format-patch to get it right. > > The email here also lacks diffstat which is useful, for example to check > whether any maintainer's relevant files are touched here. You can get it > with "--cover-letter". > > In total the command should look like: > git format-patch --cover-letter -v3 -7 HEAD > > Of course you can use any other tools to achieve the same result but as > of now - result is not the same. > Also, this ended up in my GMail spam folder, likely due to some antispam ID header being set incorrectly? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel