From: Max Vozeler <max@hinterhof.net>
To: Maximilian Eschenbacher <maximilian@eschenbacher.email>
Cc: linux-kernel@vger.kernel.org, valentina.manea.m@gmail.com,
shuah.kh@samsung.com, gregkh@linuxfoundation.org,
Dominik Paulus <dominik.paulus@fau.de>,
Fjodor Schelichow <fjodor.schelichow@hotmail.com>,
Johannes Stadlinger <johannes.stadlinger@fau.de>,
Kurt Kanzenbach <ly80toro@cip.cs.fau.de>,
Tobias Polzer <tobias.polzer@fau.de>
Subject: Re: [PATCH 03/18] usbip: Add kernel support for client ACLs
Date: Sun, 21 Sep 2014 02:44:33 +0200 [thread overview]
Message-ID: <20140921004433.GA12922@x201t.vpn.hinterhof.net> (raw)
In-Reply-To: <1410910735-27929-4-git-send-email-maximilian@eschenbacher.email>
Hi,
On Tue, Sep 16, 2014 at 11:38:40PM +0000, Maximilian Eschenbacher wrote:
> From: Dominik Paulus <dominik.paulus@fau.de>
>
> This patch adds the possibility to stored ACLs for allowed clients for
> each stub device in sysfs. It adds a new sysfs entry called "usbip_acl"
> for each stub device, containing a list of CIDR masks of allowed
> clients. This file will be used by usbip and usbipd to store the ACL.
Is there a need to involve the kernel here, couldn't usbip and usbipd
apply the ACLs during connection setup in userspace?
> Signed-off-by: Maximilian Eschenbacher <maximilian@eschenbacher.email>
> Signed-off-by: Fjodor Schelichow <fjodor.schelichow@hotmail.com>
> Signed-off-by: Johannes Stadlinger <johannes.stadlinger@fau.de>
> Signed-off-by: Kurt Kanzenbach <ly80toro@cip.cs.fau.de>
> Signed-off-by: Dominik Paulus <dominik.paulus@fau.de>
> Signed-off-by: Tobias Polzer <tobias.polzer@fau.de>
> ---
> drivers/usb/usbip/stub.h | 5 ++++
> drivers/usb/usbip/stub_dev.c | 60 +++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 64 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/usbip/stub.h b/drivers/usb/usbip/stub.h
> index 266e2b0..b2d3d55 100644
> --- a/drivers/usb/usbip/stub.h
> +++ b/drivers/usb/usbip/stub.h
> @@ -60,6 +60,11 @@ struct stub_device {
> struct list_head unlink_free;
>
> wait_queue_head_t tx_waitq;
> +
> + /* list of allowed IP addrs */
> + char *acls;
> + /* for locking list operations */
> + spinlock_t ip_lock;
Perhaps name this 'acl_lock' to make more obvious what it covers?
> };
>
> /* private data into urb->priv */
> diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
> index fac20e0..e6624f1 100644
> --- a/drivers/usb/usbip/stub_dev.c
> +++ b/drivers/usb/usbip/stub_dev.c
> @@ -119,6 +119,55 @@ err:
> }
> static DEVICE_ATTR(usbip_sockfd, S_IWUSR, NULL, store_sockfd);
>
> +/*
> + * This function replaces the current ACL list
> + */
> +static ssize_t store_acl(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct stub_device *sdev = dev_get_drvdata(dev);
> + int retval;
> +
> + if (count >= PAGE_SIZE)
> + return -EINVAL;
> +
> + spin_lock_irq(&sdev->ip_lock);
> + kfree(sdev->acls);
> + sdev->acls = kstrdup(buf, GFP_KERNEL);
> + if (!sdev->acls)
> + retval = -ENOMEM;
> + else
> + retval = strlen(sdev->acls);
> + spin_unlock_irq(&sdev->ip_lock);
> +
> + return retval;
> +}
> +
> +/*
> + * This functions prints all allowed IP addrs for this dev
> + */
> +static ssize_t show_acl(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + struct stub_device *sdev = dev_get_drvdata(dev);
> + int retval = 0;
> +
> + if (!sdev)
> + return -ENODEV;
> +
> + spin_lock_irq(&sdev->ip_lock);
> + if (sdev->acls == NULL) {
> + retval = 0;
> + } else {
> + strcpy(buf, sdev->acls);
> + retval = strlen(buf);
> + }
> + spin_unlock_irq(&sdev->ip_lock);
> +
> + return retval;
> +}
> +static DEVICE_ATTR(usbip_acl, S_IWUSR | S_IRUGO, show_acl, store_acl);
> +
> static int stub_add_files(struct device *dev)
> {
> int err = 0;
> @@ -134,9 +183,13 @@ static int stub_add_files(struct device *dev)
> err = device_create_file(dev, &dev_attr_usbip_debug);
> if (err)
> goto err_debug;
> + err = device_create_file(dev, &dev_attr_usbip_acl);
> + if (err)
> + goto err_ip;
>
> return 0;
> -
> +err_ip:
> + device_remove_file(dev, &dev_attr_usbip_debug);
> err_debug:
> device_remove_file(dev, &dev_attr_usbip_sockfd);
> err_sockfd:
> @@ -150,6 +203,7 @@ static void stub_remove_files(struct device *dev)
> device_remove_file(dev, &dev_attr_usbip_status);
> device_remove_file(dev, &dev_attr_usbip_sockfd);
> device_remove_file(dev, &dev_attr_usbip_debug);
> + device_remove_file(dev, &dev_attr_usbip_acl);
> }
>
> static void stub_shutdown_connection(struct usbip_device *ud)
> @@ -287,6 +341,7 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev)
> INIT_LIST_HEAD(&sdev->priv_free);
> INIT_LIST_HEAD(&sdev->unlink_free);
> INIT_LIST_HEAD(&sdev->unlink_tx);
> + spin_lock_init(&sdev->ip_lock);
> spin_lock_init(&sdev->priv_lock);
>
> init_waitqueue_head(&sdev->tx_waitq);
> @@ -453,6 +508,9 @@ static void stub_disconnect(struct usb_device *udev)
>
> usb_put_dev(sdev->udev);
>
> + /* free ACL list */
> + kfree(sdev->acls);
> +
> /* free sdev */
> busid_priv->sdev = NULL;
> stub_device_free(sdev);
Otherwise looks good to me.
Max
next prev parent reply other threads:[~2014-09-21 0:53 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 23:38 [PATCH 00/18] usbip: Crypto and ACLs Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 01/18] usbip: sysfs_utils: add read_sysfs_attribute Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 02/18] usbip: Add support for client authentication Maximilian Eschenbacher
2014-09-21 0:42 ` Max Vozeler
2014-09-21 12:43 ` Dominik Paulus
2014-10-03 14:16 ` Valentina Manea
2014-09-16 23:38 ` [PATCH 03/18] usbip: Add kernel support for client ACLs Maximilian Eschenbacher
2014-09-21 0:44 ` Max Vozeler [this message]
2014-09-21 12:42 ` Dominik Paulus
2014-09-16 23:38 ` [PATCH 04/18] usbip: Add CIDR matching helper functions Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 05/18] usbip: Add ACL support to usbip bind Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 06/18] usbip: Add support for ACLs in usbipd Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 07/18] usbip: Add proper error reporting Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 08/18] usbip: Handle usbip being started as user Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 09/18] usbip: Improve debug output Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 10/18] usbip: Separate protocol/program version Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 11/18] usbip: TLS for all userspace communication Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 12/18] usbip: Exchange session keys in userspace Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 13/18] usbip: Pass session keys to the kernel Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 14/18] usbip: Wrap kernel_sendmsg()/recvmsg() Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 15/18] usbip: Add encryption support to kernel Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 16/18] usbip: Update documentation Maximilian Eschenbacher
2014-09-16 23:38 ` [PATCH 17/18] usbip: Increment version number to 1.2.1 Maximilian Eschenbacher
2014-09-17 17:51 ` Denys Vlasenko
2014-09-18 15:31 ` Fjodor Schelichow
2014-09-16 23:38 ` [PATCH 18/18] usbip: list.h include stddef.h for offsetof Maximilian Eschenbacher
2014-09-26 11:56 ` [PATCH 00/18] usbip: Crypto and ACLs Valentina Manea
2014-11-07 17:49 ` Greg KH
2014-11-09 21:10 ` Valentina Manea
2014-11-09 23:33 ` Greg KH
2014-11-11 17:52 ` Maximilian Eschenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140921004433.GA12922@x201t.vpn.hinterhof.net \
--to=max@hinterhof.net \
--cc=dominik.paulus@fau.de \
--cc=fjodor.schelichow@hotmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=johannes.stadlinger@fau.de \
--cc=linux-kernel@vger.kernel.org \
--cc=ly80toro@cip.cs.fau.de \
--cc=maximilian@eschenbacher.email \
--cc=shuah.kh@samsung.com \
--cc=tobias.polzer@fau.de \
--cc=valentina.manea.m@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®