From patchwork Fri Oct 16 02:40:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 11840501 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8F0C16BC for ; Fri, 16 Oct 2020 02:40:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5AAB3208E4 for ; Fri, 16 Oct 2020 02:40:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="MddfLAWG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AAB3208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9680694000C; Thu, 15 Oct 2020 22:40:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8F627900002; Thu, 15 Oct 2020 22:40:43 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BE1E94000C; Thu, 15 Oct 2020 22:40:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 37895900002 for ; Thu, 15 Oct 2020 22:40:43 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C6DE63623 for ; Fri, 16 Oct 2020 02:40:42 +0000 (UTC) X-FDA: 77376235524.28.house30_4e1717a27219 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id AA4646C0B for ; Fri, 16 Oct 2020 02:40:42 +0000 (UTC) X-Spam-Summary: 1,0,0,713e4ae39f2622c3,d41d8cd98f00b204,jannh@google.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3866:3867:3868:3871:3872:3874:4250:4321:4385:5007:6119:6120:6261:6653:7903:9969:10004:11026:11658:11914:12043:12048:12296:12297:12517:12519:12555:12895:13069:13311:13357:13894:14096:14181:14384:14721:14877:21080:21324:21444:21627:21939:30054,0,RBL:209.85.221.68:@google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yr3h3ufaiu3kqrxtek5r793jmmnyc4qygrnss35wufphkbdcbwyxf6xzi4u8w.oidoxsdzq1938ab8yqsxhy96sttya7qnhmzm7mtwd6a9q6et6qqmiqpdoos9j8q.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: house30_4e1717a27219 X-Filterd-Recvd-Size: 4396 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 02:40:42 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id i1so964720wro.1 for ; Thu, 15 Oct 2020 19:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IcagjNj/dK1Y8RczpuQCkX5yBuEwqqFKdmDjpHwB/uo=; b=MddfLAWGyYBRfNuN1ok8b6DU3DiyooyjcqJoJfOhV+LJKWza09r9Go8ofj1LC/QisZ RX1U7FiWILjd8tJ4OPgtOUEDISb8w3/bkgvVAJMxqUZUHmQ+HhuSYJFp/Ralp9ECoDZq SMtrG+132hhR9UTmdkq2zSCiGcjHv1krB4OeKFj1QSfxQBK595gy4ZNGwhxkNu3BZxOK bn81x1r9B6DOkbjCVmkPpnJ/P0Hiju8Dg99yreeh5ABC2m7yGbRjs7seprwLuOdcEt5s My5XZ+XMcAOZGWsPD45667KU2tZIhqcxBWzE2Ng//a54J+Tl1nGWSutjgrXIQcYbJuar Ctig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IcagjNj/dK1Y8RczpuQCkX5yBuEwqqFKdmDjpHwB/uo=; b=qmOD+nnR31F0twWuENt4b8uxZa7aknSYV4J0jazHzdwQ4xsIrsq+Dwk9lGTsowGaDn Kjfnyg8wKE6vvFg7rhYIAQ5pQGVCZCYR9u/H+ryBdKYxmRKwSeo5hXBqDOBEt65Mg3gH bmjUBqfL+mP6EqYkKEp5fTOldJCCI8v3zFtlX0G3qZLrb4l4cOmpbmdnkzHR/jRx3a33 XfV692yxY9KaQ6yCMynV2GdL7DLb1aul8YEAOvRN5f+62OLKP4TyybxBMjZEzCP9QOJx PUTmgtUuCEHRlJ2jCtyRjkae/pPJNCk+kWS52E4PIB2s9KGF73fIsbRBz2mEy55hvlq+ pScw== X-Gm-Message-State: AOAM530wefJ+VF1Q7Qj5eLmtjmn/QW5eEMqS3i1zqDfSqA/TXM+dwcQT DjzT/fXXuAKz4iRXp79Bq/GeIA== X-Google-Smtp-Source: ABdhPJximA8TmzkmMulZ0xLdHIxKgoI2ci4m2SYAs/YeDnDT1bJXj91PiKhT9FEUOj80FiKoKk0j4Q== X-Received: by 2002:adf:f74e:: with SMTP id z14mr1179844wrp.312.1602816040727; Thu, 15 Oct 2020 19:40:40 -0700 (PDT) Received: from localhost ([2a02:168:96c5:1:55ed:514f:6ad7:5bcc]) by smtp.gmail.com with ESMTPSA id z5sm1511651wrw.37.2020.10.15.19.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 19:40:40 -0700 (PDT) From: Jann Horn To: Andrew Morton , linux-mm@kvack.org, Eric Biederman , Oleg Nesterov Cc: linux-kernel@vger.kernel.org, Will Deacon , Kees Cook , Ingo Molnar Subject: [RFC PATCH 5/6] ptrace: Use mm_ref() for ->exit_mm Date: Fri, 16 Oct 2020 04:40:18 +0200 Message-Id: <20201016024019.1882062-6-jannh@google.com> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201016024019.1882062-1-jannh@google.com> References: <20201016024019.1882062-1-jannh@google.com> MIME-Version: 1.0 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: We only use ->exit_mm to look up dumpability and the ->user_mm; we don't need to keep the PGD alive for this. mmgrab() is also inconvenient here, because it means that we need to use mmdrop_async() when dropping the reference to the mm from an RCU callback. Use mm_ref() instead of mmgrab() to make things neater. Signed-off-by: Jann Horn --- kernel/exit.c | 2 +- kernel/fork.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index 97253ef33486..03ba6d13ef1e 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -476,7 +476,7 @@ static void exit_mm(void) /* more a memory barrier than a real lock */ task_lock(current); current->mm = NULL; - mmgrab(mm); /* for current->exit_mm */ + mm_ref(mm); /* for current->exit_mm */ current->exit_mm = mm; mmap_read_unlock(mm); enter_lazy_tlb(mm, current); diff --git a/kernel/fork.c b/kernel/fork.c index 59c119b03351..4383bf055b40 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -720,7 +720,7 @@ void free_task(struct task_struct *tsk) if (tsk->flags & PF_KTHREAD) free_kthread_struct(tsk); if (tsk->exit_mm) - mmdrop_async(tsk->exit_mm); + mm_unref(tsk->exit_mm); free_task_struct(tsk); } EXPORT_SYMBOL(free_task);