From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 569FC3853805 for ; Tue, 22 Jun 2021 19:50:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 569FC3853805 Received: by mail-qk1-x729.google.com with SMTP id o6so7286903qkh.4 for ; Tue, 22 Jun 2021 12:50:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=Y3jUIconV+Flezsm7N4F+hojDHQYzUJsX162tH13REk=; b=JyUHtYDRPUrloX/JZqwxAIMnOubJ887InYLEpLO7Jz5p0PAu6AObVBMbK6qa8HKkd/ d0pp8zPILpmPoAK9RdlV2G+x+1T575gbL2HDuTu3Ke9IyG/zoKpF++t9tl0qvjTGRw8n YUersuHQc5a3Cc+g0t76piO0KRgWPIBXMggVRuTAU+/x3Kh4RxM3wR1fBYnMkMm6w5mi Xr7ofCVbIcwI3yJ5TaCevGWUmOORD/HQos5u6iopNL6YPrFKaowV8Pu/dJbCjBmFjRvO QRNg9Js8MkV4xzIxkdnOcTJKXQUXiE82pv7aT8NnXx4I+hfr3hhuCRQ7r31nVuWMKCXL KW/g== X-Gm-Message-State: AOAM533XFSo/BZwXq1hm0yFHmzUUZ1zAaAJLK2PS9Cq7Wxf9yMXNO2rT g4+DXHFraNOXlWQKAtdP5kTprD467NmTQw== X-Google-Smtp-Source: ABdhPJxaxUdnhx4rBYdYyxTmHrbTvEAdDe3q9GSkkcVTH2hlEjiHyREu5o8QPcxei7fkBVZnRM3fjg== X-Received: by 2002:a05:620a:539:: with SMTP id h25mr6290060qkh.284.1624391411790; Tue, 22 Jun 2021 12:50:11 -0700 (PDT) Received: from [192.168.1.108] ([177.194.59.218]) by smtp.gmail.com with ESMTPSA id g1sm13530004qkd.125.2021.06.22.12.50.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Jun 2021 12:50:11 -0700 (PDT) Subject: Re: [PATCH] nptl: Use SA_RESTART for SIGCANCEL handler To: Florian Weimer Cc: Adhemerval Zanella via Libc-alpha References: <20210617125241.1415287-1-adhemerval.zanella@linaro.org> <878s37qu6l.fsf@oldenburg.str.redhat.com> <0ed7e3e6-845b-0609-db0e-82f9898874dc@linaro.org> <87bl7xbvgs.fsf@oldenburg.str.redhat.com> <8c620913-8cbe-b0ee-d232-f8c7a58263dd@linaro.org> <877dilbul6.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Message-ID: Date: Tue, 22 Jun 2021 16:50:09 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <877dilbul6.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jun 2021 19:50:15 -0000 On 22/06/2021 15:52, Florian Weimer wrote: > * Adhemerval Zanella: > >> On 22/06/2021 15:33, Florian Weimer wrote: >>> * Adhemerval Zanella: >>> >>>> On 18/06/2021 08:38, Florian Weimer wrote: >>>>> * Adhemerval Zanella via Libc-alpha: >>>>> >>>>>> The usage of signals to implementation pthread cancellation is an >>>>>> implementation detail and should not be visible through cancellation >>>>>> entrypoints. >>>>>> >>>>>> However now that pthread_cancel always send the SIGCANCEL, some >>>>>> entrypoint might be interruptable and return EINTR to the caller >>>>>> (for instance on sem_wait). >>>>>> >>>>>> Using SA_RESTART hides this, since the cancellation handler should >>>>>> either act uppon cancellation (if asynchronous cancellation is enable) >>>>>> or ignore the cancellation internal signal. >>>>> >>>>> I think this still needs a NEWS entry because there have been kernel >>>>> bugs in this area (e.g. in CIFS). >>>> >>>> Ok, I have added the following on "Deprecated and removed features, and >>>> other changes affecting compatibility" >>>> >>>> * The pthread cancellation handler is now setup with SA_RESTART. It should >>>> not be visible to application since the cancellation handler should either >>>> act uppon cancellation (if asynchronous cancellation is enabled) or >>>> ignore the cancellation internal signal. >>> >>> The key change is: The cancellation signal is now sent in more cases, >>> but this should be transparent to the application due to SA_RESTART. >> >> I am not sure if we really need to describe this implementation detail >> on a NEWS entry. > > It's the cause of additional EINTR errors. People who have that buggy > CIFS module and use thread cancellation could see those spurious EINTR > errors. Right, without mentioning EINTR it is probably not useful. 8-/ What about: * The pthread cancellation handler is now installed with SA_RESTART and pthread_cancel will always send the internal SIGCANCEL on a cancellation request. It should not be visible to application since the cancellation handler should either act upon cancellation (if asynchronous cancellation is enabled) or ignore the cancellation internal signal. However there is buggy kernel interfaces (for instance some CIFS modules) that could still see spurious EINTR error when cancellation interrupts a blocking syscall.