Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp819432rdb; Fri, 26 Jan 2024 11:37:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcu0ZCnYOHeN5DQuhaYp9OZPDab7lCIzfQB4+xNFey0CZm0UKkz9DLONoxzuLx+Mun0+4b X-Received: by 2002:adf:f485:0:b0:339:58fc:492d with SMTP id l5-20020adff485000000b0033958fc492dmr93650wro.90.1706297830280; Fri, 26 Jan 2024 11:37:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706297830; cv=pass; d=google.com; s=arc-20160816; b=UScyAo90bFtV041OqNF3wvUuyGK7quIUPStjnws+JeNhdct3skhTxCZq1g5XQH2FuX vD27CaAujVecbTBC4840iQods20Ti4QByicrgBguI/e3npUd3ceucDAi3zDROXWzKl3O JoJKX5wshQVgvYm1tMxguUodoUOlWczDlL7KpYYZ9S5fdW308TOW3pYopZyDtaYVyooa b7iEwlj2IlmrRlK7+ri/vGprpNKloZPDmdoAT6y/a4J7u3CG7Ch5k5mwOIMqh49lD0gH z06t1wKOcB/n0YrmQbPiRH2AerK8L3neFq6fAG+g3dpB4S6bJfg1S/qpVqBbKtY/Ztzl 0HqQ== 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:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=KEVd0QafPgt3Yab5rVKzY8wr3GSCC3qWRHifh5DcWZ0=; fh=990Zm880wdVCNbGAV6xCwZqMaa+KVwfo/JOziIocwU8=; b=r4G8a4UcbvPmmp1u9ILmU8PyeJUCf2GAiaW3W3HJ50KIzcGmU23LkFjDDxlIPgEYVm vjj2fQ8PN5BbX3PuI71gDiXazQ3WN+GQmfg4WyvRDfLL5yd+U9L0qlGWPfP6AxKPjz08 FvvGcHPl0xIDDZ80Ry6LfxlI3eBNXX5TQdbV7WQf/fESZ4nKEYy15RXotkA/yPFL6pkt 7kkqNI7q+PEgvRheiNkpTNkPM2yTCalBsk27dlU3Q7Am7AaKFymI0i0+/ktoCkuYDkhW /7BI6R8Atga40/Z8PBQkSy/1wa40J2Yievs55gFr/4hqMfy7zZvsFhyM8oBLPhfPfYDg OhFQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vhGoTgrv; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-40579-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40579-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ce8-20020a170906b24800b00a32e34b96d0si941007ejb.398.2024.01.26.11.37.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 11:37:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40579-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vhGoTgrv; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-40579-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40579-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0CB751F24F42 for ; Fri, 26 Jan 2024 19:37:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E926B225CB; Fri, 26 Jan 2024 19:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vhGoTgrv" Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (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 582C1224E6 for ; Fri, 26 Jan 2024 19:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706297820; cv=none; b=Gjmz/i3Jp7D23rr2hP6DX12fgIQYBv0mIC+IxKBqNJa7d9Ul04GK+9peOTzGlgJ4/Gv4Re5nbwgaS8cqTWgCZd1CD0WX5hIVfAB24CwQcx62gkKnkHNavCaYi/q75h4nMUtcEH+uqhd3NhN8nbvBRMxgpoeouoNuwAuSY6LoApk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706297820; c=relaxed/simple; bh=uxac+B2JSnMISJQXpWFxm1pKIyER1ZrasfJLcPmesmU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=uya5p7hIIrlSB7hOTpES1jQ04qZIf+20d7loDX/VV+OWy28+jrz3oJOIgTyPlL0uBQ5zc+njyAgiamaos1nZOcvM1oyZupWl//xESbU73YydcyDb5Q/U5/6jAeXCf3dIqGPgTh7Y4gNP/UwijTRp2y7ezSAhKQUZKpOmv3ZUfS0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vhGoTgrv; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1706297816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KEVd0QafPgt3Yab5rVKzY8wr3GSCC3qWRHifh5DcWZ0=; b=vhGoTgrvH/0NZsFkHqENAmU0SSZn3JpCHs8TfdckqNJrksIb122b3AEoLVwebtkbRxp1hT g8U9j1TPUr/Te+IC6VLfrg7sq8jjg4IJz7MTFkjKIWSgyqPhk9Pz10Cz/j/rdNWMtGKwPK e358/DPprgYwehYRy+see+F/9kfDzY0= Date: Fri, 26 Jan 2024 11:36:48 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf v2 3/3] selftest/bpf: Test the read of vsyscall page under x86-64 Content-Language: en-GB To: Hou Tao , x86@kernel.org, bpf@vger.kernel.org Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , linux-kernel@vger.kernel.org, xingwei lee , Jann Horn , Sohil Mehta , houtao1@huawei.com References: <20240126115423.3943360-1-houtao@huaweicloud.com> <20240126115423.3943360-4-houtao@huaweicloud.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <20240126115423.3943360-4-houtao@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 1/26/24 3:54 AM, Hou Tao wrote: > From: Hou Tao > > Under x86-64, when using bpf_probe_read_kernel{_str}() or > bpf_probe_read{_str}() to read vsyscall page, the read may trigger oops, > so add one test case to ensure that the problem is fixed. Beside those > four bpf helpers mentioned above, testing the read of vsyscall page by > using bpf_probe_read_user{_str} and bpf_copy_from_user{_task}() as well. > > The test case passes the address of vsyscall page to these six helpers > and checks whether the returned values are expected: > > 1) For bpf_probe_read_kernel{_str}()/bpf_probe_read{_str}(), the > expected return value is -ERANGE as shown below: > > bpf_probe_read_kernel_common > copy_from_kernel_nofault > // false, return -ERANGE > copy_from_kernel_nofault_allowed > > 2) For bpf_probe_read_user{_str}(), the expected return value is -EFAULT > as show below: > > bpf_probe_read_user_common > copy_from_user_nofault > // false, return -EFAULT > __access_ok > > 3) For bpf_copy_from_user(), the expected return value is -EFAULT: > > // return -EFAULT > bpf_copy_from_user > copy_from_user > _copy_from_user > // return false > access_ok > > 4) For bpf_copy_from_user_task(), the expected return value is -EFAULT: > > // return -EFAULT > bpf_copy_from_user_task > access_process_vm > // return 0 > vma_lookup() > // return 0 > expand_stack() > > The occurrence of oops depends on the availability of CPU SMAP [1] > feature and there are three possible configurations of vsyscall page in > boot cmd-line: vsyscall={xonly|none|emulate}, so there are totally six > possible combinations. Under all these combinations, the running of the > test case succeeds. > > [1]: https://en.wikipedia.org/wiki/Supervisor_Mode_Access_Prevention > > Signed-off-by: Hou Tao The first two patches look good to me but I think it would be better if x86 folks can ack on them. The selftest patch LGTM. Acked-by: Yonghong Song