From patchwork Fri Oct 16 23:09:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 11842449 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 4EEC217E6 for ; Fri, 16 Oct 2020 23:09:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 015FE2222A for ; Fri, 16 Oct 2020 23:09:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LhDuPgRe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 015FE2222A 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 13DAA6B0071; Fri, 16 Oct 2020 19:09:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0C5E86B0072; Fri, 16 Oct 2020 19:09:47 -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 EFEBF6B0073; Fri, 16 Oct 2020 19:09:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0125.hostedemail.com [216.40.44.125]) by kanga.kvack.org (Postfix) with ESMTP id B50066B0071 for ; Fri, 16 Oct 2020 19:09:46 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 52391362C for ; Fri, 16 Oct 2020 23:09:46 +0000 (UTC) X-FDA: 77379332772.14.swing74_011011127220 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 33F2118229835 for ; Fri, 16 Oct 2020 23:09:46 +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:1513:1515:1521: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:14096:14181:14384:14721:14877:21080:21324:21444:21627:21939:30054,0,RBL:209.85.221.66:@google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04ygrefk31tyjmg54ff147syrcfqgyc4qygrnss35wufphkbdcbwyxf6xzi4u8w.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:23,LUA_SUMMARY:none X-HE-Tag: swing74_011011127220 X-Filterd-Recvd-Size: 4421 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 23:09:45 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id i1so4896015wro.1 for ; Fri, 16 Oct 2020 16:09:45 -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=ZqE9YT9elxKHcuMev0eqxdSAa29MOpdvFBgbgr/Dw4c=; b=LhDuPgReRaskA4lZJUuE4meGMw+AgSOBWcN0nqcL7KFy86acDGi8um3oRgd5CDOyyW bJFG22PeRLjTWFTU0ukD0tLvCbDgdbDFYPyGitxBgX1xKbXiv598o0EuHa9yELSghqKw VA4T4kdrHVqd88Cs852iMYBnFRMpkx301IXdoi39KfAj+zcBhsCDBtvTEc8dT3mQEW7T 7cylEg7GMWupAk7aZgn16x9jAZeU8zBSiMABrBnBpXTYtig7uF8ZJ7QptnUymL6udJDm sSK7gfMVEBYedaoF17S5Y2Kt1jq2Ee3Ymywe0au8W2vWFh7Kb2xhY8Sfp9vAdq5IO04Z rTDg== 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=ZqE9YT9elxKHcuMev0eqxdSAa29MOpdvFBgbgr/Dw4c=; b=Wiq+K/R90fiwhco9fesNsnVaFkpkWegrEpDMY/9leFOIdlo/tOmxrQxySJFDM+U7qf HMQSq/5BATV1jQMQbHDqtmSdoNRC4IQLoIDIc9F1CzqWo3lgNPGI1jIBoNW0eP0sULQy VPPyulhMPJt5/6U2uColnsbETE2i6tYmQfUKL2hMpuOi+PNoqUUCt8dC0wZDtXv4Ska/ UasjxF/IydzT2UuyuBZ/x/V1f3LJsRashat2UInfALeDgdQVggHMrWL62G7P7i/kJwFS +LmXckGn/0aF60hoy0IQF5T1lktRSr1hay7tIFPCl3b2IV2/Ha622aqDE1flrbZiJcZ+ X46g== X-Gm-Message-State: AOAM531x5XR33ITXtjJZ92tvwJ8X/mJB2ScIym6WEduOzYS88s/hP0Da v8bNK87GE/jRpkXsBEChvJQTfA== X-Google-Smtp-Source: ABdhPJxhjUYQmLunbOMgkbnTqMUJ/Am0yPCMEVT4RqDmKWTqbn4mCWM3hyiVNo2TJIXie6ukzbX0NA== X-Received: by 2002:a5d:4b49:: with SMTP id w9mr7015093wrs.41.1602889784661; Fri, 16 Oct 2020 16:09:44 -0700 (PDT) Received: from localhost ([2a02:168:96c5:1:55ed:514f:6ad7:5bcc]) by smtp.gmail.com with ESMTPSA id v17sm6144214wrc.23.2020.10.16.16.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2020 16:09:44 -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 resend 5/6] ptrace: Use mm_ref() for ->exit_mm Date: Sat, 17 Oct 2020 01:09:14 +0200 Message-Id: <20201016230915.1972840-6-jannh@google.com> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201016230915.1972840-1-jannh@google.com> References: <20201016230915.1972840-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);