From patchwork Thu Oct 27 16:55:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 11889 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp347317wru; Thu, 27 Oct 2022 10:02:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PEH4e0OUC6xoJrQUbbLmsH+Fn1sAqFN3l4xhqzdXit9hIEPJ0vJ8m5J3A15Cgws/oeWcK X-Received: by 2002:a17:90b:1e51:b0:212:d06b:b5fa with SMTP id pi17-20020a17090b1e5100b00212d06bb5famr11080841pjb.171.1666890135852; Thu, 27 Oct 2022 10:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666890135; cv=none; d=google.com; s=arc-20160816; b=Z+5zE3F1y+JXBjZ1KyGa4GXUlNzl3lx9YanwKH1v8nafUG1ZuYngFX0V56O0QGGpFZ ERUJ/Jz44yD5sJH9jM/l1gerXfeZs1aB5CSevcAsiq0H5f+CK+ypdgWjo/9JMoSY9zlv bqIVVc/uOMMtW2Gxx7qRJw4byUAzabjyVQUERPnUfchpjFp6MNCGAff/bRjaZmgv194p VnbNz1F6KuD3e1smxTmf+GlBaPvDAMKzKBlNXUKABqTJw5YPUIPHtQRinEllQpgJI6Nc NmlNd01OEkzWUqAwt9x02G6rTJTyyroPP1K4TmADnYt3Q+45McSGZf26ayPUYcYpv1CE LpTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nEKjVejDvz6ghEfjCPpSgciTDy4pfARqW1t0KlhDGhA=; b=kPzlwK0I8cfQZqfRb/LRjeMplfJ3PhHVi60GN8KQmlLzWa/cnOnJo/cf1OAcZzPJlJ MnksnmEgUSEkF0Z9rnLS88wcZJhSJzLBQtynpZ2/svq3gCxDo1WN1VKFvSEXdhI2u82K c5C9dFg13N5OtpKucTuqvMz7JXYCSigtbNt982xYE4yeSlf9QHKT9uKsQXOClR06bArC qcbUsvQYnUS39p0EPrJYZHAYnqrV1bMmDKxGCCQhM+JMsHGIeRZZgEz39An8lKqoLnl2 Olw6WDtaRMNlw+FeTxyoLA+gJWNSww9QYdFjjY71catKwDIcrZS5b8Twf6k2PtFDUbjY lpDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xu9Kdzr4; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ck1-20020a17090afe0100b002007cc304f3si6041085pjb.60.2022.10.27.10.01.54; Thu, 27 Oct 2022 10:02:15 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=Xu9Kdzr4; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236825AbiJ0RBo (ORCPT + 99 others); Thu, 27 Oct 2022 13:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236807AbiJ0RBk (ORCPT ); Thu, 27 Oct 2022 13:01:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D9F31911D5; Thu, 27 Oct 2022 10:01:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A799BB82716; Thu, 27 Oct 2022 17:01:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F414EC433C1; Thu, 27 Oct 2022 17:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666890093; bh=9Ab+7kjacFVu0GE7LCnthBKvDfAV+vHoprFlEc2CDkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xu9Kdzr45EmB0MYUCfUYep9a0KhIcmZLvGrqHjmCJuakXgwT0En0Myj4J7w+mhb00 4oSggMrjUhC62hVeWNfjfP5PNgNGObWcwd4Bihj+Lo2dXyxF5Z8D10dg7lJDc7V4Ye o0pBySKZu7dhehWLfgKi+8shxS+6qDTIezVfpgCk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Anshuman Khandual , Evgenii Stepanov Subject: [PATCH 5.15 02/79] arm64/mm: Consolidate TCR_EL1 fields Date: Thu, 27 Oct 2022 18:55:00 +0200 Message-Id: <20221027165055.004242716@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221027165054.917467648@linuxfoundation.org> References: <20221027165054.917467648@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747860991081323136?= X-GMAIL-MSGID: =?utf-8?q?1747860991081323136?= From: Anshuman Khandual commit e921da6bc7cac5f0e8458fe5df18ae08eb538f54 upstream. This renames and moves SYS_TCR_EL1_TCMA1 and SYS_TCR_EL1_TCMA0 definitions into pgtable-hwdef.h thus consolidating all TCR fields in a single header. This does not cause any functional change. Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Acked-by: Catalin Marinas Signed-off-by: Anshuman Khandual Link: https://lore.kernel.org/r/1643121513-21854-1-git-send-email-anshuman.khandual@arm.com Signed-off-by: Will Deacon Cc: Evgenii Stepanov Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/pgtable-hwdef.h | 2 ++ arch/arm64/include/asm/sysreg.h | 4 ---- arch/arm64/mm/proc.S | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) --- a/arch/arm64/include/asm/pgtable-hwdef.h +++ b/arch/arm64/include/asm/pgtable-hwdef.h @@ -273,6 +273,8 @@ #define TCR_NFD1 (UL(1) << 54) #define TCR_E0PD0 (UL(1) << 55) #define TCR_E0PD1 (UL(1) << 56) +#define TCR_TCMA0 (UL(1) << 57) +#define TCR_TCMA1 (UL(1) << 58) /* * TTBR. --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -1094,10 +1094,6 @@ #define CPACR_EL1_ZEN_EL0EN (BIT(17)) /* enable EL0 access, if EL1EN set */ #define CPACR_EL1_ZEN (CPACR_EL1_ZEN_EL1EN | CPACR_EL1_ZEN_EL0EN) -/* TCR EL1 Bit Definitions */ -#define SYS_TCR_EL1_TCMA1 (BIT(58)) -#define SYS_TCR_EL1_TCMA0 (BIT(57)) - /* GCR_EL1 Definitions */ #define SYS_GCR_EL1_RRND (BIT(16)) #define SYS_GCR_EL1_EXCL_MASK 0xffffUL --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -46,7 +46,7 @@ #endif #ifdef CONFIG_KASAN_HW_TAGS -#define TCR_MTE_FLAGS SYS_TCR_EL1_TCMA1 | TCR_TBI1 | TCR_TBID1 +#define TCR_MTE_FLAGS TCR_TCMA1 | TCR_TBI1 | TCR_TBID1 #else /* * The mte_zero_clear_page_tags() implementation uses DC GZVA, which relies on From patchwork Thu Oct 27 16:56:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 11890 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp350780wru; Thu, 27 Oct 2022 10:07:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5C7Q5romz67DfCMfVFH9no3rn8niZK1GV8a7GDDEM/ZddmI/Lnn+dZaFU/JlXE71JP8rNv X-Received: by 2002:a17:902:b601:b0:186:9f20:f6a4 with SMTP id b1-20020a170902b60100b001869f20f6a4mr24578069pls.38.1666890466689; Thu, 27 Oct 2022 10:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666890466; cv=none; d=google.com; s=arc-20160816; b=VzdfR3rHaB4Plf++i8AIfY8YrMwHlRYVJdJVb4Wvw6ncy/9KjlkcJkXofO1KUBnWxn d1YGsIl6ljAR8a5oV2mFvxgcn/MXIk0U6AsBTdfDVwyeigoCHB0htooOFLQOnB1mmOT3 bHMwUgcxG7EtZXcknpWhj7tdt6x/z0mv3tI2RQzaop38kS6tEKPgj9FxcRycfG7dUAap 2b7fKu0zC8SQUdWjwue4MtWwKEMEfmE4kXUcOdkHm3JSAxW4M8dQ3n5TncoPMSazkIAi AdV38ehSTXbRi5cyaix8SeG75FXQ/e39TO+meN+I5qGE2TEL4eZZtSnHRNGwiF2Rr04v Y9FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Nu+dNqyw2MSfxO5GDEKJfJJ4bD/Q1jRD9NyMKIrVtBQ=; b=fkroplYMqV755SzeoQ5LpDGG4y2wszDHX+9jpRI/9txl3vP2ADGVtkMWLUKwADAY0v MmBJBDkqkI409AM9fpozOF8yXYF+LEuWPkcx9Bz7rxaHzHC2WhzvHPhaxQJcYYRPCsc7 P5NfWNliVwY4x8imdNuyHUyodNPmrWA1lWbeDEFsIInpa7How5Rja0lH/8pu+53su/CC K/4pF9vmOqtUhT1VFXoV9dbXFB1tUf+K5TkfWagW4VziRZ8Ivn8HXLB115Q/2ZbiDDkq 9z2nrdH1BaKXkxzv/pT2/6qZy3aar3/9QUNN0oCNYdXZsFCDhr/lNnWgjHDaO9n2RRar uZCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M6gkwDRq; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020a170902758500b00186f035eda3si1648032pll.579.2022.10.27.10.07.28; Thu, 27 Oct 2022 10:07:46 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=M6gkwDRq; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237020AbiJ0RHN (ORCPT + 99 others); Thu, 27 Oct 2022 13:07:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237018AbiJ0RHK (ORCPT ); Thu, 27 Oct 2022 13:07:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7627219C06E; Thu, 27 Oct 2022 10:07:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 15CCF623F7; Thu, 27 Oct 2022 17:07:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE921C433C1; Thu, 27 Oct 2022 17:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666890427; bh=KnqdBqXpwjnoczNNin28/Qu7T5+d3J3wqw/aPVgwV5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M6gkwDRq0ZzW/1wjsK67lKou40T33TVnreVpyu07Srkg2xJGTGA9FB1KrmtyIVOKA rSp0/RiFPQ9T5igRiiYFZ8Xe5FTQNSX1hJC+/r83GuFjNS8SlzrZ6GXEtmSWuDpSLR f/xEYcoJCYAy853/om+k78fumLtbSSuciB4dmKDQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jeff Layton , "J. Bruce Fields" , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Cyrill Gorcunov , Andrei Vagin , Pavel Tikhomirov , Sasha Levin Subject: [PATCH 5.10 67/79] fcntl: make F_GETOWN(EX) return 0 on dead owner task Date: Thu, 27 Oct 2022 18:56:17 +0200 Message-Id: <20221027165056.588648208@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221027165054.270676357@linuxfoundation.org> References: <20221027165054.270676357@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747861337869389434?= X-GMAIL-MSGID: =?utf-8?q?1747861337869389434?= From: Pavel Tikhomirov [ Upstream commit cc4a3f885e8f2bc3c86a265972e94fef32d68f67 ] Currently there is no way to differentiate the file with alive owner from the file with dead owner but pid of the owner reused. That's why CRIU can't actually know if it needs to restore file owner or not, because if it restores owner but actual owner was dead, this can introduce unexpected signals to the "false"-owner (which reused the pid). Let's change the api, so that F_GETOWN(EX) returns 0 in case actual owner is dead already. This comports with the POSIX spec, which states that a PID of 0 indicates that no signal will be sent. Cc: Jeff Layton Cc: "J. Bruce Fields" Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Cyrill Gorcunov Cc: Andrei Vagin Signed-off-by: Pavel Tikhomirov Signed-off-by: Jeff Layton Stable-dep-of: f671a691e299 ("fcntl: fix potential deadlocks for &fown_struct.lock") Signed-off-by: Sasha Levin --- fs/fcntl.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index 71b43538fa44..5a56351f1fc3 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -148,11 +148,15 @@ void f_delown(struct file *filp) pid_t f_getown(struct file *filp) { - pid_t pid; + pid_t pid = 0; read_lock(&filp->f_owner.lock); - pid = pid_vnr(filp->f_owner.pid); - if (filp->f_owner.pid_type == PIDTYPE_PGID) - pid = -pid; + rcu_read_lock(); + if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type)) { + pid = pid_vnr(filp->f_owner.pid); + if (filp->f_owner.pid_type == PIDTYPE_PGID) + pid = -pid; + } + rcu_read_unlock(); read_unlock(&filp->f_owner.lock); return pid; } @@ -200,11 +204,14 @@ static int f_setown_ex(struct file *filp, unsigned long arg) static int f_getown_ex(struct file *filp, unsigned long arg) { struct f_owner_ex __user *owner_p = (void __user *)arg; - struct f_owner_ex owner; + struct f_owner_ex owner = {}; int ret = 0; read_lock(&filp->f_owner.lock); - owner.pid = pid_vnr(filp->f_owner.pid); + rcu_read_lock(); + if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type)) + owner.pid = pid_vnr(filp->f_owner.pid); + rcu_read_unlock(); switch (filp->f_owner.pid_type) { case PIDTYPE_PID: owner.type = F_OWNER_TID;