From nobody Sat Sep 28 10:38:14 2024 X-Original-To: dev-commits-src-branches@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 4XG3hR4Dvpz5X8Xw; Sat, 28 Sep 2024 10:38:15 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XG3hR1LCWz471k; Sat, 28 Sep 2024 10:38:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727519895; 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=POjrCKpRaOTuBayVNJ0CV3d2+gP9q1C6mun/HTCVUIM=; b=EU7U7XQXSvvg/IimxqhpZdH5v1/LU0u43+50aGHDcAj5cR8LtQHEg6Qvo1/BI9Pz3BPNCE Y52I9tI4hnPwPKuSfqHcN3YqTPiEacXbi5K+uZwZvmLwCr13ylV5t1NBjGZdFdKVCaEj/L 5zV7qJR0XlePI9Y51X/x+2v8zWnMJkS4J3DPA6v7dlRkrxUuO4iAKN5AeGHdA41X9PDFFW mv6HJK9ZLNIBwLaWLGn/HY4wIt5p6fBasz13bpLA44uNmbsdFGinnoRtIgId6AI3cmIJQT /O3Dyr6wHnA+PIPkgOi39p60PKr0VW8ivzUxj/SFDp+bwaTwKY3hJ87K7L3egg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727519895; 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=POjrCKpRaOTuBayVNJ0CV3d2+gP9q1C6mun/HTCVUIM=; b=J7vfKv708qtJTjzBbd3IjAAjZAyI2JxCO2TlEoEKBhl9J6qjTljPa3UcJKevwq83dt3EYw z0vGJmsf1m0xfDPRIHB/ZqE00bmemPr88aNzAJ7P6v3QnWPKvYCwEXId1DVpkCB0bUtslL sa9pzmyTx7dZaGKU7slrnZhuK86ETzJcpH3lGlsknfsvGO8qdb6SEVCpAz58TEkSNeaDuc Ncj/HE1CfIr4sRBeToPEe6QLt5hdswwkV9cLQJ+WC9Ug+kYOcuYeOWTLcR1uUbvuvc9D95 ksxNBsZPZu9IucWEgURxxtkSEoPKWKUZ1HW+BQ1iC+d/B47jzTXAYB/9iCyPhg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727519895; a=rsa-sha256; cv=none; b=hfjmPMuE8vOAwLSJkpS+ay02Rh7RoV3KHnWOAPqBUCsCWvgrEsAIviZDREh8Xw+ajUaPC/ +8Ma5VXpz0j8Xezij7c/bWuiGSJ4T8u33P2RHA9wVi6hkFdYbhiI2NEqgABhMQJsJO0GGW ZBfdJS47xg8bq91I3EcEpHHdpgPT/c5Gx/hNROcOkmDt1UsKeOQ/LeFoYtY21PO/81eefB ylRkw7iyT0SvF70pkA1yme5xiTCcI2Vz0Y/4OppKVl5DS0ZPzNkY8fFOGBp6PTIJ04BCxZ DM/Ti9001RGdv9DgkDhHSk1nKVA/u9qpofRccY7h4NOUIKRHrtj0Lru3a4AvgQ== 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 4XG3hR0g8SzLwb; Sat, 28 Sep 2024 10:38:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48SAcEC8097831; Sat, 28 Sep 2024 10:38:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48SAcE6N097828; Sat, 28 Sep 2024 10:38:14 GMT (envelope-from git) Date: Sat, 28 Sep 2024 10:38:14 GMT Message-Id: <202409281038.48SAcE6N097828@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: d506ab946dea - stable/14 - LinuxKPI/lindebugfs: stop panicing in lindebugfs, fix simple_read_from_buffer List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: d506ab946dea5f9692b9f3da5d7a20e9fd59b9ba Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=d506ab946dea5f9692b9f3da5d7a20e9fd59b9ba commit d506ab946dea5f9692b9f3da5d7a20e9fd59b9ba Author: Bjoern A. Zeeb AuthorDate: 2024-06-27 12:19:38 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-09-28 10:35:12 +0000 LinuxKPI/lindebugfs: stop panicing in lindebugfs, fix simple_read_from_buffer Trying to use lindebugfs for debugging wirless drivers two issues became apparent: (a) a panic in lindebugfs calling a hard coded release function if the caller had not provided one. This seems to be based on assumptions that no longer hold up. Remove the hard coded release function to prevent panics. (b) In LinuxKPI simple_read_from_buffer() would call copy_to_user() but buffers weren't setup for this (lindebugfs copies data from its own buffer) and then pseudofs will do another copyout to the user on this; remove the copy_to_user() and simply copy the data over to the provided buffer; this works for as long as the only consumers remain debugfs callers (which currently seems to be the case). [the only out-of-tree consumers I am aware off are two drm-kmod drivers/gpu/drm/amd/pm/* debugfs functions I cannot test]. Sponsored by: The FreeBSD Foundation Tested by: jfree Differential Revision: https://reviews.freebsd.org/D45755 (cherry picked from commit 5668c22a13c6befa9b8486387d38457c40ce7af4) --- sys/compat/lindebugfs/lindebugfs.c | 2 -- sys/compat/linuxkpi/common/include/linux/fs.h | 22 +++++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sys/compat/lindebugfs/lindebugfs.c b/sys/compat/lindebugfs/lindebugfs.c index c1678c0f3421..eab89d9d13a5 100644 --- a/sys/compat/lindebugfs/lindebugfs.c +++ b/sys/compat/lindebugfs/lindebugfs.c @@ -154,8 +154,6 @@ debugfs_fill(PFS_FILL_ARGS) if (d->dm_fops->release) d->dm_fops->release(&vn, &lf); - else - single_release(&vn, &lf); if (rc < 0) { #ifdef INVARIANTS diff --git a/sys/compat/linuxkpi/common/include/linux/fs.h b/sys/compat/linuxkpi/common/include/linux/fs.h index 74288f9cd461..3e7e71a0713c 100644 --- a/sys/compat/linuxkpi/common/include/linux/fs.h +++ b/sys/compat/linuxkpi/common/include/linux/fs.h @@ -354,9 +354,8 @@ static inline ssize_t simple_read_from_buffer(void __user *dest, size_t read_size, loff_t *ppos, void *orig, size_t buf_size) { - void *read_pos = ((char *) orig) + *ppos; + void *p, *read_pos = ((char *) orig) + *ppos; size_t buf_remain = buf_size - *ppos; - ssize_t num_read; if (buf_remain < 0 || buf_remain > buf_size) return -EINVAL; @@ -364,13 +363,18 @@ simple_read_from_buffer(void __user *dest, size_t read_size, loff_t *ppos, if (read_size > buf_remain) read_size = buf_remain; - /* copy_to_user returns number of bytes NOT read */ - num_read = read_size - copy_to_user(dest, read_pos, read_size); - if (num_read == 0) - return -EFAULT; - *ppos += num_read; - - return (num_read); + /* + * XXX At time of commit only debugfs consumers could be + * identified. If others will use this function we may + * have to revise this: normally we would call copy_to_user() + * here but lindebugfs will return the result and the + * copyout is done elsewhere for us. + */ + p = memcpy(dest, read_pos, read_size); + if (p != NULL) + *ppos += read_size; + + return (read_size); } MALLOC_DECLARE(M_LSATTR);