Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2318561rwd; Wed, 17 May 2023 08:28:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wqpnH3mZpoucum13J4E4twPw2KLA3xu6iaRVzf6qxMdM2W7WNgOUBPt/tVUa6xLrc/ebS X-Received: by 2002:a17:902:ab91:b0:1ad:dbea:6e09 with SMTP id f17-20020a170902ab9100b001addbea6e09mr16914520plr.66.1684337306691; Wed, 17 May 2023 08:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684337306; cv=none; d=google.com; s=arc-20160816; b=SOZaY5aNne/Brk51ivafa550ml5QDkyUovOpHEXsWS95in/Rem/SfsPf7L1HPrnoGy tIlUXL1I53OQnfXlFx/UF8K3/mk1LlrsP45EKk1/glbpPC7sAWSoCOCiaCjpVXd7s5P7 h7tztbsczs8a0quHeAfqc7+l4XUiWPtiJvD9VSW+MA9fOCKuorzYoFM0sDqPBhoqszSW K3mzX0t8jpAV3QwmwgTIziN+MAIC2oGDKfLr1NH7S8C1jKgxb8wsUdUhPkdCSrUdmwMk ZLWBHU6qOT73rka1G+iru2Th2nCZNDyViFQ/bGhJi988T+kfstczU/ibSSfNfYfHKlwU h2fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=HphpZG1cfp4ZuEeq32BSNbxONoUw/U/BOfxh6PlDKrI=; b=KP4VdDUGkscSVXxnNn2WhUvUpLeUU60TEXHRShnueNH6B3S1ZPxugMDwsAcwzF7T1i PRHVlY1Vo7yx81ndGwoJHLIRcKDxevWlCcNors6cQNi08NRjZX+n4bahcq0tGk1ijKLA HUg5CZ56Fr2FNkPedxIOouUUAUsg6XvWAfng7VmNXh3SbqzcXKHYt1IeymbV6EvnZKX7 0/UJUHZpT/tJKVE2k/3thuV07cznpWCmQ8eLTvFMoV5rtNjMpJn2XqDI4CSBB6QvgWhN rawJvKrFPk/NTn+ZYJ8+TyzVDTfk4uFja27i8WcKXoXOmGj5wa+xXA+pSUG9yk6EoiQg pdTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=eAbUHob0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv15-20020a17090ae40f00b0024df86690a6si1921478pjb.135.2023.05.17.08.28.14; Wed, 17 May 2023 08:28:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=eAbUHob0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232070AbjEQPWH (ORCPT + 99 others); Wed, 17 May 2023 11:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231704AbjEQPWG (ORCPT ); Wed, 17 May 2023 11:22:06 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 008757A8F for ; Wed, 17 May 2023 08:22:02 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-510d8b0163fso3598a12.1 for ; Wed, 17 May 2023 08:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684336921; x=1686928921; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HphpZG1cfp4ZuEeq32BSNbxONoUw/U/BOfxh6PlDKrI=; b=eAbUHob0fvSN+keUC4LH8COrh2z6bi/dUGViO2F8YhgafASrYUyJhiI1nnoxS4F0u4 oOfvp6HZwnW+7ZfQ2maR569eeTSTLJqZDlCfUMGU6qnqnDBNZpvxvn+l3qLbZ3DaHhdb a55sDMdXNOWilq21OpS2MBescQVd1sIMEM17wvmciHj0af+PfkCl85wEyMoh5aFLrajy DcGHkMp6BYdqoPD2RcQfHhWkgxWez0NVDti2+0XbaXRdjsOLPa4nnRP2WQAoOpQJImS5 weEUDQRHGB6LPTpDTSs8ROoEpiKzYsac6RzNDnYZsGsvgTG5tIfLmcHbQeuoEEoZ1Pos U/qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684336921; x=1686928921; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HphpZG1cfp4ZuEeq32BSNbxONoUw/U/BOfxh6PlDKrI=; b=N4IPmuZF6ZV5dfb5i3yq8AeSpG06ja5mnxq17rK3TTVlIEFZzutjpNRZPojJ+wC5Yv SiAgJjt4YZcvOtMFSiaZda55VHB+bMQBclXFlgU2rigwjF3rYWy91gvBOPVAmqRQq3y8 MuqqAR/EQslsDU3Jrzf0YxtE4cT5Adv2B3kezle7rXqDG4DaPnD8cotoDYCkFk0NtvAc im3ANBfVECVQg+vI8rwUNOBdQAk4ll5LBUiRb89/NMjQ0ErfV1dpzzruQ8ToSklNxSeA Whn9Ig6zlGrwp2OdxCR8M/cRDxxzSoMvHkctZ7GVeKS41MYvqHcptwFR964tanwlL32d 2ETw== X-Gm-Message-State: AC+VfDxL2cS5jCDHj/Zlka3L1i6kbW9QQZzXFc4J35/Ku1xJ3Vz7psyA cB71JTtJtX9bi+cqeMZvnsm5qun98kOS1fPhF7yD0w== X-Received: by 2002:a50:aadd:0:b0:50b:f6ce:2f3d with SMTP id r29-20020a50aadd000000b0050bf6ce2f3dmr142899edc.0.1684336921213; Wed, 17 May 2023 08:22:01 -0700 (PDT) MIME-Version: 1.0 References: <20230515130553.2311248-1-jeffxu@chromium.org> <2bcffc9f-9244-0362-2da9-ece230055320@intel.com> In-Reply-To: From: Jeff Xu Date: Wed, 17 May 2023 08:21:23 -0700 Message-ID: Subject: Re: [PATCH 0/6] Memory Mapping (VMA) protection using PKU - set 1 To: Dave Hansen Cc: =?UTF-8?Q?Stephen_R=C3=B6ttger?= , jeffxu@chromium.org, luto@kernel.org, jorgelo@chromium.org, keescook@chromium.org, groeck@chromium.org, jannh@google.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 17, 2023 at 8:07=E2=80=AFAM Dave Hansen = wrote: > > On 5/17/23 03:51, Stephen R=C3=B6ttger wrote: > > On Wed, May 17, 2023 at 12:41=E2=80=AFAM Dave Hansen wrote: > >> Can't run arbitrary instructions, but can make (pretty) arbitrary sysc= alls? > > > > The threat model is that the attacker has arbitrary read/write, while o= ther > > threads run in parallel. So whenever a regular thread performs a syscal= l and > > takes a syscall argument from memory, we assume that argument can be at= tacker > > controlled. > > Unfortunately, the line is a bit blurry which syscalls / syscall argume= nts we > > need to assume to be attacker controlled. > > Ahh, OK. So, it's not that the *attacker* can make arbitrary syscalls. > It's that the attacker might leverage its arbitrary write to trick a > victim thread into turning what would otherwise be a good syscall into a > bad one with attacker-controlled content. > > I guess that makes the readv/writev-style of things a bad idea in this > environment. > > >>> Sigreturn is a separate problem that we hope to solve by adding pkey > >>> support to sigaltstack > >> > >> What kind of support were you planning to add? > > > > We=E2=80=99d like to allow registering pkey-tagged memory as a sigaltst= ack. This would > > allow the signal handler to run isolated from other threads. Right now,= the > > main reason this doesn=E2=80=99t work is that the kernel would need to = change the pkru > > state before storing the register state on the stack. > > > >> I was thinking that an attacker with arbitrary write access would wait > >> until PKRU was on the userspace stack and *JUST* before the kernel > >> sigreturn code restores it to write a malicious value. It could > >> presumably do this with some asynchronous mechanism so that even if > >> there was only one attacker thread, it could change its own value. > > > > I=E2=80=99m not sure I follow the details, can you give an example of a= n asynchronous > > mechanism to do this? E.g. would this be the kernel writing to the memo= ry in a > > syscall for example? > > I was thinking of all of the IORING_OP_*'s that can write to memory or > aio(7). IORING is challenging from security perspectives, for now, it is disabled in ChromeOS. Though I'm not sure how aio is related ? Thanks -Jeff