Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1889589iog; Thu, 16 Jun 2022 16:35:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vA60iRFPclaPRxWrqkXD1a7lUGzPl+yvuvwpdJk4Arg0ERYW91tDh0uSZkGGdXHVYb50U4 X-Received: by 2002:a17:906:d84:b0:715:7f3d:403f with SMTP id m4-20020a1709060d8400b007157f3d403fmr6878811eji.406.1655422537159; Thu, 16 Jun 2022 16:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655422537; cv=none; d=google.com; s=arc-20160816; b=Mkz1RdsZt24Rr3Fv0S/tPED+o6Mq5dI8dUKGo02fCZmFxm21BkxkFzrbctcT4TcNd5 Du2WwpcGFpE2N/f7Tfpp9165EZeoz5+alqaV0kvg1a/LSm3oU6V9FnRGOyGJywhPcTKg 38/8+7euxilLKDhas2SImrPuZdSHiowtn3LzGhnz5aOT82LjTXZoRG9JBCkm5AIhl3xg kEnBevk36IpEIfdY23jJqST70FqeBq1wOVeF99h0zl25kyv8gQQ+xGw0E9RsWIXhvL3i 3RxgTl6fPXS0V4R79dyuuH54pUG5xP27pgXW+GKaK//FvVs5w9BYPR4zkZv+H7R7Mv7C bZNw== 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=dxYlFYa08li+b2bH2lpzssUgCCuwu/1aYyeRjozsoxA=; b=NkTRtpExoltvuieBBhRdDDU4KyaaGhbJs1BXcO7eNa0z/AkrJIi2lgd1YgrpnF2gHi lGAzO9ho9AmFinVgMPrD+CqEGcrDy9/Dc97RPXD3Npg2PSLxXWHlMjRO7GrpmTFMkbeO TUM3ZL0MNM3djTEvbFvvVr6GqareNa+I+5rv45lmfLcHget207dT5Gv/PsLnqqxuSbHw xZgRd/F0OeHr4XMiE5zbgy9kWJoT+4MXOEN0fvzCqmBaETb7mLFt4TLx+Xp2lgSyTzFq uqKE6NrgwOCd/6gPsYjm8tiOPqu59XvMZA7JfEDFrB/sB1pmViqVZNOVUhtKl6tvZAlm fPLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=WI575e9Y; 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 h21-20020a170906111500b00707cb88fcbcsi2621468eja.93.2022.06.16.16.35.10; Thu, 16 Jun 2022 16:35:37 -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=WI575e9Y; 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 S1379317AbiFPXBx (ORCPT + 99 others); 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-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 X-Spam-Status: No, score=-5.3 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/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