Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1853533rwb; Fri, 28 Jul 2023 16:36:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlHmauDKBILWvCmO/kN+SRjXsNkfpfU1n4LhL6Okl+g8rgo64qeD/HUC/5dd/k9O9tsuDnO5 X-Received: by 2002:a17:90a:ba18:b0:268:68da:63fe with SMTP id s24-20020a17090aba1800b0026868da63femr2819382pjr.38.1690587391230; Fri, 28 Jul 2023 16:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690587391; cv=none; d=google.com; s=arc-20160816; b=wNfPX6EvKZZujZ2ryHx0rRt25Bf0NHnkxQf6Kod11yDyWSYVRGjk/t4E2HZuIwlWnv IZAshSTbONCwG9x0Anwf2aM7Tr8Quq8IgbWXB5dL9fMIIF9FP7LLjZ+ojnCfutmqdXAa 50gOvZMVs3dIlY5WvwRCTOie/jDnH35ch8J064mmVVTBRWde/iYiRrJONCXdRhi0xZDU OCBQKqXV58ejKnfq3HvckLLyifVwJAd7tGOF4V+KmZCeXnhR9PIfs1U8wAnGCUuAaoNo BEcFxZPb+7qv9OA+6DWYa/i2AMs9k6WG2PTaPTrIPL6MJgbfBCWJrE+zf/PM2tFBkYTH 0gQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=MwUGAXlWTnPRJAd9ATS5GD+jmGk/Py4JKBUesXwXH2A=; fh=Lf33w2+48ylQ8hEeunBTsBAGlU4P5NgQQ+tu4JIo5ZQ=; b=ZZMSIyblaWDAvJXla+A6Pm8YBucBYc3Jai6wEyjzSRvg5db2+9eiZO6yc1N/d8HDO0 n33RRmU3K6KA/nQvvyz5LW3d+RIISCXqHvzexclZTqL4QqJAOaWB8vQzQS7WA8qPqbg5 Q084FEhIKnspTNPhj+giKxQikQ8Yf51k+xwu0E55rBu+tj/7IYlzyAl70iEXV+qPrNSW 7jg4uV8LAwTjnRwQj3e57uYXY/LCniMqTxhfZpxXEocmFcW87rxZDlQD9mfOh3utTqLg uYr/dFO7c7fKJg9HBC0HO1qTHX9h69d/ir392afIHKpa2Wu1NvfLui5GGTTQ3doQhFBb ygVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=d98DSZkd; 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 40-20020a17090a0fab00b002681289fee1si59219pjz.107.2023.07.28.16.36.19; Fri, 28 Jul 2023 16:36:31 -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=d98DSZkd; 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 S235401AbjG1XAQ (ORCPT + 99 others); Fri, 28 Jul 2023 19:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231248AbjG1XAN (ORCPT ); Fri, 28 Jul 2023 19:00:13 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10E8544BD for ; Fri, 28 Jul 2023 16:00:07 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-760dff4b701so33306239f.0 for ; Fri, 28 Jul 2023 16:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1690585206; x=1691190006; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=MwUGAXlWTnPRJAd9ATS5GD+jmGk/Py4JKBUesXwXH2A=; b=d98DSZkdO+2JdfHRp58xcUD6LnqaYwJDvDZpaJyN70zZT2JY8lfcHfRFsUeJzKeUTr 0HwHHXR9frV3x3oDKHSvV0B3QxqOhanpLkl2q/ayOWCyt7ZeGYK0+RdS7LzDsZzISPDP BYu408eZ0VFLR+YSbXX8T/q0e3f+Kf4iKmGcQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690585206; x=1691190006; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MwUGAXlWTnPRJAd9ATS5GD+jmGk/Py4JKBUesXwXH2A=; b=BrLPjWcB5+CKuIkqQPGebs7/d40enz1p6u1qzJboyB6pstCb1NBW5oIWeSCn4/SvWB v4YAKIN+UEcEJUIA60FTGZOcB/Uk/l+OPk36hCUzWynusm8sToFnsBmxQ3LsecVtJX8k ddb7CzrhCb1BYK1Jpyw3n4MB3XpwKhLfJtMKzLj9a/pN/V7H6P0Bj7H4GrZSPr2pVBxu AIJy3qrzBQQTxUlr2wlP3LvMGfNS1nqwNvpW+0Uh6lvEG1rJ5K8KJaq+c3G2053C4/LV NfiFL3nXSuk19TihIriKffNdX4BCSlRbt+yHZ1IE3p9TipRm+jkTBg2ES+SOANCDdOdr dVvw== X-Gm-Message-State: ABy/qLZNgBXI+YH8WjZ5KntnffBmmgpeRJDuL4fchP4DMYNhvpjOIrXj Kjpt3Z4xX8xUHH6Es7unk4JEFQ== X-Received: by 2002:a92:cd05:0:b0:345:e438:7381 with SMTP id z5-20020a92cd05000000b00345e4387381mr785191iln.2.1690585206252; Fri, 28 Jul 2023 16:00:06 -0700 (PDT) Received: from [192.168.1.128] ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id w12-20020a02cf8c000000b0042acf934cbasm1346038jar.72.2023.07.28.16.00.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jul 2023 16:00:05 -0700 (PDT) Message-ID: <8c92599f-fcb4-3aba-f367-17abd9b52451@linuxfoundation.org> Date: Fri, 28 Jul 2023 17:00:05 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH next 3/3] selftests:connector: Add root check and fix arg error paths to skip Content-Language: en-US To: Anjali Kulkarni Cc: Shuah Khan , Liam Howlett , "kuba@kernel.org" , "davem@davemloft.net" , "linux-kselftest@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Shuah Khan References: <2c0ac97f9c8e6bd46b60854c136099c0dd4a09f6.1690564372.git.skhan@linuxfoundation.org> <0CB227BA-69FD-447F-BE73-2482A6998F7E@oracle.com> <5b283f3b-f176-7f19-5db0-1332a94a44be@linuxfoundation.org> <16B47831-5F53-4BAF-B347-A1404D2ED264@oracle.com> <957be0e8-2bdf-80f4-92b7-3b9070c546b3@linuxfoundation.org> <3242346A-9B09-44F7-A062-8456F83372C7@oracle.com> <84048d13-9311-36f6-9eb4-8169952580d7@linuxfoundation.org> From: Shuah Khan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 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, URIBL_BLOCKED autolearn=ham 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 7/28/23 16:40, Anjali Kulkarni wrote: > > >> On Jul 28, 2023, at 3:25 PM, Shuah Khan wrote: >> >> On 7/28/23 15:59, Anjali Kulkarni wrote: >>>> On Jul 28, 2023, at 2:41 PM, Shuah Khan wrote: >>>> >>>> On 7/28/23 15:21, Anjali Kulkarni wrote: >>>>>> On Jul 28, 2023, at 12:44 PM, Shuah Khan wrote: >>>>>> >>>>>> On 7/28/23 13:06, Shuah Khan wrote: >>>>>>> On 7/28/23 12:10, Anjali Kulkarni wrote: >>>>>>>> >>>>>>>> >>>>>>>>> On Jul 28, 2023, at 10:29 AM, Shuah Khan wrote: >>>>>>>>> >>>>>>>>> proc_filter test requires root privileges. Add root privilege check >>>>>>>>> and skip the test. Also fix argument parsing paths to skip in their >>>>>>>>> error legs. >>>>>>>>> >>>>>>>>> Signed-off-by: Shuah Khan >>>>>>>>> --- >>>>>>>>> tools/testing/selftests/connector/proc_filter.c | 9 +++++++-- >>>>>>>>> 1 file changed, 7 insertions(+), 2 deletions(-) >>>>>>>>> >>>>>>>>> diff --git a/tools/testing/selftests/connector/proc_filter.c b/tools/testing/selftests/connector/proc_filter.c >>>>>>>>> index 4fe8c6763fd8..7b2081b98e5c 100644 >>>>>>>>> --- a/tools/testing/selftests/connector/proc_filter.c >>>>>>>>> +++ b/tools/testing/selftests/connector/proc_filter.c >>>>>>>>> @@ -248,7 +248,7 @@ int main(int argc, char *argv[]) >>>>>>>>> >>>>>>>>> if (argc > 2) { >>>>>>>>> printf("Expected 0(assume no-filter) or 1 argument(-f)\n"); >>>>>>>>> - exit(1); >>>>>>>>> + exit(KSFT_SKIP); >>>>>>>>> } >>>>>>>>> >>>>>>>>> if (argc == 2) { >>>>>>>>> @@ -256,10 +256,15 @@ int main(int argc, char *argv[]) >>>>>>>>> filter = 1; >>>>>>>>> } else { >>>>>>>>> printf("Valid option : -f (for filter feature)\n"); >>>>>>>>> - exit(1); >>>>>>>>> + exit(KSFT_SKIP); >>>>>>>>> } >>>>>>>>> } >>>>>>>>> >>>>>>>>> + if (geteuid()) { >>>>>>>>> + printf("Connector test requires root privileges.\n"); >>>>>>>>> + exit(KSFT_SKIP); >>>>>>>>> + } >>>>>>>>> + >>>>>>>> >>>>>>>> I am not sure why you have added this check? proc_filter does not need root privilege to run. >>>>>>>> >>>>>>> It failed for me when I ran it saying it requires root privileges. >>>>>>> I had to run it as root. >>>>>> >>>>>> The following is what I see when I run the test as non-root >>>>>> user: >>>>>> >>>>>> bind failed: Operation not permitted >>>>>> >>>>> Yes, that’s expected on a kernel which does not have the kernel patches submitted with this selftest installed on it. >>>>> So this check for root needs to be removed. >>>> >>>> I will send v2 for this patch without root check. I should have >>>> split the argument error paths and root check anyway. >>>> >>>> However, what is strange is if the test run by root, bind() doesn't fail. >>>> This doesn't make sense to me based on what you said about bind() fails >>>> if kernel doesn't support the new feature. >>>> >>> I didn’t say that - part of the changes introduced by the patches is to remove the root check and add some features on top of existing code. >> >> Okay. So what should happen if a root user runs this test on a kernel >> that doesn't have the kernel patches submitted with this selftest >> installed on it? >> > > It will default to the behavior previous to my changes - that is it will report all events as opposed to a subset of events (which is the new feature added by my change) > Okay. Sorry I am unable to follow this explanation. This test has just been added in commit 73a29531f45fed6423144057d7a844aae46dad9d Can you please look at the usage for this test: - What should happen when kernel without filtering is run as root or non-root - What should happen when kernel with filtering is run as root or non-root There seems to be difference in behavior of this test depending on user privileges. This should reflect in the message the user sees. This message "bind failed: Operation not permitted" doesn't tell user anything - add a better message. Also this needs to be a skip and not fail. I just sent v2 without the root check. thanks, -- Shuah