Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp962062pxp; Wed, 16 Mar 2022 22:45:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkW+0XLPhGT73UnmVr1C386/69WVKAUg+6lm9yGAyZGHJQDjHpK2mqyZZaB+D1L/EpzEx5 X-Received: by 2002:a05:6a00:24c4:b0:4f7:2fc6:50e8 with SMTP id d4-20020a056a0024c400b004f72fc650e8mr3314484pfv.63.1647495925054; Wed, 16 Mar 2022 22:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647495925; cv=none; d=google.com; s=arc-20160816; b=swYZUzBa5xYf8l7FfjORQLHl8teZy/WJY1YSt+R1NzAiZF4oSnNpFCa2ch6Iu5A2Fp E5I1LWJiALSMnFjVmn4LAFj/+Emg1FW9y3A63G4kLzEJcx1ztyE/ZiG2pBTig5YPu9ms qmma0hJ5cIvG56x6zcHqU/W+RQDrC1QlXbDSyzoturc0IkSbu6WZUvJYZ+mv+eAeAzgS EdZe5vJBAK49HUZRvZt8p1f5RaNoZjtHpk/fw1+SWAhNrnOSH17GOEpP8jwOQp7Kpm/I +6bsAJGqr4KXzCKlOJctTFNyg/Z5cRcFh3AHZHFTjoyD7YnghOyrwkh6tB2JOrS3cfir ncPg== 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=2v5bS+URIkLuCOMxmpJEVC+ukptrZZTNAb9Iqx+TaW0=; b=u0Qk1mdr13QeUn5Hq4akt4isvsJ9EEYvEskp7nrpCKWN2crQ3fMu623KvcNqWxuFAF hJGgXDGFZI+f41CLPhHf0dN23alJLmW765qMMhgzat+i+THrVtdqHDGkxfVgnKMBdjUh 77SPBZWhCkI2E56dNtlyUQXPPx4ByFEiSROJQiYK3PVUsKz3O8PxaENkRVi72FU5i0ww WL3Se/Mc1ixih+nmRBJE6iPuHkQRw0nhgwmfAyUl7qWnr8RB8GbFxKS7rAanm7qH06mw EHAh5SAggNuDnioQaV1OuwQR6gYzqg+aKjMRoRwm0M8GPw7MGWT2OxFT37TkjDql27uY fVDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g26-20020a639f1a000000b003816043efbasi1089814pge.431.2022.03.16.22.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:45:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DC792127598; Wed, 16 Mar 2022 21:39:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352547AbiCOXUX (ORCPT + 99 others); Tue, 15 Mar 2022 19:20:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352542AbiCOXUV (ORCPT ); Tue, 15 Mar 2022 19:20:21 -0400 Received: from out03.mta.xmission.com (out03.mta.xmission.com [166.70.13.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B80902B1AD; Tue, 15 Mar 2022 16:19:08 -0700 (PDT) Received: from in02.mta.xmission.com ([166.70.13.52]:49304) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nUGRX-000gSW-46; Tue, 15 Mar 2022 17:19:07 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:37848 helo=email.froward.int.ebiederm.org.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 1nUGRW-00EYhW-AA; Tue, 15 Mar 2022 17:19:06 -0600 From: "Eric W. Biederman" To: Cc: Linus Torvalds , Alexey Gladkov , Kyle Huey , Oleg Nesterov , Kees Cook , Al Viro , , Jens Axboe References: <87a6ha4zsd.fsf@email.froward.int.ebiederm.org> <87bl1kunjj.fsf@email.froward.int.ebiederm.org> <87r19opkx1.fsf_-_@email.froward.int.ebiederm.org> <87o82gdlu9.fsf_-_@email.froward.int.ebiederm.org> Date: Tue, 15 Mar 2022 18:18:59 -0500 In-Reply-To: <87o82gdlu9.fsf_-_@email.froward.int.ebiederm.org> (Eric W. Biederman's message of "Tue, 08 Mar 2022 18:13:34 -0600") Message-ID: <87tubyx0rg.fsf_-_@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1nUGRW-00EYhW-AA;;;mid=<87tubyx0rg.fsf_-_@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.174.4;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18q0QTOMQzEBUR9felhWzseChKcq8/iNIs= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-DCC: XMission; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *; X-Spam-Relay-Country: X-Spam-Timing: total 245 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 8 (3.4%), b_tie_ro: 7 (2.9%), parse: 0.73 (0.3%), extract_message_metadata: 2.3 (0.9%), get_uri_detail_list: 0.62 (0.3%), tests_pri_-1000: 3.3 (1.4%), tests_pri_-950: 1.10 (0.4%), tests_pri_-900: 0.84 (0.3%), tests_pri_-90: 74 (30.0%), check_bayes: 73 (29.6%), b_tokenize: 4.5 (1.8%), b_tok_get_all: 4.6 (1.9%), b_comp_prob: 1.74 (0.7%), b_tok_touch_all: 59 (24.1%), b_finish: 0.79 (0.3%), tests_pri_0: 140 (57.3%), check_dkim_signature: 0.42 (0.2%), check_dkim_adsp: 2.8 (1.1%), poll_dns_idle: 1.05 (0.4%), tests_pri_10: 1.76 (0.7%), tests_pri_500: 5 (2.2%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 0/2] ptrace: Making the ptrace changes atomic 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 While working on cleaning up the exit path it have had occasion to look at what guarantees are provided for setting and reading the fields that are provided in task_struct for ptraces. Namely exit_code, ptrace_message, and last_siginfo. It turns out as the ptrace interface in the kernel was extended in the kernel the old existing interfaces in the kernel were just wrapped and not properly updated to handle the new functionality. This lead to races and inconsistencies. This fixes the reason for the races and inconsistencies by moving the work of maintaining the ptrace fields into ptrace_stop. The inconsistency that results in some ptrace_stop points continuing with a signal while others will not I have left alone as it appears to be part of our userspace ABI, and changing that risks breaking userspace. Eric W. Biederman (2): ptrace: Move setting/clearing ptrace_message into ptrace_stop ptrace: Return the signal to continue with from ptrace_stop include/linux/ptrace.h | 17 +++++++---------- include/uapi/linux/ptrace.h | 2 +- kernel/signal.c | 40 ++++++++++++++++++++++++---------------- 3 files changed, 32 insertions(+), 27 deletions(-) Eric