From nobody Wed Jul 8 22:57:21 2026 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 4gwYQC5NDWz6l22m; Wed, 08 Jul 2026 22:57:23 +0000 (UTC) (envelope-from markj@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gwYQC3ZX8z3YxC; Wed, 08 Jul 2026 22:57:23 +0000 (UTC) (envelope-from markj@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783551443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Av7XphwkYokmQd7WrxY0gJD9zY/Kt8hnVqZECFxHcDU=; b=OzT6kmvfAgysUHNPoAX7HxujEoQyLTDHa5l7jn8Fgxzrez7DqSh5qREgJhAcKYjbcmvR4L OwJsMpMeMVFmzB1N/EhySWbn2FABwc2shFE99nI3Jy2jKnZlWTGclfkIqGAFvVCzv/igZ5 L/eiyiDro7GV5b03cg8daU2oHAkfyKtjwrAXPLQmQUB/c5BJ9fA7KSal6rzP2QkdGXFEAS 87F5tJUuJ4iu0UnFVP1wstnlWbinXOzNcbHGnuYW87tFZzLflZpa6dL8UGG1j4vLAI9vUB VPZQWAWqmXZaf4M6t/NvoLDDOl9uruUmqFHXDMMj/1AVeYGX9/ViKDIn5aaKYg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783551443; a=rsa-sha256; cv=none; b=va9+1RzMOqEJ/GGvndDizhbrkvbeWBeSZnollv53g79zE/DHnNpSecQLeVNVyMPjcYuF5e 9ozttU+7By9I0Rvv3mI4CBQmiR780s56mWa5Oqs8VqLxV9GpToT8UYyJB3KzXAqew5aTpG mz4YS6squOYCW03WR3gLEZghetFM4V2XPny+sE7GV4tKbcZDgTpRMBQo6uDi4oKqnv4lcT Ow12gmBsTXTG7BHtduQcnhYuaOLdBUMTtCKsdkNtDVPWosaPVj6hjxunwsSwuvamLRxAWw u5nr+UGNWAwyit7uHiyrgj5RP7EJDNspS63SyXBCkWWMNAECVkNGDueEJuU6ZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783551443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Av7XphwkYokmQd7WrxY0gJD9zY/Kt8hnVqZECFxHcDU=; b=QCJ7ZfWREZnMTilHJSUS04FZ9a5qWW6YSaVQlmIyxeW/nOcM1cXjFT9xI4L094etmMM6v6 H+W8IzROScuIokIGjfGCVxel/sqFN5OwRTsPy6vcouBxjbePLDo5tAd1XqY8vOz2niM3C5 7Zm/14RSy4oYVnkztk92UpWUQ1y7r6XGJ6G1GK6DmaAC213Jgx7qZiykxl3OrL2u7RcxPs 9RC8+LKqzWSeSfB9LNvuQW6FvTro5DbfqVX/gcMD1lMCtNwpOj3eMU8v6GyBzZfSo4vuB/ cLitHhutlZ5qIMzjY9sJc//wezvWSUALInIb0CXEUAto16IswGZjQCh27HZWeg== Received: from nuc (192-0-220-237.cpe.teksavvy.com [192.0.220.237]) (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) (Authenticated sender: markj) by smtp.freebsd.org (Postfix) with ESMTPSA id 4gwYQC0tQ8z14Tt; Wed, 08 Jul 2026 22:57:23 +0000 (UTC) (envelope-from markj@freebsd.org) Date: Wed, 8 Jul 2026 18:57:21 -0400 From: Mark Johnston To: Konstantin Belousov Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: dfad790c8cca - main - sendfile: stop abusing kern_writev() Message-ID: References: <6a4d73f7.1e7dd.1cbcbd60@gitrepo.freebsd.org> 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jul 08, 2026 at 11:23:27PM +0300, Konstantin Belousov wrote: > On Wed, Jul 08, 2026 at 03:36:44PM -0400, Mark Johnston wrote: > > On Wed, Jul 08, 2026 at 10:23:06PM +0300, Konstantin Belousov wrote: > > > On Wed, Jul 08, 2026 at 02:59:47PM -0400, Mark Johnston wrote: > > > > On Tue, Jul 07, 2026 at 09:47:35PM +0000, Konstantin Belousov wrote: > > > > > if (error != 0) > > > > > goto out; > > > > > + if (trl_uio->uio_rw != UIO_WRITE) { > > > > > > > > cloneuio() does not set uio_rw. sendfile() was relying on kern_writev() > > > > to do that. A GENERIC-KMSAN kernel panics when running the test suite: > > > > > > > > panic: MSan: Uninitialized malloc memory from copyinuio+0x11d > > > > cpuid = 5 > > > > time = 1783537112 > > > > KDB: stack backtrace: > > > > db_trace_self_wrapper() at db_trace_self_wrapper+0xa7/frame 0xfffffe00764d7840 > > > > vpanic() at vpanic+0x538/frame 0xfffffe00764d79c0 > > > > panic() at panic+0x1dd/frame 0xfffffe00764d7ad0 > > > > __msan_warning() at __msan_warning+0x25d/frame 0xfffffe00764d7c20 > > > > sendfile() at sendfile+0xcb6/frame 0xfffffe00764d7d50 > > > > amd64_syscall() at amd64_syscall+0x837/frame 0xfffffe00764d7f30 > > > > fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe00764d7f30 > > > > --- syscall (393, FreeBSD ELF64, sendfile), rip = 0x21aad2ea3b0a, rsp = 0x21aad1d706c8, rbp = 0x21aad1d70760 --- > > > > KDB: enter: panic > > > > > > The following should be enough, am I correct? > > > > I am re-running the test suite to see. > > > > I am also not sure about the offset. dofilewrite() sets > > auio->uio_offset = offset. kern_filewrite() takes an offset parameter > > and does nothing with it. > > > > copyinuio() initializes it to -1, so KMSAN will not report a problem, > > but it looks wrong to me. > > The streaming sockets are kind of append-only, so uio_offset should > be irrelevant for them. But indeed kern_filewrite() should not take > explicit offset, it was a mistake to keep the argument after the split. > > commit 605bd06dd7fca162967ce0f99bcbd31d982b1a37 > Author: Konstantin Belousov > Date: Wed Jul 8 23:21:26 2026 +0300 > > kern_filewrite(): remove unused argument offset > > Noted by: markj > Fixes: dfad790c8cca ("sendfile: stop abusing kern_writev()") > Seems ok. I am surprised the compiler didn't catch this. It seems we need to explicitly pass -Wunused-parameter, and if I do this there are many places that need to be patched. There is another bug, the comparison `auio->uio_resid != cnt` in dofilewrite() is no longer correct. It needs to be `cnt != 0`.