From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B47823858D38 for ; Sat, 3 Jun 2023 02:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B47823858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685758088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aYgVv9Oin57AlsnHWVwF6GAuaguaQbVJ5uP9NPY9GAc=; b=K5TjFJ0jWC6F8GYMInG6X966dDaXwBrv+WnEnZ7o3pHD93YKqHmox4JdN02ShKBhi+FqlA tSdZgtTNX8ek+Xat5wMqLH39MVoSCwBhVe4v3VfHqPtr1K+PAivVuohJ44X3zXIE3QkbFo a5vE/fqkyk2rCwPgyk0H7cjIWoAThRc= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-278-9TEdqaAPOVeS3kDsl4t5xQ-1; Fri, 02 Jun 2023 22:08:07 -0400 X-MC-Unique: 9TEdqaAPOVeS3kDsl4t5xQ-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-5693861875fso32148087b3.1 for ; Fri, 02 Jun 2023 19:08:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685758086; x=1688350086; h=content-transfer-encoding:in-reply-to:organization:from:references :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=aYgVv9Oin57AlsnHWVwF6GAuaguaQbVJ5uP9NPY9GAc=; b=AydKF1HnTvGPCGYz5hAbc8RKssgtsSDZTudmnUZhxgxpIqklXz6FWWIvHD/kdEjEMD fLt5oIGRKeO55IJ0uM8Z8aB4bvWQ6nOBCTpYvIonIb3SWD0vUGPpvlkZxu7+s/jKGQcP oqwcA2I1N1suOwB9qjZ4wwy/l8GkoC6R1cgLcYOmeYcOrUKHWOhKBq2Dr9RtjGwqdkJy mki6CuQfX6EIoxLR1WN4hbJ9LbckbQP8wMiXwypyc4ZrdYmV5L4V8mZl3rXYzDcrLR8F L1knjyFN6vb1SAe3qThG1jHDiuc6DVxtIOkWktKAH6qpQpyqukFlQup32f8JMj9i8B/c Iczg== X-Gm-Message-State: AC+VfDz4S634HQry49VIwqAV9pNK9ET72BYddz2eNMHkpaVtDfQqkonH Qql8P75i8DDp7aNSdl9CIBc3785f6eZthdjUwR37yLOgeEBWWz8H1Ui4XqweRKHfqQHXjaQjkzY iec/uZsha5kJz4NmZu4M9 X-Received: by 2002:a81:8785:0:b0:559:ed0a:96c4 with SMTP id x127-20020a818785000000b00559ed0a96c4mr1703796ywf.44.1685758086655; Fri, 02 Jun 2023 19:08:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ65Rk2LVnv5V2K1Tp2Ftr+5zojpbTdllk4OFln5ZskiBViC6UWua+YJoJARyO2uDiNKRsjDMQ== X-Received: by 2002:a81:8785:0:b0:559:ed0a:96c4 with SMTP id x127-20020a818785000000b00559ed0a96c4mr1703785ywf.44.1685758086214; Fri, 02 Jun 2023 19:08:06 -0700 (PDT) Received: from [192.168.0.241] ([198.48.244.52]) by smtp.gmail.com with ESMTPSA id p4-20020a0de604000000b0055d6b67f468sm1052393ywe.14.2023.06.02.19.08.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Jun 2023 19:08:05 -0700 (PDT) Message-ID: <4e777d0e-d096-a536-c6d6-78b672c13901@redhat.com> Date: Fri, 2 Jun 2023 22:08:04 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] time: Also check for EPERM while trying to clock_settime To: Adhemerval Zanella , libc-alpha@sourceware.org References: <20230602170209.33275-1-adhemerval.zanella@linaro.org> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <20230602170209.33275-1-adhemerval.zanella@linaro.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 6/2/23 13:02, Adhemerval Zanella via Libc-alpha wrote: > Container management default seccomp filter [1] only accepts > clock_settime if process has also CAP_SYS_TIME. So also handle > EPERM as well. > > Also adapt the test to libsupport and add a proper Copyright header. > LGTM. Reviewed-by: Carlos O'Donell > Checked on aarch64-linux-gnu. > --- > time/tst-clock2.c | 59 ++++++++++++++++++++++++----------------------- > 1 file changed, 30 insertions(+), 29 deletions(-) > > diff --git a/time/tst-clock2.c b/time/tst-clock2.c > index 4c8fb9f247..9d1980e858 100644 > --- a/time/tst-clock2.c > +++ b/time/tst-clock2.c > @@ -1,43 +1,44 @@ > -/* Test setting the monotonic clock. */ > +/* Test setting the monotonic clock. > + Copyright (C) 2007-2023 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > > -#include > -#include > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > > -#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > > -# include > -# include > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include > +#include > +#include > +#include > > -static int > +int > do_test (void) > { > +#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK > if (sysconf (_SC_MONOTONIC_CLOCK) <= 0) > - return 0; > + FAIL_UNSUPPORTED ("_SC_MONOTONIC_CLOCK not supported"); > > struct timespec ts; > - if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0) > - { > - puts ("clock_gettime(CLOCK_MONOTONIC) failed"); > - return 1; > - } > + TEST_COMPARE (clock_gettime (CLOCK_MONOTONIC, &ts), 0); > > /* Setting the monotonic clock must fail. */ > - if (clock_settime (CLOCK_MONOTONIC, &ts) != -1) > - { > - puts ("clock_settime(CLOCK_MONOTONIC) did not fail"); > - return 1; > - } > - if (errno != EINVAL) > - { > - printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d\n", > - errno, EINVAL); > - return 1; > - } > - return 0; > -} > -# define TEST_FUNCTION do_test () > + TEST_VERIFY (clock_settime (CLOCK_MONOTONIC, &ts) == -1); > + TEST_VERIFY (errno == EINVAL || errno == EPERM); > > + return 0; > #else > -# define TEST_FUNCTION 0 > + return EXIT_UNSUPPORTED; > #endif > -#include "../test-skeleton.c" > +} > + > +#include -- Cheers, Carlos.