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=-9.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 74F2CC433EF for ; Wed, 8 Sep 2021 07:01:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0670961154 for ; Wed, 8 Sep 2021 07:01:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0670961154 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 48A616B006C; Wed, 8 Sep 2021 03:01:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43A8B6B0071; Wed, 8 Sep 2021 03:01:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30179900002; Wed, 8 Sep 2021 03:01:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id 21C4B6B006C for ; Wed, 8 Sep 2021 03:01:29 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BF9BF8249980 for ; Wed, 8 Sep 2021 07:01:28 +0000 (UTC) X-FDA: 78563510256.26.482E148 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by imf11.hostedemail.com (Postfix) with ESMTP id 4E136F0000BD for ; Wed, 8 Sep 2021 07:01:28 +0000 (UTC) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id BD3553F31C for ; Wed, 8 Sep 2021 07:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1631084486; bh=7OsT0XPB+KLnwypcRQ26qkCgD4akJ8q/u9rPuGRcl6M=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=iiKrVGgH6Fn0ZXd1vJiB6zorjq2K0nb2fXQDqGKCuLxYOSVc8KhZoPYvJblZ31etL Xnnc5NhpOo4KSCAkeGYnc9iL749OJI2xSVsdc3bVgfwz8CHOVecBsKMsQEygoP146j fAfjvm37/u/4+b2+hCnVIeJeD7zE9doU7j3cpwqUfj0BcR7Ix7Jc1fT+CMBDfKbOWe P0sTpSyw6uR4p00VjZpxrD6b5XkcLMZ+44U5HCg+2Uj23jWTp2I38H53xbXQwSRieT faLfy6+QNkDvK1N0xQIvmVhGZqC2Aehz89QHT5FolOnID3TCsyHSyVMXZUkU5SAtNf H6rP5wb2jwvqA== Received: by mail-wr1-f69.google.com with SMTP id p18-20020a5d4e12000000b0015940dc586aso213142wrt.6 for ; Wed, 08 Sep 2021 00:01:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7OsT0XPB+KLnwypcRQ26qkCgD4akJ8q/u9rPuGRcl6M=; b=cb3honfsCApddYEhF/GNUn9nrsBMmh+AnHKxeMEnONlp1flZc2ACouNOv07jGkn8w6 IzAutuRcT7tK5XyzndexSHuJL3Go11xmYAGKWynjuI0Ez79gBZB/a8Ag7dSxSDH8KRYf RK8dxm+Ma6kcXCMEx+jmY2dKhchfnbeDTVz4YwqCo5wxMxEQJaGJlFwd3/b1+r3xrAN+ 1HwYJeD2rdU9vejP0UFbeCw4LKNNnkpjyY8yZEltrJSHrN+G3HFKQA4rymb8ytw0gwoz CwrTO6D1r4uvvU99Nh28C3LcdLujwu6Mv1eUq80dP2wW40ZEis71qnywwgjzoMOVOlVU UiVw== X-Gm-Message-State: AOAM533/mesHF7ZdMtz49Br9Fv16iL7TL3r/5w3UIcbbKgwFcphrgw+F wP8n8ZSj+gjO3aEHJVDCImGPHq4yhtjLmtSmrLIxFUC+KTaOW5/+iycX16qp0iMsoB5Ioy054BI 4N82GtH1ug9mcFjxmc+K0Cv64pnVj X-Received: by 2002:a05:6000:1010:: with SMTP id a16mr2165638wrx.70.1631084486186; Wed, 08 Sep 2021 00:01:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAmJ4+SOX1o+v7aucWstLZvxDjC7dz0hHMt68cmrHjjVhjdJdEeWBblBfkce0XG8SHHwAphg== X-Received: by 2002:a05:6000:1010:: with SMTP id a16mr2165600wrx.70.1631084485973; Wed, 08 Sep 2021 00:01:25 -0700 (PDT) Received: from [192.168.3.211] ([79.98.113.74]) by smtp.gmail.com with ESMTPSA id o14sm1164596wrg.91.2021.09.08.00.01.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Sep 2021 00:01:25 -0700 (PDT) Subject: Re: [PATCH 0/7] ARM: support THREAD_INFO_IN_TASK (v3) To: Keith Packard , linux-kernel@vger.kernel.org Cc: Abbott Liu , Andrew Morton , Andrey Ryabinin , Anshuman Khandual , Ard Biesheuvel , Arnd Bergmann , Bjorn Andersson , Christoph Lameter , Dennis Zhou , Geert Uytterhoeven , Jens Axboe , Joe Perches , Kees Cook , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, 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-K=c3=b6nig?= , Valentin Schneider , Viresh Kumar , "Wolfram Sang (Renesas)" , YiFei Zhu References: <20210904060908.1310204-1-keithp@keithp.com> <20210907220038.91021-1-keithpac@amazon.com> From: Krzysztof Kozlowski Message-ID: <2d5e3f95-77ce-cd26-9020-3c1a8a65e799@canonical.com> Date: Wed, 8 Sep 2021 09:01:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210907220038.91021-1-keithpac@amazon.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=iiKrVGgH; spf=pass (imf11.hostedemail.com: domain of krzysztof.kozlowski@canonical.com designates 185.125.188.123 as permitted sender) smtp.mailfrom=krzysztof.kozlowski@canonical.com; dmarc=pass (policy=none) header.from=canonical.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4E136F0000BD X-Stat-Signature: t6ynmhx1cwcqkycza6hhy4fq7rh9j97a X-HE-Tag: 1631084488-144817 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. Best regards, Krzysztof