Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1476431pxu; Thu, 17 Dec 2020 10:49:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuOtELLoERECLcUhHCaX+RdCcbtt1JKAuYxdTH1PvCoTQksuVJB7MvJIM9yfIVdA2fzHMQ X-Received: by 2002:a17:906:9452:: with SMTP id z18mr353371ejx.389.1608230986974; Thu, 17 Dec 2020 10:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608230986; cv=none; d=google.com; s=arc-20160816; b=ySm0h5noVufOdBtU1KveflW7RaxFgx4V57zWdaKc7c5iWKGvSVYRlLJV50fn0Ow3WC akpLufTvSe5wQuMenWK84i6+gj1qy7/lLBsL3EDOX0mL7mVG/5nMwXtdMj0QY/W6h+6J hA10ASnVoidaFHbprquD4FGfkHSuEfJ+xxkHlrRm02SC8V8JvsnOzbqtUAE+JCSRQOm8 gc6VtbSCNjCDtNgpclWPF0Mrku02cllv0rCcFMGdcOpoBfNP5Z0SZ0EQzwjade2j/oTh BZMRN+Ai9XlFJXR65mes1H2AX+YJ9vHx4fmoE9NbKskHY0oFrRjZaoiHl+65TiHzccP8 lhLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=RgIxjQYWtYAa2YyBkhmV1G3jZsBp8Xbu/08k79fTWkI=; b=wazbKvQDo313mSazzqL7WeaKfm70cqlN2Aw5oExjzUGU49vTGEVLAFfCVm98JJZ3wq fA9S8+ww03dpG3u0hwvuTgBx6XrNVdnW1sJbMK8aMIJZAFIHwEJ3fr6qVOQNjEOfDK1m a4RgeDcPPDGTebskcqlwCTOWqIWDJfH6IQ3fC+tu9/CrVFP9Q5kZ1qOq5M2WY9IYJEG7 fbaSZCPPuPoPAMna7+WloAENquPK/vG+nwtrc1XS+iTV+DiE4kYaMp7vT9KV6O3lCpFf 2X7HH+Ss1+B5c6GaXIG6K7ll52fWX2Y4stwBPjUcB0QLtmBITvWzoSNe+lhTbF21PIX0 LEKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x9si3267808ejy.403.2020.12.17.10.49.23; Thu, 17 Dec 2020 10:49:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730429AbgLQSrE (ORCPT + 99 others); Thu, 17 Dec 2020 13:47:04 -0500 Received: from out03.mta.xmission.com ([166.70.13.233]:32902 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729602AbgLQSrD (ORCPT ); Thu, 17 Dec 2020 13:47:03 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kpyI6-003Dnp-MZ; Thu, 17 Dec 2020 11:46:18 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kpyI5-002lI8-Ei; Thu, 17 Dec 2020 11:46:18 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: "Alejandro Colomar \(man-pages\)" Cc: Oleg Nesterov , Jann Horn , Ted Estes , Jann Horn , Pavel Emelyanov , Andrew Morton , Michael Kerrisk , Kees Cook , linux-man , linux-kernel , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart References: <0e5189c0-9e9b-ac34-825c-619a9a6ef682@gmail.com> <5062fe43-ca37-134f-89ad-57fbd8c312ba@softwarecrafters.com> <1abbf267-d522-0586-e5a5-c71f4d7b0fa4@gmail.com> Date: Thu, 17 Dec 2020 12:45:29 -0600 In-Reply-To: <1abbf267-d522-0586-e5a5-c71f4d7b0fa4@gmail.com> (Alejandro Colomar's message of "Wed, 16 Dec 2020 10:22:09 +0100") Message-ID: <87eejouv92.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1kpyI5-002lI8-Ei;;;mid=<87eejouv92.fsf@x220.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX190iekfNeZPMseo2lks32NWzQGjeRDvFXU= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: X-Spam-Status: No, score=0.7 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG,XMSubLong,XM_B_SpammyWords autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4748] * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.2 XM_B_SpammyWords One or more commonly used spammy words X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;"Alejandro Colomar \(man-pages\)" X-Spam-Relay-Country: X-Spam-Timing: total 673 ms - load_scoreonly_sql: 0.31 (0.0%), signal_user_changed: 15 (2.2%), b_tie_ro: 12 (1.8%), parse: 1.74 (0.3%), extract_message_metadata: 21 (3.1%), get_uri_detail_list: 2.9 (0.4%), tests_pri_-1000: 6 (0.9%), tests_pri_-950: 1.33 (0.2%), tests_pri_-900: 1.08 (0.2%), tests_pri_-90: 240 (35.6%), check_bayes: 237 (35.2%), b_tokenize: 12 (1.7%), b_tok_get_all: 11 (1.7%), b_comp_prob: 3.7 (0.6%), b_tok_touch_all: 205 (30.5%), b_finish: 1.28 (0.2%), tests_pri_0: 370 (55.0%), check_dkim_signature: 0.63 (0.1%), check_dkim_adsp: 6 (0.9%), poll_dns_idle: 0.41 (0.1%), tests_pri_10: 2.2 (0.3%), tests_pri_500: 11 (1.6%), rewrite_mail: 0.00 (0.0%) Subject: Re: [Bug 210655] ptrace.2: documentation is incorrect about access checking threads in same thread group X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Alejandro Colomar (man-pages)" writes: > [CC += Thomas, Ingo, Peter, Darren] > > Hi Oleg, > > On 12/16/20 3:33 AM, Jann Horn wrote: >> On Wed, Dec 16, 2020 at 3:21 AM Ted Estes wrote: >>> On 12/15/2020 6:01 PM, Jann Horn wrote: >>>> On Wed, Dec 16, 2020 at 12:25 AM Alejandro Colomar (man-pages) >>>> wrote: >>>>> On 12/16/20 12:23 AM, Alejandro Colomar (man-pages) wrote: >>>>>> On 12/16/20 12:07 AM, Jann Horn wrote: >>>>>>> As the comment explains, you can't actually *attach* >>>>>>> to another task in the same thread group; but that's >>>>>>> not because of the ptrace-style access check rules, >>>>>>> but because specifically *attaching* to another task >>>>>>> in the same thread group doesn't work. >>>> As I said, attaching indeed doesn't work. But that's not what "Ptrace >>>> access mode checking" means. As the first sentence of that section >>>> says: >>>> >>>> | Various parts of the kernel-user-space API (not just ptrace() >>>> | operations), require so-called "ptrace access mode" checks, >>>> | whose outcome determines whether an operation is >>>> | permitted (or, in a few cases, causes a "read" operation >>>> | to return sanitized data). >>>> >>>> You can find these places by grepping for \bptrace_may_access\b - >>>> operations like e.g. the get_robust_list() syscall will always succeed >>>> when inspecting other tasks in the caller's thread group thanks to >>>> this rule. >>> >>> Ah, yes. I missed that back reference while trying to digest that >>> rather meaty man page. A grep on the man page source tree does show a >>> number of references to "ptrace access mode". >>> >>> That said, the ptrace(2) man page also directly references the ptrace >>> access mode check under both PTRACE_ATTACH and PTACE_SEIZE: >>> >>> | Permission to perform a PTRACE_ATTACH is governed by a ptrace | access >>> mode PTRACE_MODE_ATTACH_REALCREDS check; see below. As confirmed, the >>> "same thread group" rule does not apply to either of those operations. A >>> re-wording of rule 1 similar to this might help avoid confusion: 1. If >>> the calling thread and the target thread are in the same thread group: >>> a. For ptrace() called with PTRACE_ATTACH or PTRACE_SEIZE, access is >>> NEVER allowed. b. For all other so-called "ptrace access mode checks", >>> access is ALWAYS allowed. --Ted >> >> Yeah, maybe. OTOH I'm not sure whether it really makes sense to >> explain this as being part of a security check, or whether it should >> be explained separately as a restriction on PTRACE_ATTACH and >> PTRACE_SEIZE (with a note like "(irrelevant for ptrace attachment)" on >> rule 1). But I don't feel strongly about it either way. >> > > As you are the maintainer for ptrace, > could you confirm the above from Jan? > And maybe suggest what you would do with the manual page. > > I'd like to get confirmation that there are still other functions that > require "ptrace access mode" other than ptrace() itself, where it's > valid that the calling thread and the target thread are in the same > group. Large swaths of proc are governed by those checks. In general in the kernel whenever you are accessing another process to perform an operation (especially reading) it will probably use "ptrace access mode" checks. You can see this by with "git grep ptrace_may_access" on the kernel source. Eric