Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4032951pxj; Tue, 15 Jun 2021 13:59:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBff40JDr5OeMb3shs3RJnaPDVwSIzKaO2Ke7eWK9U5daTjU5ehwWMnbT6j/3CI/liElwI X-Received: by 2002:a92:dc10:: with SMTP id t16mr947034iln.75.1623790767170; Tue, 15 Jun 2021 13:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623790767; cv=none; d=google.com; s=arc-20160816; b=Bg+Do6G0jv7qLLGnz49wBBfdx033zCmk2qSyiZCk6K9xbVnvfhlx+IrjuTUaXBof8I 6ScM/KhfPVuwdymD6uCRHNbcsdDg3BZlIutbxpIkXSfpRH4Ia8697Lq7CmjGWFkQd0cl 4szDUtBzIyONNgb3u9/QiGenwyAXeS0w2imfAIqQsLL0LsOX8Zz0v/6b09IvGdAyiQKh KhV26U+j3jWDJASoRBQxbZOS7xS+55CqdQqd0iUjtXDHMJ58LUSvrbtk7DGY7FISBdfg AvptODp/syNmL8Q/KChaghDDipNMNzGW2w7ysW8LQTdWgdEBz92u2wfW0v6M8F5AIyHU Grkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=sBxLxf4FrcsggEOYTT1dFKc27Ben3JcpMZ+iTHfSh4M=; b=LDOEJGBiKN+p1Xa5mjyGmMnBT69SWgdSkuCGHkb+c17oGSjYyYti6bvsmnffn5mtpT 2dMOTnPzelq9fujVhKkYZWkfNzMalBXI7XgitYasgm0HHPs5MkjAiW2QTwlI+ZJEfO36 35Y2luUnsii8bJqYB7zPglTf2O2GXFgfrgAC2IW7cGRiDLkQvOr3RwqaHGgbJOoQOKtg fFHAlDJIYILa/kJhRYB3FCUz9CHiYbvfv4zkp4WeX/l6gURWNuNmOL6zbrzjcZOsZ1f1 ESPV47+Mt3YGLch/65vOlB1Z75v6zvHmtnvLNCIxHbJbYt7z+qT7csEHXWlX+gX1ky9T IqBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qoOPzfCW; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r133si209690jac.80.2021.06.15.13.59.10; Tue, 15 Jun 2021 13:59:27 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qoOPzfCW; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230217AbhFOU6w (ORCPT + 99 others); Tue, 15 Jun 2021 16:58:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbhFOU6v (ORCPT ); Tue, 15 Jun 2021 16:58:51 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2DBDC061574; Tue, 15 Jun 2021 13:56:45 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id 22-20020a17090a0c16b0290164a5354ad0so2626095pjs.2; Tue, 15 Jun 2021 13:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=sBxLxf4FrcsggEOYTT1dFKc27Ben3JcpMZ+iTHfSh4M=; b=qoOPzfCWsyStJrRTj3ypUmLWs9KaVh+ew/9w7Gc5TP4nnZNPghDlsVSApsafxGQD6c c7OgbmhU2BGKtsYhZ+6cXCZ0BW1t35QwpzzEVRT2Ad3RlYx/2Yot2XoaH/g1y63nbYPT 4ewM2wWuQvk81/v/Ykalqh3IJjnuFQ1CLAz2SIjIfFzrL2zxgm2/GEfNu79rIXWaYAyI IQKVYw3f+KOLPEAQj/A7RoYydAHO29/vHTCPS/LRQ+TBLs9Ve1aotzmLKJ0fBxkNxlBY V0WN6qYalvfZN980nCq5a0KEU7YQcGUNsohKLzvD7Oyek+5fOatozOwOM505e3f7R0GL 144w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=sBxLxf4FrcsggEOYTT1dFKc27Ben3JcpMZ+iTHfSh4M=; b=bCz6GyI+BTMLu+hakLuw0A5EL6mpyZKEXmpsWLuSnc8wlxwvHSRNGo5p3h9wOY/dzi txDjZC2Vkbuv1ee9qts+f40RuBY53b7CcfqtRUenb6Tmvrvp4sK2CQMkOcgM/2ECGtvA jX5Tz6DogoSyAVSnHwDkLPS3g3b77Yn2uwxJoWDgB4QiJfAMZ+WYCw5DsNnZ8e6aPWTH IK5hK9XtRaDtlvnLOwuCEVpnY/txqHVVE2umZi9pWYd4EKu1+kG/VsOcrWbSF3g2IwQt TW+71VgXHDzozqyebIjqKF/KZf90QDeAoUrbPiUb27+Mt9EH8D+hhviQdJpWN4DbSxss Z73w== X-Gm-Message-State: AOAM530EMd+AXYees6QfpQwoBJimp25Q8yB/PPDAGxYvELuVf6WM3zcG DXOhrCkUB0RGXJhCxViV4Eg= X-Received: by 2002:a17:902:b181:b029:fc:c069:865c with SMTP id s1-20020a170902b181b02900fcc069865cmr5981998plr.28.1623790605160; Tue, 15 Jun 2021 13:56:45 -0700 (PDT) Received: from ?IPv6:2001:df0:0:200c:a550:e6ef:8525:d5e0? ([2001:df0:0:200c:a550:e6ef:8525:d5e0]) by smtp.gmail.com with ESMTPSA id s11sm3369427pjz.42.2021.06.15.13.56.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Jun 2021 13:56:44 -0700 (PDT) Subject: Re: Kernel stack read with PTRACE_EVENT_EXIT and io_uring threads To: "Eric W. Biederman" Cc: Linus Torvalds , linux-arch , Jens Axboe , Oleg Nesterov , Al Viro , Linux Kernel Mailing List , Richard Henderson , Ivan Kokshaysky , Matt Turner , alpha , Geert Uytterhoeven , linux-m68k , Arnd Bergmann , Ley Foon Tan , Tejun Heo , Kees Cook , John Paul Adrian Glaubitz References: <87sg1p30a1.fsf@disp2133> <87pmwsytb3.fsf@disp2133> <87sg1lwhvm.fsf@disp2133> <6e47eff8-d0a4-8390-1222-e975bfbf3a65@gmail.com> <924ec53c-2fd9-2e1c-bbb1-3fda49809be4@gmail.com> <87eed4v2dc.fsf@disp2133> <5929e116-fa61-b211-342a-c706dcb834ca@gmail.com> <87fsxjorgs.fsf@disp2133> From: Michael Schmitz Message-ID: <7277aa4b-5d3f-6bb3-379a-470df4addd15@gmail.com> Date: Wed, 16 Jun 2021 08:56:35 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87fsxjorgs.fsf@disp2133> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric, On 16/06/21 7:30 am, Eric W. Biederman wrote: > >>> The io_uring tasks are special in that they are user process >>> threads that never run in userspace. So as long as everything >>> ptrace can read is accessible on that process all is well. >> OK, I'm testing a patch that would save extra context in sys_io_uring_setup, >> which ought to ensure that for m68k. > I had to update ret_from_kernel_thread to pop that state to get Linus's > change to boot. Apparently kernel_threads exiting needs to be handled. Hadn't yet got to that stage, sorry. Still stress testing stage 1 of my fix (push complete context). I would have thought that this should be sufficient (gives us a complete stack frame for ptrace code to work on)? But it makes sense that when you push an extra stack frame, you'd need to pop that on exit. > >>> Having stared a bit longer at the code I think the short term >>> fix for both of PTRACE_EVENT_EXIT and io_uring is to guard >>> them both with CONFIG_HAVE_ARCH_TRACEHOOK. > Which does not work because nios2 which looks susceptible > sets CONFIG_HAVE_ARCH_TRACEHOOK. > > A further look shows that there is also PTRACE_EVENT_EXEC that > needs to be handled so execve and execveat need to be wrapped > as well. > > Do you happen to know if there is userspace that will run > in qemu-system-m68k that can be used for testing? I surmise so. I don't use qemu myself - either ARAnyM, or actual hardware. Hardware is limited to 14 MB RAM, which has prevented me from using more than simple regression testing. In particular, I can't test sys_io_uring_setup there. Adrian uses qemu a lot, and has supplied disk images to work from on occasion. Maybe he's got something recent enough to support sys_io_uring_setup ... I've CC:ed him in, as I'd love to do some more testing as well. Cheers,     Michael > > Eric >