Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5033383iog; Wed, 22 Jun 2022 10:32:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s1KCwewzf6iCUI3yakctH5C8FwvXzCTVaHD78GRuAHTSA9V3g4kRfkmVXUT7QW57Asu0iK X-Received: by 2002:a17:906:604f:b0:718:e9e8:9d2a with SMTP id p15-20020a170906604f00b00718e9e89d2amr4033399ejj.315.1655919124969; Wed, 22 Jun 2022 10:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655919124; cv=none; d=google.com; s=arc-20160816; b=QqY4YcYn43cDps/x/aT+0SB8Czj+wQmXwT6QWmhclv47xBEVZoaOCDOcWPFELZA7o6 8/qd1IsndcVTkGPvcW8HLxci66fbv6clvOTlHtEiAB7fhU5t0YxGuCaDPWINwO8qlOvf PKrkqbZV5cvWDOxwmp6WHhBbbVHZwcNWnThQe/WUvFxhftpbF/JD0rcCOsr1r699iGQ/ B8wIcWgExE/oFGHg0T3j8wSNqwcGBQ4JN2YQV0ehYINq2ggFsNOmuI1SMwGNz35MTME+ VHt72Zo3ylFWRDFSgny5XaM6GGkVKzAzEdWtkDxl/HUpSuMTY03LTlkp7Gaf6qZzWCCQ U8pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=U991fSAn0e5OZS8n2s3T8TVs+b1TUclU+3UhI11zgD8=; b=jkyd6Dc3wgUS6acGfV90kaSlFNByZIRTZyo+TXfwBwuLHg3joeeGrWQArABYfz91XT Lk64+BHAUnWjYvxzJ7WqVHNUdMR33A6BHal6PibRHqfARg8ZlKgbUJWAE5Zi/O0vZxbq Em+5QDgIkmCG5cuNqvYbXy44ka0gd+jtFv26J++eYuYHY68sVIHaUce9F9lrLFwLolsE MaT/e7yWgoA9g1t5tjos7MpLwMCZMQehzLboNqR2KTu5gPzhX/Jk+KoD/NVNCMVSjCrv +h39usZPp7Pf7Tp32HAKRLWxLeeHl3w/p7fq5COQmM+z4XGiTDPnVvtKtEZxzD3YRMCn WdPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=BLyBaisz; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i20-20020a05640242d400b004355043e3fbsi5544024edc.440.2022.06.22.10.31.39; Wed, 22 Jun 2022 10:32:04 -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=@linuxfoundation.org header.s=google header.b=BLyBaisz; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376884AbiFVRQA (ORCPT + 99 others); Wed, 22 Jun 2022 13:16:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358257AbiFVRP6 (ORCPT ); Wed, 22 Jun 2022 13:15:58 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 490A5E19 for ; Wed, 22 Jun 2022 10:15:57 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id z191so872717iof.6 for ; Wed, 22 Jun 2022 10:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=U991fSAn0e5OZS8n2s3T8TVs+b1TUclU+3UhI11zgD8=; b=BLyBaiszrCrs1vOtd+028zjudoDFopra4uBSPF/4NSvS/7/1P0OqEJNhi6TdAFfFFf cxaifim4gniuyKxI4LmozvFGz+Fe+IkzstYW2hZP0/yrMFffhXnLeDZL/vQvmsTOia2T zUIszU7rZWknL4EUAKsGNQqbRBJOj6cFiwNbQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=U991fSAn0e5OZS8n2s3T8TVs+b1TUclU+3UhI11zgD8=; b=Qv+LXHv4hnk1xQNR1SIGgwv4OIThGLWZsJ/qx7CXcj78CMHLPLlmFcmp5ARWueEDVQ L3YZmY9Uk4i/Zrw2bEv/aG36IS/YRGEG50sYgR5WbhfZSoaqnul7THMBpZ3LlPcXJ+Pl iQE7dQ5UQU30cQtu9H7imy2oMNiAOtXxfb0r5PzgeibByW69S5cUsEyT5ye/s0tjTPw4 k1NyuD1ayiJbJ70Y+EKA2t2QfHxJR6xrCiFHVftfC7COyia1Fv3H2vreUgkmDvnU44B+ YfCJ+KPTFxvdMKwUf7mFofiRgtVBB6YiWh7JeaNyTEv68PRBQHvjGkh0YYlv2BQ0mA3A 5ZiQ== X-Gm-Message-State: AJIora/7DEAuNuy+2Rjlawed1B46f5IdazZjHlaWVbgOudx4NYNIFIiO enM8mJN6EmGi0iCxQyOWcKo5+g== X-Received: by 2002:a05:6602:3d3:b0:65d:f99a:2ed1 with SMTP id g19-20020a05660203d300b0065df99a2ed1mr2306309iov.109.1655918156612; Wed, 22 Jun 2022 10:15:56 -0700 (PDT) Received: from [192.168.1.128] ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id c9-20020a029609000000b00331d411da60sm8693375jai.75.2022.06.22.10.15.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jun 2022 10:15:56 -0700 (PDT) Subject: Re: [PATCH] selftests/proc: Fix proc-pid-vm for vsyscall=xonly. To: Dylan Hatch Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan References: <20220616211016.4037482-1-dylanbhatch@google.com> <941e0991-eb3e-f988-8262-3d51ff8badad@linuxfoundation.org> <47312e8a-87fe-c7dc-d354-74e81482bc1e@linuxfoundation.org> From: Shuah Khan Message-ID: Date: Wed, 22 Jun 2022 11:15:55 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 6/21/22 6:18 PM, Dylan Hatch wrote: > On Fri, Jun 17, 2022 at 3:27 PM Shuah Khan wrote: >> >> On 6/17/22 4:05 PM, Dylan Hatch wrote: >>> On Fri, Jun 17, 2022 at 12:38 PM Shuah Khan wrote: >>>> >>>> On 6/17/22 12:45 PM, Dylan Hatch wrote: >>>>> On Thu, Jun 16, 2022 at 4:01 PM Shuah Khan wrote: >>>>>> >>> >>>> >>>> It depends on the goal of the test. Is the test looking to see if the >>>> probe fails with insufficient permissions, then you are changing the >>>> test to not check for that condition. >>> >>> The goal of the test is to validate the output of /proc/$PID/maps, and >>> the memory probe is only needed as setup to determine what the >>> expected output should be. This used to be sufficient, but now it can >>> no longer fully disambiguate it with the introduction of >>> vsyscall=xonly. The solution proposed here is to disambiguate it by >>> also checking the length read from /proc/$PID/maps. >>> >>>> >> >> Makes sense. However the question is does this test need to be enhanced >> with the addition of vsyscall=xonly? >> >>>> I would say in this case, the right approach would be to leave the test >>>> as is and report expected fail and add other cases. >>>> >>>> The goal being adding more coverage and not necessarily opt for a simple >>>> solution. >>> >>> What does it mean to report a test as expected fail? Is this a >>> mechanism unique to kselftest? I agree adding another test case would >>> work, but I'm unsure how to do it within the framework of kselftest. >>> Ideally, there would be separate test cases for vsyscall=none, >>> vsyscall=emulate, and vsyscall=xonly, but these options can be toggled >>> both in the kernel config and on the kernel command line, meaning (to >>> the best of my knowledge) these test cases would have to be built >>> conditionally against the conflig options and also parse the command >>> line for the 'vsyscall' option. >>> >> >> Expected fail isn't unique kselftest. It is a testing criteria where >> a test is expected to fail. For example if a file can only be opened >> with privileged user a test that runs and looks for failure is an >> expected to fail case - we are looking for a failure. >> >> A complete battery of tests for vsyscall=none, vsyscall=emulate, >> vsyscall=xonly would test for conditions that are expected to pass >> and fail based on the config. >> >> tools/testing/selftests/proc/config doesn't have any config options >> that are relevant to VSYSCALL >> >> Can you please send me the how you are running the test and what the >> failure output looks like? > > I'm building a kernel with the following relevant configurations: > > $ cat .config | grep VSYSCALL > CONFIG_GENERIC_TIME_VSYSCALL=y > CONFIG_X86_VSYSCALL_EMULATION=y > CONFIG_LEGACY_VSYSCALL_XONLY=y > # CONFIG_LEGACY_VSYSCALL_NONE is not set > > Running the test without this change both in virtme and on real > hardware gives the following error: > > # ./tools/testing/selftests/proc/proc-pid-vm > proc-pid-vm: proc-pid-vm.c:328: int main(void): Assertion `rv == len' failed. > Aborted > > This is because when CONFIG_LEGACY_VSYSCALL_XONLY=y a probe of the > vsyscall page results in a segfault. This test was originally written > before this option existed so it incorrectly assumes the vsyscall page > isn't mapped at all, and the expected buffer length doesn't match the > result. > > An alternate method of fixing this test could involve setting the > expected result based on the config with #ifdef blocks, but I wasn't > sure if that could be done for kernel config options in kselftest > code. There's also the matter of checking the kernel command line for > a `vsyscall=` arg, is parsing /proc/cmdline the best way to do this? > We have a few tests do ifdef to be able to test the code as well as deal with config specific tests. Not an issue. Parsing /proc/cmdline line is flexible for sure, if you want to use that route. Thank you for finding the problem and identifying missing coverage. Look forward to any patches fixing the problem. thanks, -- Shuah