From nobody Mon Feb 06 22:19:38 2023 X-Original-To: dev-commits-src-main@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 4P9gfh50JKz3nVSZ; Mon, 6 Feb 2023 22:19:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P9gfh4NJBz4GSX; Mon, 6 Feb 2023 22:19:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675721980; 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: in-reply-to:in-reply-to:references:references; bh=YgRQBQXqOqq6M/YVsC+wBxQP8+CA9BM+OVHgaViv6/I=; b=W4vCiXodM3HO9CPU8fBbTDuHmuxEWcOGu40FQavRMLRhiCpGT4johFeU8Ui39AI5UsSDSH KIQjv9r8C7lEt9zm/RhD65d/AEIfl0hAMQKfJqsCdk7iAM1kK1HtLy1aS5H9YUnGJztsH/ +xt1YyadkLuHapR7Ew4cXgNUfNAemK31mNQ0MFHBL9YKfZyQRMp5SrMg3kQV6tWuZ5fnZg DpQycDmMCwiHqipy8jYUT9BKooma2fbZ0UemyAFHvQPuhgTL3idSfP0nD/B0DUJ2y5W8k1 LByflg/TqF4ONmSkDdEqqgCLDC9Qupcmd/Zc5c+DIMJGFFUU78mraNieh9KaWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675721980; 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: in-reply-to:in-reply-to:references:references; bh=YgRQBQXqOqq6M/YVsC+wBxQP8+CA9BM+OVHgaViv6/I=; b=SId1XrDOGCIaG93+ANNuK0Uui8djEdIowfk0FNYdnUCPqiMWQfDgTpwF2KwFTq2sScEbYH KfTo8GPeOiw6F4Nh3EqrgampoDlK4Pm0UI+xfW1jtJ3AlpmybVgxbplbmokDXzx+hAzGZF voEh3KjjQeyOtX8NZRFNS5bJ7R8UxYARqlUj/Ap0T9FpVavd1gzEJu6gkHYL/PbRCos9gz SK1DhyaIcy90O4hVfOsxC1aJE4jXNqiIfnqcKoeKcOS9+tdqDEE+3EpSW5wine1ZVAjX5i BRxcbK1/zcZ+jpOLDG/levGH8LaTMP+IBZgNuzEBgUJ3poDL9aEJeGmLI/LjQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675721980; a=rsa-sha256; cv=none; b=Hl4olq4tIEWXHrWIkWDJVEhtjw5bkHUrenntZQ6f7jhWCvkAsZMbrs08Y2IvhpSAXPlxwX XY1pVvvdQSb87pOGqAJK/ad7NiAnhC0rPT78WeHFS8ohO7Uj5/XFzRGB10lxza3LnjaWgs QtB8OFOuZnz1F2vcxaXtA+J6oB3msRCAmVxcE47o06wZO5XJ7Z7kujBIdboURYAnZDRUo+ exYWsmXQBLX7jXqBZ1eCasrFENTJz/ilz/U4rnBa76sveLksWWZJOuQMMGQj9M+gmCyvqH XhPo4tprnhMEAqu+zRH185ygv9zDI3m/nA+7P1ptpoHJT4NCb2pUPJq4r5GkmQ== Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4P9gfg6CBkz1RKP; Mon, 6 Feb 2023 22:19:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <3e74025f-eedf-7ca2-a5a0-b3971dfdfe30@FreeBSD.org> Date: Mon, 6 Feb 2023 14:19:38 -0800 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US To: "Bjoern A. Zeeb" , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202211281724.2ASHOxU9080511@gitrepo.freebsd.org> From: John Baldwin Subject: Re: git: 0fce2dc15730 - main - LinuxKPI,lindebugfs: add u8 base type and blob support In-Reply-To: <202211281724.2ASHOxU9080511@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ThisMailContainsUnwantedMimeParts: N On 11/28/22 9:24 AM, Bjoern A. Zeeb wrote: > The branch main has been updated by bz: > > URL: https://cgit.FreeBSD.org/src/commit/?id=0fce2dc1573019d0732f33fa7c26cc228655d3e8 > > commit 0fce2dc1573019d0732f33fa7c26cc228655d3e8 > Author: Bjoern A. Zeeb > AuthorDate: 2022-10-22 18:12:16 +0000 > Commit: Bjoern A. Zeeb > CommitDate: 2022-11-28 17:21:50 +0000 > > LinuxKPI,lindebugfs: add u8 base type and blob support > > Add debugfs_create_u8() based on other already present implementations. > Add a read-only implementation for debugfs_create_blob(). > > Both are needed for iwlwifi debugfs support. This passes kernel pointers to copyout because debugfs is kind of broken due to quirks in how linux file operations are implemented. > Sponsored by: The FreeBSD Foundation > MFC after: 3 days > OKed by: jfree (earlier version) > Differential Revision: https://reviews.freebsd.org/D37090 > --- > sys/compat/lindebugfs/lindebugfs.c | 66 ++++++++++++++++++++++ > sys/compat/linuxkpi/common/include/linux/debugfs.h | 11 +++- > 2 files changed, 76 insertions(+), 1 deletion(-) > > diff --git a/sys/compat/lindebugfs/lindebugfs.c b/sys/compat/lindebugfs/lindebugfs.c > index b88caf9c3140..b72ceb5e0be9 100644 > --- a/sys/compat/lindebugfs/lindebugfs.c > +++ b/sys/compat/lindebugfs/lindebugfs.c > @@ -394,6 +423,43 @@ debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent, unsi > &fops_ulong_ro, &fops_ulong_wo); > } > > + > +static ssize_t > +fops_blob_read(struct file *filp, char __user *ubuf, size_t read_size, loff_t *ppos) This is not actually a __user pointer. Note that simple_attr_read/write use plain pointers. The only invocations of this function are in debugfs_fill: rc = -ENODEV; if (uio->uio_rw == UIO_READ && d->dm_fops->read) { rc = -ENOMEM; buf = (char *) malloc(sb->s_size, M_DFSINT, M_ZERO | M_NOWAIT); if (buf != NULL) { rc = d->dm_fops->read(&lf, buf, sb->s_size, &off); if (rc > 0) sbuf_bcpy(sb, buf, strlen(buf)); free(buf, M_DFSINT); } } else if (uio->uio_rw == UIO_WRITE && d->dm_fops->write) { sbuf_finish(sb); rc = d->dm_fops->write(&lf, sbuf_data(sb), sbuf_len(sb), &off); } > +{ > + struct debugfs_blob_wrapper *blob; > + > + blob = filp->private_data; > + if (blob == NULL) > + return (-EINVAL); > + if (blob->size == 0 || blob->data == NULL) > + return (-EINVAL); > + > + return (simple_read_from_buffer(ubuf, read_size, ppos, blob->data, blob->size)); > +} This means you can't use simple_read_from_buffer() here as it is a wrapper around copyout. At least some architectures fail copyout calls where the user pointer is a kernel pointer (e.g. arm64 and RISC-V). I haven't looked if amd64 has the misfeature of letting it work. I'll have to fix this for CheriBSD downstream, but I'll try to post a review using an inlined version of simple_read_from_buffer that just uses memcpy directly. -- John Baldwin