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=-11.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 AF987C433EF for ; Sat, 4 Sep 2021 06:09:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D56E60FDC for ; Sat, 4 Sep 2021 06:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233426AbhIDGKU (ORCPT ); Sat, 4 Sep 2021 02:10:20 -0400 Received: from home.keithp.com ([63.227.221.253]:36028 "EHLO elaine.keithp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232224AbhIDGKP (ORCPT ); Sat, 4 Sep 2021 02:10:15 -0400 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 132B93F30826; Fri, 3 Sep 2021 23:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1630735729; bh=TiBQjRhgDSbNjx047iON2OqbTV5dVpsECJ5EVpXAQx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EdC4AZMs592lphtlw4x0KzeVVCLMQIJ+eBX9QPBdPbCCQii4OWQ7EzMMq4vfrE+TR XUzhJ06rr2GW1hTq01825KsIln9+kJnDijL0OGHXXZLdYVa7WXO772uHsmeC5exkHe YWVMVHKkvmKGJwaQ8Mhz9UDfzXx0jjMMl8vA7wmO52w7LdsU+y81fRuQfGsnI1pAd2 1X6SU6Q6gL7C0lIX2RhwR+hJeVqI9UgR698x+fgJoX5Hg63xZrtdTQyKGZiiLZGNZm wuVO8Rb8LvkFKQyqhLIgW2ZsUihCclq3ti3oXaOj/g01HzhhWKHQeDjjjjDQHOxa+7 eOYWCc+n2A5SA== X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id d4vRelaLlD2U; Fri, 3 Sep 2021 23:08:48 -0700 (PDT) Received: from keithp.com (168-103-156-98.tukw.qwest.net [168.103.156.98]) by elaine.keithp.com (Postfix) with ESMTPSA id 670813F30823; Fri, 3 Sep 2021 23:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1630735728; bh=TiBQjRhgDSbNjx047iON2OqbTV5dVpsECJ5EVpXAQx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dp8zjbvLOiyFLpBahF7z3Sv1YeCcWsU52OuLP1wDBt1ymSAxt6+PvAjRHhXyvV7Xg 41YStC+dh+p2UE2qdy9s/BbuXYq9pC1Acov8e4yTOEQvcG0kXrMDQ/BFolB7pGv8gQ /5HHqkxLDSijeigkem2ISW+jBOYnLfWa2J7DaZYD+kJtihraAsnIKxCJ5AJTYFhQMx OtVoQOorkaUWiypXnixuSEG9ZZei9pVO/hw8HW7V92+hjBVhzay8s/SxrlVJ7Fg8BW yc7EQ+VZm0fv9sCjGxVVpn7a7C+bxHz1Ar66Mxo6F3MFZLD7me9ODG5CI1iLGvYa5O heewzlx9InG5A== Received: by keithp.com (Postfix, from userid 1000) id 765121E6013A; Fri, 3 Sep 2021 23:09:10 -0700 (PDT) From: Keith Packard To: linux-kernel@vger.kernel.org Cc: Abbott Liu , Alexander Sverdlin , Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Arnd Bergmann , Bjorn Andersson , Florian Fainelli , Geert Uytterhoeven , Hartley Sweeten , Jens Axboe , Jian Cai , Joe Perches , Kees Cook , Keith Packard , Krzysztof Kozlowski , Linus Walleij , linux-arm-kernel@lists.infradead.org, Manivannan Sadhasivam , Marc Zyngier , Masahiro Yamada , Miguel Ojeda , Mike Rapoport , Nathan Chancellor , Nick Desaulniers , Nicolas Pitre , Rob Herring , Russell King , Thomas Gleixner , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Valentin Schneider , Viresh Kumar , "Wolfram Sang (Renesas)" , YiFei Zhu , Keith Packard Subject: [PATCH 0/2] ARM: support THREAD_INFO_IN_TASK (v7 only) (v2) Date: Fri, 3 Sep 2021 23:09:05 -0700 Message-Id: <20210904060908.1310204-1-keithp@keithp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210902155429.3987201-1-keithp@keithp.com> References: <20210902155429.3987201-1-keithp@keithp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 second version of this series, in this version the changes are restricted to v7 hardware which offers a way to identify each cpu in the system without reference to the stack it is using. The series is broken into three pieces: 1) Change the secondary_start_kernel API to pass the cpu number to this function. This is required for the following patch because the raw_smp_processor_id() macro will use the per_cpu_offset value which needs to have the cpu number to get the right value. 2) Enable THREAD_INFO_IN_TASK by creating a new per-cpu variable, current_task, just like the x86 architecture. The largest changes are in the assembly code where fetching the current_task value requires a temporary register. Fortunately, each location in the code performing this had a reasonably obvious register to use. 3) Optimize access to the cpu number using another new per-cpu variable. This is not functionally necessary, but avoids de-referencing through two pointers at modest memory cost. Signed-off-by: Keith Packard