delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2024/10/17/12:39:26

DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 49HGdP7G539819
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=odND6PEy
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E0C23858414
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1729183163;
bh=YcTegr5bUx0ki7hvvfWLAYzRxN7W3phhiuYV6+11VMw=;
h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=odND6PEy2QP9G7DDzoWxlsdPj5fSD9EPYRL3FyF/H6GDbUQst+l99C8blBdyaEB3v
Z5jrEDljdo7JTHPyDC+tIcLKkcvAmOQNkwEx7Pp+a/VgDqUk5PsPL3KRxaIADQC2VE
2pXWBTSYsxlknRhs3OE24u19xkLorSUgi9XHXsig=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B236D3858D20
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B236D3858D20
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729183106; cv=none;
b=s9YLb3c8/wYSwJ1VLjeIzSzUFRfduMur2LW2Y2ygN3NdApVFuAfkW91ylxpBCIokf4OzBq4SZaF9uJ9YEX0l+Be4foMujoyTAbjy9ELgurCA4JKGoWAWicG5i5RVYloYUy4znr7SxEaa1OFUkrswA8lmAZE0e1DYzExIeJAXHbU=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1729183106; c=relaxed/simple;
bh=DVV3kNM2OMC7Rg9Xd7Z+n59I+bhioO52mfAoUjhrLog=;
h=Subject:To:From:Message-ID:Date:MIME-Version;
b=OVe3pCC9jUMTMmPLe3FGkHz5IiM8+OFT179K0v8jbbnRhvMSf1uGDr/Y5B12Sx9jmve1NXfe2gmX8Q3KkLcxuGRuEl3ekwc5UFf9fVtZvSGrmSljIHgRqCxoUl9C+Cs4qnqp1pV82E2mbO3caaZENhm4hzYC7v8HnybhYaNHwuo=
ARC-Authentication-Results: i=1; server2.sourceware.org
Subject: Re: cygwin 3.5.4-1: lockf() aborts on overlap and does not fail on
overflow
To: cygwin AT cygwin DOT com
References: <dd4111c1-d6fb-b1f5-b928-ad8d899af2c9 AT t-online DOT de>
<20241017221957 DOT 11825d50d0c73b6a8560f17e AT nifty DOT ne DOT jp>
Message-ID: <f3da920e-3b53-0739-9bd5-a689e80d169c@t-online.de>
Date: Thu, 17 Oct 2024 18:37:57 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
SeaMonkey/2.53.18.2
MIME-Version: 1.0
In-Reply-To: <20241017221957.11825d50d0c73b6a8560f17e@nifty.ne.jp>
X-TOI-EXPURGATEID: 150726::1729183077-867FA4D7-8FD4190F/0/0 CLEAN NORMAL
X-TOI-MSGID: 9629f64e-009b-4d9b-8b1f-5bc98aab43ea
X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, BODY_8BITS,
FREEMAIL_FROM, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE,
RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS,
TXREP autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Christian Franke via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Christian Franke <Christian DOT Franke AT t-online DOT de>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 49HGdP7G539819

Takashi Yano via Cygwin wrote:
> On Mon, 14 Oct 2024 15:36:02 +0200
> Christian Franke wrote:
>> Two possibly independent bugs found by 'stress-ng --lockf ...':
>>
>> 1) lockf() may abort the process with api_fatal() if the new range
>> partly overlaps with two ranges previously locked by the same process.
>>
>> 2) lockf() prints a warning on too many locks and returns success. It
>> should not print a warning and fail with ENOLCK instead.
>>
>> Testcase for both:
>>
>> $ uname -r
>> 3.5.4-1.x86_64
>>
>> $ cat locktest.c
>> #include <fcntl.h>
>> #include <stdio.h>
>> #include <unistd.h>
>>
>> static int lock_at(int fd, int off, int size)
>> {
>>     if (lseek(fd, off, SEEK_SET) < 0) {
>>       perror("lseek"); return -1;
>>     }
>>     printf("\rlock %d-%d\n", off, off + size - 1); fflush(stdout);
>>     if (lockf(fd, F_LOCK, size) < 0) {
>>       perror("lock"); return -1;
>>     }
>>     return 0;
>> }
>>
>> int main(int argc, char **argv)
>> {
>>     int fd = open("locktest.tmp", O_RDWR|O_CREAT, 0666);
>>     if (fd < 0) {
>>       perror("open"); return 1;
>>     }
>>
>>     if (argc == 1) {
>>       lock_at(fd, 0, 2);
>>       lock_at(fd, 2, 2);
>>       lock_at(fd, 1, 2);
>>     }
>>     else {
>>       for (int i = 0; i < 914; i++)
>>         if (lock_at(fd, i, 1))
>>           return 1;
>>     }
>>     printf("\rdone\n");
>>     return 0;
>> }
>>
>> $ gcc -o locktest locktest.c
>>
>> $ ./locktest
>> lock 0-1
>> lock 2-3
>> lock 1-2
>>        1 [main] locktest 44864 C:\cygwin64\tmp\locktest.exe: \
>>          *** fatal error - NtCreateEvent(lock): 0xC0000035\
>>          Hangup
>>
>> $ ./locktest loop
>> lock 0-0
>> lock 1-1
>> lock 2-2
>> lock 3-3
>> ...
>> lock 909-909
>> lock 910-910
>> lock 911-911
>>         0 [main] locktest 44865 inode_t::get_all_locks_list: \
>>           Warning, can't handle more than 910 locks per file.
>> lock 912-912
>>       727 [main] locktest 44865 inode_t::get_all_locks_list: \
>>           Warning, can't handle more than 910 locks per file.
>> lock 913-913
>>      1329 [main] locktest 44865 inode_t::get_all_locks_list: \
>>           Warning, can't handle more than 910 locks per file.
>> done
>>
>> There is possibly also an off-by-one error as the 912'th lockf() prints
>> the first warning.
> Thanks for the report.
> I looked into the problems, and considered how to fix them.
>
> Could you please try the experimental patch attached?


Works as expected with both 'locktest.exe' and 'stress-ng --lockf ...'.

-- 
Thanks,
Christian


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019