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=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 9C9ABC433E1 for ; Thu, 20 Aug 2020 21:21:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 207E72076E for ; Thu, 20 Aug 2020 21:21:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="K8tXDB6r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 207E72076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B3AB66B0027; Thu, 20 Aug 2020 17:21:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AEC208D0005; Thu, 20 Aug 2020 17:21:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A00EE6B0029; Thu, 20 Aug 2020 17:21:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id 8AB986B0027 for ; Thu, 20 Aug 2020 17:21:48 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 43DF8180AD81D for ; Thu, 20 Aug 2020 21:21:48 +0000 (UTC) X-FDA: 77172219096.03.boats74_5c0daf127033 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 1A62228A4E9 for ; Thu, 20 Aug 2020 21:21:48 +0000 (UTC) X-HE-Tag: boats74_5c0daf127033 X-Filterd-Recvd-Size: 4028 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Aug 2020 21:21:47 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id p37so1750770pgl.3 for ; Thu, 20 Aug 2020 14:21:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EsAjRN4EWGdA6npeygguQ2Nt+2Qs2ZtAg82JTA4fjFU=; b=K8tXDB6rNbGscQlHY1IKoadl3x/vhZyQ/BPRzUIJ9ekNpyEgrFUp8WnYNBdytMLT03 xspi1TS1YHRjFLBTubnUoUCSmJYUJobp6DsgeFT/F5cu26hy9hImQkk6Jen/Ec5jLEk3 nP64duWEgISYePfLB3r9Xmac7cfpySG0j2bUg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=EsAjRN4EWGdA6npeygguQ2Nt+2Qs2ZtAg82JTA4fjFU=; b=rizKJC+sxTDxAsiIYL8sfJCr0W6XttWn1bsOp/6aLF92R4Y5fuoxkzHz0rpu7fNvmZ BpfRGxhvgRGKteUeXCUtia3b79YcbgaQmKKD+sBThdkralhmItFCt+NX+N3uo1OFknqp XFsnDcF49PBh2DgLln4cWGFktJLiXYZ+Q+lLx16Lty1T1zayhfJRMMEUqQohuloACH7O DeBy2MODYTp21W41Px5qBrnX2SeN07NIvDhgZr4eUjc25LqbG1lAPmpGL6Yli79jM3ZD EHC3n7E6/Lq6Sh4NZJJpRbKdJV7fqHDGFPOW+Lu4jMQXj4iJbxZpHZqCfpRcyZp3QwS9 ydFw== X-Gm-Message-State: AOAM532YC4rvB5eNHd/CNnrVc6pE6vJD2Y94doVUpShANq+FRk/W758J tBhLnKMM/mX+lFmz+I6LbLs/1Q== X-Google-Smtp-Source: ABdhPJwJ5uE9q3Uz8BjfaU+FBc50PS+4PET4V3mUpf4QuQZJT1QCIhsKZQ8JLt5HhxkLcLP/YQvrnQ== X-Received: by 2002:a05:6a00:228f:: with SMTP id f15mr503972pfe.222.1597958506806; Thu, 20 Aug 2020 14:21:46 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id k8sm3680437pgt.54.2020.08.20.14.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 14:21:46 -0700 (PDT) Date: Thu, 20 Aug 2020 14:21:45 -0700 From: Kees Cook To: linmiaohe Cc: "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "linux-security-module@vger.kernel.org" Subject: Re: [PATCH] mm/migrate: Avoid possible unnecessary ptrace_may_access() call in kernel_move_pages() Message-ID: <202008201420.D9F0CB3E@keescook> References: <9ce6209f41b64734b2cac748783aa441@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9ce6209f41b64734b2cac748783aa441@huawei.com> X-Rspamd-Queue-Id: 1A62228A4E9 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.084864, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Aug 20, 2020 at 02:18:21AM +0000, linmiaohe wrote: > Kees Cook wrote: > >On Mon, Aug 17, 2020 at 07:59:33AM -0400, Miaohe Lin wrote: > >> There is no need to check if this process has the right to modify the > >> specified process when they are same. > >> > >> Signed-off-by: Hongxiang Lou > >> Signed-off-by: Miaohe Lin > > > >NAK, please don't do this -- the ptrace and security hooks already do these kinds of self-introspection checks, and I'd like to keep a central place to perform these kinds of checks. > > > > Many thanks for your reply. > We also avoid get_task_struct/ put_task_struct pair of atomic ops, rcu_lock, task_lock and so on this way. > > >Is there a specific problem you've encountered that this fixes? > > > > I'am sorry but there's no specific problem. I do this mainly to skip the unnecessary ptrace and security hooks. Cool. Let's keep this as-is so we continue to have centralized instrumentation of these things in the LSM. :) Thanks for your attention to performance! -- Kees Cook