From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65AA9C43334 for ; Thu, 16 Jun 2022 23:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379321AbiFPXBx (ORCPT ); Thu, 16 Jun 2022 19:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379308AbiFPXBv (ORCPT ); Thu, 16 Jun 2022 19:01:51 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A03462A2A for ; Thu, 16 Jun 2022 16:01:50 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id y17so1900883ilj.11 for ; Thu, 16 Jun 2022 16:01:50 -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=dxYlFYa08li+b2bH2lpzssUgCCuwu/1aYyeRjozsoxA=; b=WI575e9Yb3UURQikbwMwnVlY7aFjJ5HZCCsnkaOWrdzEauSAVut+sqOcHZgLf0S7xa zqp6pmpRe8FHVecMzWb/PTiZZfyk5w2koS6iDe4Vg1KswQd3pBxNC++CyRGIgIveOAOf EDkFaZlrYPNMKdPMa8l9eLQGJYIp65QDsGwnE= 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=dxYlFYa08li+b2bH2lpzssUgCCuwu/1aYyeRjozsoxA=; b=cA0PZ/TF7c8FHuwJHiNIwjIc53D+fEgzY85Y9gvVzVSCbjnNoa3sg8f7WD4gC671W5 gpyUmPPh3RVHNYehaUaEs4kJl36pB/U7bStk7BceAADiCkMhq6P5si5pfU6EcLqw70UG QYtD/GYPpNJJdFPsTqD/by4o3vx2E/SQtN30eqHjsRR0EMCJ/Tcw6s+Mk/oGl9ENwW8d mfhADeaHvk6vCDbP0wqze4iAbEgsXst4d8eq/HbpPzf7AaQFkq6Mx1t0+cvT64XaUqG2 +yrlkvcX2kffiQ03QBz2Z6fACWxmogh6omAx7AcVHZ0RuVDidEP1TWBcEhKZa3MrRdXR sd6Q== X-Gm-Message-State: AJIora867aeKXpss8pLvcOgCgxd8EDOogRjvvf47DOtDTc9/Yi9qkl/O SKa+E/KBCn3tQukj5h4p3kjdfN1op7TFAw== X-Google-Smtp-Source: AGRyM1s7LIyJLY6T2Uw2EEkj6wJqA6dr2rUEctCYF7at0sSK8+Zh7zsCGDCfSXKU0oW2S2jL2LftaQ== X-Received: by 2002:a05:6e02:152f:b0:2d4:980:a529 with SMTP id i15-20020a056e02152f00b002d40980a529mr4197820ilu.72.1655420509530; Thu, 16 Jun 2022 16:01:49 -0700 (PDT) Received: from [192.168.1.128] ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id s71-20020a02514a000000b0033171dafaa0sm1414627jaa.178.2022.06.16.16.01.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Jun 2022 16:01:49 -0700 (PDT) Subject: Re: [PATCH] selftests/proc: Fix proc-pid-vm for vsyscall=xonly. To: Dylan Hatch , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan References: <20220616211016.4037482-1-dylanbhatch@google.com> From: Shuah Khan Message-ID: <941e0991-eb3e-f988-8262-3d51ff8badad@linuxfoundation.org> Date: Thu, 16 Jun 2022 17:01:48 -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: <20220616211016.4037482-1-dylanbhatch@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/16/22 3:10 PM, Dylan Hatch wrote: > This test would erroneously fail the /proc/$PID/maps case if > vsyscall=xonly since the existing probe of the vsyscall page only > succeeds if the process has read permissions. Fix this by checking for > either no vsyscall mapping OR an execute-only vsyscall mapping in the > case were probing the vsyscall page segfaults. > Does this fix include skipping the test with a clear message that says why test is skipped? > Signed-off-by: Dylan Hatch > --- > tools/testing/selftests/proc/proc-pid-vm.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c > index 28604c9f805c..5ca85520131f 100644 > --- a/tools/testing/selftests/proc/proc-pid-vm.c > +++ b/tools/testing/selftests/proc/proc-pid-vm.c > @@ -213,9 +213,12 @@ static int make_exe(const uint8_t *payload, size_t len) > > static bool g_vsyscall = false; > > -static const char str_vsyscall[] = > +static const char str_vsyscall_rx[] = > "ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n"; > > +static const char str_vsyscall_x[] = > +"ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0 [vsyscall]\n"; > + > #ifdef __x86_64__ > static void sigaction_SIGSEGV(int _, siginfo_t *__, void *___) > { > @@ -261,6 +264,7 @@ int main(void) > int exec_fd; > > vsyscall(); > + const char *str_vsyscall = g_vsyscall ? str_vsyscall_rx : str_vsyscall_x; > > atexit(ate); > > @@ -314,7 +318,8 @@ int main(void) > > /* Test /proc/$PID/maps */ > { > - const size_t len = strlen(buf0) + (g_vsyscall ? strlen(str_vsyscall) : 0); > + const size_t len_buf0 = strlen(buf0); > + const size_t len_vsys = strlen(str_vsyscall); > char buf[256]; > ssize_t rv; > int fd; > @@ -325,11 +330,16 @@ int main(void) > return 1; > } > rv = read(fd, buf, sizeof(buf)); > - assert(rv == len); > - assert(memcmp(buf, buf0, strlen(buf0)) == 0); > if (g_vsyscall) { > - assert(memcmp(buf + strlen(buf0), str_vsyscall, strlen(str_vsyscall)) == 0); > + assert(rv == len_buf0 + len_vsys); > + } else { > + /* If vsyscall isn't readable, it's either x-only or not mapped at all */ > + assert(rv == len_buf0 + len_vsys || rv == len_buf0); > } > + assert(memcmp(buf, buf0, len_buf0) == 0); > + /* Check for vsyscall mapping if buf is long enough */ > + if (rv == len_buf0 + len_vsys) > + assert(memcmp(buf + len_buf0, str_vsyscall, len_vsys) == 0); > } > > /* Test /proc/$PID/smaps */ > The change looks good to me. Doesn't look like it skips the test though? thanks, -- Shuah