Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1329842lqz; Mon, 1 Apr 2024 02:48:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+Oihwp+8dTzz8AP24dv1ZuBG/ogohX23fp085qKm4XI7THyhNE9Ov7QObBVMdlEs/v++GzvbOoc78/UIJnZ0/jEbeYBdAjwgF7pFZpg== X-Google-Smtp-Source: AGHT+IGM2pKzfd8Q8I9TPk4t3+NOEe09hIrb2FFSeUAlg6/pq++OjMTO/vaga7KGejElPkoB/MF0 X-Received: by 2002:a05:620a:1a11:b0:78a:4590:ce2b with SMTP id bk17-20020a05620a1a1100b0078a4590ce2bmr12159560qkb.1.1711964904100; Mon, 01 Apr 2024 02:48:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711964904; cv=pass; d=google.com; s=arc-20160816; b=mNv5H/UnbrARgnOXa76T5Mz86zSOeTEGmxIzpsSwkWczw0zyG+a73E9DnmTJwW7iwz X3Vc1XlPrRCSXxrE2Pt+HG+lHnCGiPKvMZ92/fv6+HjK7NMPYQGXUon9opUuezJ0SVnX ebyF9HWGL9CVWIkVs7UNq6LH8cTQkpqMuL+pDGHk8xMu9NoZAuUx8SYS/h77NRTJ9bkJ gR2Lgioe8HB527RwiRqDQxc06HiV/BCT116y0DUbCmOpK/EwotGjPwfKWhY7biNkNbNV FLQuKmQtVJqk1CpbqsgS7uoZ0vrIqdx0L17VSvujeXEDE/I5Zm4mf1kxIR1TsvLthouo vDOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Ztu2FvgPGsMIM9MGAhUC5Pglx6IH/1lc7B3TQ59R8vk=; fh=GDS+cVWzkuJgHKulSb3wojWXYDFXmcvufEgX01u35a4=; b=FYlnmh6fdFBxky+MO19N680a6SDDwZ6gBCpAHVzeehjkTxSYh+jM4XoE88PNHIcekg HdWrFvSjogEHEzKKBYTEawKIrxdxJIHuGdsJ/Ailq183syTbgr4em3vE8B/F91coI95Z LcQaitLkRQlZilpMAKskqEM75NDumMWWTtsy+3h6zzIOTXAtvkJyAOSrS42Lb5RrtQVc bSAp+7mvtWQqmwbixEsw44H+0G6q1Y6dRHnJrBqohdjysiZjfKCKeKUUwV+Iax1fqzYt 1ZrAFaSLrFeNIf4KBTDdrhZQ24XpWEr2Mgh47MMEU6ihKrUIrNa6nW1ElXqAt2SUrZlS d/+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=IKkpukb8; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-126574-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126574-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u6-20020a05620a454600b0078be3266847si2205303qkp.674.2024.04.01.02.48.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 02:48:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126574-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=IKkpukb8; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-126574-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126574-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CE49B1C20F4F for ; Mon, 1 Apr 2024 09:48:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37F0512E73; Mon, 1 Apr 2024 09:48:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="IKkpukb8" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 905DE1095A; Mon, 1 Apr 2024 09:48:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711964889; cv=none; b=iMxA5RUze03NOGMcnJ8ey3HJAXlIoaLgkq1TDpE2oLgpzPzsDKZFmDIV8yoELl0JZF51VeMpx6OZ9S5yFPhw1SC6NncsC+OXqr4PQIgzbBj0QmfxL/gViIw+e1F+SJsPR86onPtH3gfvHqGqYe2hJOoIQ9gNc50YJpvsih3zuLM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711964889; c=relaxed/simple; bh=06wOk/U0MualMJ4bunj44L58B9nb+s9Iaqf0BY9Iihk=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=R0fbu7d0cnvSSeCj3pCBCiwTZkqtlB0XIWrn59lYf7ez8ee3gzmrVeKm1j3rIsioVzGqIXa3ofzsMpcbtw5Vexqdb8RoimQje0WX9K0wZ1LnLPsPeaMuX612eLaUce6H4YpULPJoreYQraGH9UGwICmVPk39VF6Ck1/EyuxJV0M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=IKkpukb8; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1711964885; bh=06wOk/U0MualMJ4bunj44L58B9nb+s9Iaqf0BY9Iihk=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=IKkpukb884sj8Eg4Yw/1yM6F+jVI41WbIFR5wppl38DPIFzg7d+snPhJSh90a3YbB 6UxRTezpSmT4wNQmWC70hAfP/JxH0Ch921mvOmRMG6ao7uQPIuZ7OsFD7KR2aH5N87 tG0r+nrikfEXbQvrvlxX1XWEKAWH5gay7UPdFl6DDuIhYIr3WnRTZy/d4En7a/hkhB ryU3/OINHUKgVPtbeLhy24Ru35rCA0iPfjdVytimtX+uverHEJe3H4njiECn3UAPIe pNY86YqfqdyTKZh6NivIn+8POtsgH3Jxd+ULYNYtQQqgOUeGD7ZqZngxjW5K5IDaXk qoDfDq7BJ5Z5Q== Received: from [10.193.1.1] (broslavsky.collaboradmins.com [68.183.210.73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 8BFC2378148F; Mon, 1 Apr 2024 09:47:23 +0000 (UTC) Message-ID: Date: Mon, 1 Apr 2024 14:46:13 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , paul.walmsley@sifive.com, rick.p.edgecombe@intel.com, broonie@kernel.org, Szabolcs.Nagy@arm.com, kito.cheng@sifive.com, keescook@chromium.org, ajones@ventanamicro.com, conor.dooley@microchip.com, cleger@rivosinc.com, atishp@atishpatra.org, alex@ghiti.fr, bjorn@rivosinc.com, alexghiti@rivosinc.com, samuel.holland@sifive.com, palmer@sifive.com, conor@kernel.org, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, corbet@lwn.net, tech-j-ext@lists.risc-v.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, oleg@redhat.com, akpm@linux-foundation.org, arnd@arndb.de, ebiederm@xmission.com, Liam.Howlett@oracle.com, vbabka@suse.cz, lstoakes@gmail.com, shuah@kernel.org, brauner@kernel.org, andy.chiu@sifive.com, jerry.shih@sifive.com, hankuan.chen@sifive.com, greentime.hu@sifive.com, evan@rivosinc.com, xiao.w.wang@intel.com, charlie@rivosinc.com, apatel@ventanamicro.com, mchitale@ventanamicro.com, dbarboza@ventanamicro.com, sameo@rivosinc.com, shikemeng@huaweicloud.com, willy@infradead.org, vincent.chen@sifive.com, guoren@kernel.org, samitolvanen@google.com, songshuaishuai@tinylab.org, gerg@kernel.org, heiko@sntech.de, bhe@redhat.com, jeeheng.sia@starfivetech.com, cyy@cyyself.name, maskray@google.com, ancientmodern4@gmail.com, mathis.salmen@matsal.de, cuiyunhui@bytedance.com, bgray@linux.ibm.com, mpe@ellerman.id.au, baruch@tkos.co.il, alx@kernel.org, david@redhat.com, catalin.marinas@arm.com, revest@chromium.org, josh@joshtriplett.org, shr@devkernel.io, deller@gmx.de, omosnace@redhat.com, ojeda@kernel.org, jhubbard@nvidia.com Subject: Re: [PATCH v2 27/27] kselftest/riscv: kselftest for user mode cfi To: Deepak Gupta References: <20240329044459.3990638-1-debug@rivosinc.com> <20240329044459.3990638-28-debug@rivosinc.com> <4b38393a-f69d-4a77-a896-b6cd42c7edcf@collabora.com> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 3/30/24 1:02 AM, Deepak Gupta wrote: > On Fri, Mar 29, 2024 at 12:50 PM Muhammad Usama Anjum > wrote: >> >> On 3/29/24 9:44 AM, Deepak Gupta wrote: >>> Adds kselftest for RISC-V control flow integrity implementation for user >>> mode. There is not a lot going on in kernel for enabling landing pad for >>> user mode. Thus kselftest simply enables landing pad for the binary and >>> a signal handler is registered for SIGSEGV. Any control flow violation are >>> reported as SIGSEGV with si_code = SEGV_CPERR. Test will fail on recieving >>> any SEGV_CPERR. Shadow stack part has more changes in kernel and thus there >>> are separate tests for that >>> - enable and disable >>> - Exercise `map_shadow_stack` syscall >>> - `fork` test to make sure COW works for shadow stack pages >>> - gup tests >>> As of today kernel uses FOLL_FORCE when access happens to memory via >>> /proc//mem. Not breaking that for shadow stack >>> - signal test. Make sure signal delivery results in token creation on >>> shadow stack and consumes (and verifies) token on sigreturn >>> - shadow stack protection test. attempts to write using regular store >>> instruction on shadow stack memory must result in access faults >>> >>> Signed-off-by: Deepak Gupta >>> --- >>> tools/testing/selftests/riscv/Makefile | 2 +- >>> tools/testing/selftests/riscv/cfi/Makefile | 10 + >>> .../testing/selftests/riscv/cfi/cfi_rv_test.h | 85 ++++ >>> .../selftests/riscv/cfi/riscv_cfi_test.c | 91 +++++ >>> .../testing/selftests/riscv/cfi/shadowstack.c | 376 ++++++++++++++++++ >>> .../testing/selftests/riscv/cfi/shadowstack.h | 39 ++ >> Please add generated binaries in the .gitignore files. > > hmm... > I don't see binary as part of the patch. Which file are you referring > to here being binary? shadowstack would be generated by the build. Create a .gitignore file and add it there. For example, look at tools/testing/selftests/riscv/vector/.gitignore to understand. > >> > -- BR, Muhammad Usama Anjum