From nobody Tue Feb 14 08:45:28 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PGFCX6k3nz3rQk6; Tue, 14 Feb 2023 08:45:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PGFCX6DQVz3K7m; Tue, 14 Feb 2023 08:45:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676364328; 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; bh=7DvzWf02z2h1sCQ9goDklyMfoucqG/Xvg2r45IVmbTs=; b=jqaFrkKA5jlgjWjRNqY+Rx3u6rwZa4kDr82ic20X7r7xDdkktt9UuwZrGP1x8rhdGZ90Sd Diwy0+JPh/C7r/qa0CId95/1oAc22B+lgCGEFMRKyV/OAAvEg0hrBuFOQJg0RajOCMPQiR 6Dy4xlNiPZqh8BYRsM/c9LlCNIcx3VXyOnQPrl+050NUD52/U5rw4n5hxANV7DpmnhbY6Q 8KB6rAL2lDalEu/bxtEGduBAxlg7fUPG6DhZKGtcl3RwvxmO+2q/TAkB3bV2yG7XV60MsG A69vmn04Vgh6nCO9Sd0++wSg71Eoq3pXHxbfmO1AAYf6tMnGsbeM1DjiLQkNsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676364328; 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; bh=7DvzWf02z2h1sCQ9goDklyMfoucqG/Xvg2r45IVmbTs=; b=N19z+SLNIfjIT0rlxoNFElCG0IpvrNsTQZ6oi1W42ApnQ0DxGUtmV7grVcIBmGSd6P6hhZ +0T7OWuNkcQtxDkgMREnjWNoJrE0W5lTOopjqsbkUzAYD4WBV3ztfYNgALZ0hwZjWkRVG5 g64NXU24OmPrAumQEUd+bH6eEPwMhUhX6mF0TlizD7XpR1F3JqkqOPMZH7evj5GsLahKaT r77JQEov2/P2t9SbxyNZQBNQOK+2ZFzE5s2cQHFzxE4MWFGEeR6Lw9ffEssvzGIUz792mS U+XUL1pT0tW8Nx9jjTGfQzIdfv4bwSL1ahpbYXQcBenVB0KtPWGlXm83kZKIow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676364328; a=rsa-sha256; cv=none; b=yGzabuAPJkF7LDbDxkHYdUrrHXVYos8EyHMvtvW0NaWN8QKJ4oSMB+QT1Hx4SDtXvkJgB7 mVZCG0lbGRso3paphjAex7GXMwO5ycVCrsCCef+Y0YP3VEirhqJL9FB8mWX9jEUyCHzuZ8 ZzWKvDB+aB8Z0vsZXvqNTCU/IKcVWddDFJNkj1m38T2OHkDVEWrxhMT8HX7fYlqrFPsIp0 s31fWkrtvZVvpL+ZXMuH09T66UcjDolMdRn7BI8CCpfNqv8cun0G5qPbo0H7rV8CwX9eIZ 6WZOsEQCatWE3yP3chPwvrdC66Hmwshp95F1U9gfslFNA+D6ePK3XzpLSofLRg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PGFCX5Gfgzsc6; Tue, 14 Feb 2023 08:45:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31E8jSSL057363; Tue, 14 Feb 2023 08:45:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31E8jSsw057362; Tue, 14 Feb 2023 08:45:28 GMT (envelope-from git) Date: Tue, 14 Feb 2023 08:45:28 GMT Message-Id: <202302140845.31E8jSsw057362@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 3f1f48f1d95a - main - stress2: Add a regression test for D38549 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3f1f48f1d95a4923a557e34acc047a3ef8630532 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=3f1f48f1d95a4923a557e34acc047a3ef8630532 commit 3f1f48f1d95a4923a557e34acc047a3ef8630532 Author: Peter Holm AuthorDate: 2023-02-14 08:44:58 +0000 Commit: Peter Holm CommitDate: 2023-02-14 08:44:58 +0000 stress2: Add a regression test for D38549 --- tools/test/stress2/misc/msdos18.sh | 250 +++++++++++++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) diff --git a/tools/test/stress2/misc/msdos18.sh b/tools/test/stress2/misc/msdos18.sh new file mode 100755 index 000000000000..faeed9dca944 --- /dev/null +++ b/tools/test/stress2/misc/msdos18.sh @@ -0,0 +1,250 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2023 Peter Holm +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# D38549: msdosfs deextend: validate pages of the partial buffer + +# https://people.freebsd.org/~pho/stress/log/log0420.txt + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +set -eu +prog=$(basename "$0" .sh) +mkdir -p $mntpoint +mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 1g -u $mdstart +newfs_msdos /dev/md$mdstart > /dev/null 2>&1 +mount -t msdosfs /dev/md$mdstart $mntpoint +mount | grep $mntpoint +set +e + +odir=`pwd` + +cd /tmp +sed '1,/^EOF/d' < $odir/$0 > $prog.c +cc -o $prog -Wall -O0 $prog.c -pthread || exit 1 +rm -f $prog.c +cd $mntpoint + +in=inputFile +out=outputFile + +/tmp/$prog $in $out 12345 +ls -al + +cd $odir +umount $mntpoint +mdconfig -d -u $mdstart +rm -f /tmp/$prog +exit +EOF +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int fd, port; +volatile int go; +char *inputFile; +char *outputFile; + +#define FSIZE 936374 +char buf[FSIZE]; + +static void +reader(void) { + struct sockaddr_in inetaddr, inetpeer; + socklen_t len; + int on, n, tcpsock, msgsock; + + on = 1; + if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) + err(1, "socket(), %s:%d", __FILE__, __LINE__); + + if (setsockopt(tcpsock, + SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) + err(1, "setsockopt(), %s:%d", __FILE__, __LINE__); + + inetaddr.sin_family = AF_INET; + inetaddr.sin_addr.s_addr = INADDR_ANY; + inetaddr.sin_port = htons(port); + inetaddr.sin_len = sizeof(inetaddr); + + if (bind(tcpsock, + (struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0) + err(1, "bind(), %s:%d", __FILE__, __LINE__); + + if (listen(tcpsock, 5) < 0) + err(1, "listen(), %s:%d", __FILE__, __LINE__); + + len = sizeof(inetpeer); + if ((msgsock = accept(tcpsock, + (struct sockaddr *)&inetpeer, &len)) < 0) + err(1, "accept(), %s:%d", __FILE__, __LINE__); + + if ((fd = open(outputFile, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1) + err(1, "open(%s)", outputFile); + + usleep(arc4random() % 1000); + for (;;) { + if ((n = read(msgsock, buf, FSIZE)) < 0) + err(1, "read(), %s:%d", __FILE__, __LINE__); + if (n == 0) + break; + + } + close(msgsock); + close(tcpsock); + close(fd); + return; +} + +static void * +thr(void *data __unused) +{ + pthread_set_name_np(pthread_self(), __func__); + go = 1; + while (go == 1) { + ftruncate(fd, FSIZE / 2); + ftruncate(fd, FSIZE); + } + + return (NULL); +} + +static void +writer(void) { + struct hostent *hostent; + struct sockaddr_in inetaddr; + pthread_t tid; + off_t off = 0; + size_t size; + int i, on, r, tcpsock; + + on = 1; + for (i = 1; i < 5; i++) { + if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) + err(1, "socket(), %s:%d", __FILE__, __LINE__); + + if (setsockopt(tcpsock, + SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) + err(1, "setsockopt(), %s:%d", __FILE__, __LINE__); + + size = getpagesize(); + if (setsockopt(tcpsock, SOL_SOCKET, SO_SNDBUF, (void *)&size, + sizeof(size)) < 0) + err(1, "setsockopt(SO_SNDBUF), %s:%d", + __FILE__, __LINE__); + + hostent = gethostbyname ("localhost"); + memcpy (&inetaddr.sin_addr.s_addr, hostent->h_addr, + sizeof (struct in_addr)); + + inetaddr.sin_family = AF_INET; + inetaddr.sin_port = htons(port); + inetaddr.sin_len = sizeof(inetaddr); + + r = connect(tcpsock, (struct sockaddr *) &inetaddr, + sizeof(inetaddr)); + if (r == 0) + break; + sleep(1); + close(tcpsock); + } + if (r < 0) + err(1, "connect(), %s:%d", __FILE__, __LINE__); + + if ((fd = open(inputFile, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1) + err(1, "open(%s)", inputFile); + + if (write(fd, buf, sizeof(buf)) != sizeof(buf)) + err(1, "write()"); + + r = pthread_create(&tid, NULL, thr, NULL); + if (r) + errc(1, r, "pthread_create"); + + usleep(5000); + if (sendfile(fd, tcpsock, 0, FSIZE, NULL, &off, 0) == -1) + err(1, "sendfile"); + + usleep(arc4random() % 20000); + go = 0; + if ((r = pthread_join(tid, NULL)) != 0) + errc(1, r, "pthread_join"); + + _exit(0); +} + +int +main(int argc, char **argv) +{ + pid_t pid; + time_t start; + + if (argc != 4) { + fprintf(stderr, "Usage: %s 0) { + reader(); + kill(pid, SIGINT); + if (waitpid(pid, NULL, 0) != pid) + err(1, "waitpid()"); + } else + err(1, "fork(), %s:%d", __FILE__, __LINE__); + } + + return (0); +}