From nobody Fri Jul 26 10:56:36 2024 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 4WVl785kGcz5RtW0; Fri, 26 Jul 2024 10:56:36 +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 4WVl781x1vz4Wf5; Fri, 26 Jul 2024 10:56:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721991396; 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=eaOrsFFwXxFR690+SBylRP+BKqia0Wg/FFmCHfEeToY=; b=xIw9BHiQQEh2c1ksiSeztL+RI45d2JWVct5WdgIV+ULAJoi60hhX4Qsv97CitExV/g4OV5 PqwkVPG+ug2deIxMigcvXi/iRlUbmuDbWUsE6epfR8AZlluY2YeYriEYWfaxkBbPqYF6hA 3DBixes1PXo+a4cw+OTB1Sk3DVHwGPdR/bjGq1zmeoVcvybep+zAhQh3Pz1FwwagrABs2K KD/r/8rRWQqwWMu0CAPVFVRmuUqbSjlbkwtR1WgBi6awPXEJCWAk3IoU6E2e2aPTwukL3W U51HUHQHHE8hHZVNYgXRMI6Az1ijiOOJwc1O9CQ0nxvQv2Vl1P3JbMSu5KPSIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721991396; a=rsa-sha256; cv=none; b=j/VDlwbZDyzFe/3kz1ilHHJX/BDdpH5EP9M/w7Ghc0xPdm8fjoIYD4wh7O0q+pKRbQ+bqb LwXXXgk0U1KxvffAmBJkxCgo2BWv57as94268ROXvnr1bBSpodT1vX2cJWVFZlNQR5TGxI onS4tb3aGOkI6t6sbKKfZTadM/WdjgIYHWayQBVrAagYgbglhpuO8mlHaQ7NSY3F0hZxk2 pBQOXyBgcfjvjJuF3cL8uYQw7UjbnfcH5AgNaUDib41+kkqQj2sajsIWCpkVa7laczKAQd t2bRJ1WTseqXdV6Jw9Qxl1ycoZQTw+8coxgVLlBXdu/WgZZbsIYIaZuwQvB6lQ== 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=1721991396; 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=eaOrsFFwXxFR690+SBylRP+BKqia0Wg/FFmCHfEeToY=; b=aHlySHlaHimzciiG0SSdL9tLkShG1rCJrq1iDpVayW60HhXDTJkJREXSX7tCPaoWMnQMU1 1BKH3hb/uSN8G3j+Yo7cugF+lTWli3uj1qoDRaKrMhE0loU7WASoGT2kZLaYZElKsqhrik ApOT3rNZM1SxhgJdo57Zle8rwDPSsFPjYZ7SpztKxa7hE0fZmv99nHqQgCSKqoZjcWzscD bvTZirXBJOJZYrFlB39QBLzYm3axqORqLDdyNbHKuIdgyCkYbmjW4KOym3Gx1Wz0Ae7RAf ILNOO8uAyNcjFk0frTp+fmWFlbv3PwRj3By/3/fb61yV4W4zlT2gXY9vT58s0g== 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 4WVl781NMgzKPH; Fri, 26 Jul 2024 10:56:36 +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 46QAuaNn001866; Fri, 26 Jul 2024 10:56:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46QAuanv001863; Fri, 26 Jul 2024 10:56:36 GMT (envelope-from git) Date: Fri, 26 Jul 2024 10:56:36 GMT Message-Id: <202407261056.46QAuanv001863@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 5668c22a13c6 - main - LinuxKPI/lindebugfs: stop panicing in lindebugfs, fix simple_read_from_buffer 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 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/main X-Git-Reftype: branch X-Git-Commit: 5668c22a13c6befa9b8486387d38457c40ce7af4 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=5668c22a13c6befa9b8486387d38457c40ce7af4 commit 5668c22a13c6befa9b8486387d38457c40ce7af4 Author: Bjoern A. Zeeb AuthorDate: 2024-06-27 12:19:38 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-07-26 10:53:55 +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 MFC after: 2 weeks Tested by: jfree Differential Revision: https://reviews.freebsd.org/D45755 --- 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 2cede0ef213f..d32de5d0657e 100644 --- a/sys/compat/lindebugfs/lindebugfs.c +++ b/sys/compat/lindebugfs/lindebugfs.c @@ -162,8 +162,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 9c763168b0f4..d277b717423f 100644 --- a/sys/compat/linuxkpi/common/include/linux/fs.h +++ b/sys/compat/linuxkpi/common/include/linux/fs.h @@ -353,9 +353,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; @@ -363,13 +362,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);