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

DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 49HM9B4D642914
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=i5b/p0Ed
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C9FB3858283
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1729202949;
bh=HmELzPJXEoRAYY53hKF1En4pkLAB5kxjTIucehF+uco=;
h=Date:To:Cc:Subject:In-Reply-To:References:List-Id:
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
From:Reply-To:From;
b=i5b/p0EdhXak6NhVuZC4SP75HX17zEt3r36TmB4J5eBr+W87sMKL699oKPsCwIUxb
1SJvQb8UKg9qweQPLYXwNOT98RrFRKVxYHiEI9GErM+UJ7YrITdZ3ufE+z0tHAeoTh
onFIQcKl31diglBJasTE4Ss3UZK0JWbxiAN96XWw=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 585583858D20
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 585583858D20
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729202896; cv=none;
b=OcEcOSvMKZkC6hnWQM2PLGZSlIIaNkwGyMmCwdfSu+fUq2eF/2ldDdjL/dpmQtWEWOAKiJphw5npshwgkxsIEGIri2SSA4oJCTGJgAdhrbfUmpj5Ksc3UBKxPhDmFaCK02BCiaTgxhocKavzJ9lRyhPfW7kVcmPScegnt4T9Gnw=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1729202896; c=relaxed/simple;
bh=+3UlPRBkSabmNE7SNJ6niFzI5wPJn5pisnbqVCQ8DFo=;
h=Date:From:To:Subject:Message-Id:Mime-Version;
b=HUyanclEHt8tYJP7vmroqQryihRIUHYBfhKh/phKZ7RFcV+TfekIbLLZRKdzjGPxSUXB6lfmVR+Il9/DiyATsWv1JiwpizsHlGg5Jq/becJNFhbgU93FjWNnGfd47W5nfNQtiuA0+8AK8dTYyfHe3fIkCcucZ3N5ppK2AN4/TPk=
ARC-Authentication-Results: i=1; server2.sourceware.org
Date: Fri, 18 Oct 2024 07:08:06 +0900
To: cygwin AT cygwin DOT com
Cc: Christian Franke <Christian DOT Franke AT t-online DOT de>
Subject: Re: cygwin 3.5.4-1: lockf() aborts on overlap and does not fail on
overflow
Message-Id: <20241018070806.78b5978a73ca35b5f7afeef7@tyan0.yr32.net>
In-Reply-To: <f3da920e-3b53-0739-9bd5-a689e80d169c@t-online.de>
References: <dd4111c1-d6fb-b1f5-b928-ad8d899af2c9 AT t-online DOT de>
<20241017221957 DOT 11825d50d0c73b6a8560f17e AT nifty DOT ne DOT jp>
<f3da920e-3b53-0739-9bd5-a689e80d169c AT t-online DOT de>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, BODY_8BITS,
KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_NONE,
SPF_HELO_PASS, SPF_NONE, 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: Takashi Yano via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Takashi Yano <yano AT tyan0 DOT yr32 DOT net>
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 49HM9B4D642914

On Thu, 17 Oct 2024 18:37:57 +0200
Christian Franke wrote:
> 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 for testing!

-- 
Takashi Yano <yano AT tyan0 DOT yr32 DOT net>

-- 
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