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=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham 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 02407C43387 for ; Wed, 16 Jan 2019 17:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C819720840 for ; Wed, 16 Jan 2019 17:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727465AbfAPRkI (ORCPT ); Wed, 16 Jan 2019 12:40:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50672 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727464AbfAPRkI (ORCPT ); Wed, 16 Jan 2019 12:40:08 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D624C002960; Wed, 16 Jan 2019 17:40:07 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.162]) by smtp.corp.redhat.com (Postfix) with SMTP id DDE551C959; Wed, 16 Jan 2019 17:40:04 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 16 Jan 2019 18:40:07 +0100 (CET) Date: Wed, 16 Jan 2019 18:40:04 +0100 From: Oleg Nesterov To: Tetsuo Handa Cc: Kees Cook , "Serge E. Hallyn" , syzbot , James Morris , LKML , linux-security-module , syzkaller-bugs@googlegroups.com Subject: Re: yama: unsafe usage of ptrace_relation->tracer Message-ID: <20190116174003.GB20060@redhat.com> References: <20181022134634.GA7358@redhat.com> <201810250215.w9P2Fm2M078167@www262.sakura.ne.jp> <20181025111355.GA3725@redhat.com> <20181025121709.GD3725@redhat.com> <20181025130129.GE3725@redhat.com> <20181029122356.GA29883@redhat.com> <20181029150546.GA30959@redhat.com> <0fc3493d-a50e-f386-20a8-28d348c19544@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0fc3493d-a50e-f386-20a8-28d348c19544@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 16 Jan 2019 17:40:07 +0000 (UTC) Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: On 01/10, Tetsuo Handa wrote: > > syzbot is hitting this problem as of linux-next-20190110. > When a patch will be proposed? Well. I have already suggested the patch below several times. It won't fix all problems in this code (I forgot the details but iirc ptracer_exception_found() is broken too, task_is_descendant() should be cleanuped, may be something else), but probably this trivial fix makes sense for the start? Oleg. --- x/security/yama/yama_lsm.c +++ x/security/yama/yama_lsm.c @@ -368,7 +368,8 @@ static int yama_ptrace_access_check(stru break; case YAMA_SCOPE_RELATIONAL: rcu_read_lock(); - if (!task_is_descendant(current, child) && + if (!pid_alive(child) || + !task_is_descendant(current, child) && !ptracer_exception_found(current, child) && !ns_capable(__task_cred(child)->user_ns, CAP_SYS_PTRACE)) rc = -EPERM;