Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4493730ybc; Fri, 15 Nov 2019 05:39:38 -0800 (PST) X-Google-Smtp-Source: APXvYqygIVU+isr7amHU3vk6Z1nzikvbtFLujel3rgNt4/4n2RtzVTDYcwK8qiFIwZkp8If73MpD X-Received: by 2002:a17:906:600b:: with SMTP id o11mr944207ejj.175.1573825178415; Fri, 15 Nov 2019 05:39:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573825178; cv=none; d=google.com; s=arc-20160816; b=AwFlrTyEUaTx7RkHswIDpVoS2ojnw5OOzGCZkDruupvV8lXu3w/V1kk4yGpYtVW7hR ZMBTl6SR/S/bs2oHGX9SlmvZRa2ji/p3sRMdkcVLcKQE+8w0xzEJ41Qa+WaSQGReO2pF +iTM4IaUG7yaSXQHigHG18Y+JYJjPjvoIGHFFZzd+yuQxqb9X7mguh/4jAAuYzTtln54 v0chgbxWg9zRS+XTHQ8Lww6ljhC3tpmfAhS1nGUfdhTg9lBsQrxaQ6tGKEQSMnz9OCDG 4espYn8zgegqu+YVIHjtLG+FOA3P0dQJGM0vrJNcIrEP1/m1xs/KC/2pbMy2ko3PixOm noPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=G6EkFeMScJt97Zxa/Roqr4qkhmepcK8pLPvMI4jl0bE=; b=U8Dsqf9YRF/07Ijdh3V7cwxMI0S0Xw62UJI/uqPa3YA8cRa0M9iU3lDbyTsAw8OuCM 5qRVcuck/oeL5ruDLikakbjS6PqF2RqzwEkVhjXwvR4u/ukTo4fu04MXY3HFOqrloGqQ M3IqXFBEDUBMijBnmipLWCWMJJYExWQI6pDAIluu0v6I+cjU7QAQRyw5/sZkN9pCzOvv A0dgUjJDT4wo8584MFG7pjDJNZVUkjd67jcCY84J200fppr60SSZFGhxp5ZVCUgGusUF GF8gEYsLv5zFV3pcuVv+Lvo2oJ9YkJNHDxzfobkb0j8Nu5N4jgOt7Af9aQW3+nUsLPsC DBhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=N9YDxlPJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k21si5524110ejc.148.2019.11.15.05.39.13; Fri, 15 Nov 2019 05:39:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=N9YDxlPJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727588AbfKONhS (ORCPT + 99 others); Fri, 15 Nov 2019 08:37:18 -0500 Received: from mail-qk1-f201.google.com ([209.85.222.201]:50771 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727249AbfKONhR (ORCPT ); Fri, 15 Nov 2019 08:37:17 -0500 Received: by mail-qk1-f201.google.com with SMTP id a13so6360052qkc.17 for ; Fri, 15 Nov 2019 05:37:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=G6EkFeMScJt97Zxa/Roqr4qkhmepcK8pLPvMI4jl0bE=; b=N9YDxlPJbBf24qBKjbmFUxwjp7HYh9Ovm2F3sroCnhW54f4ELGNBCOqk2ZiQX4Dgpy vmNv+jIJlJGo5typ0J71QQG814xAs4eigUB3DDbVSCl9nr3ZHSJ3yGZHReeTlnuqnMW5 gOhV6h7VCN6ymjvH1Bz5ThBxZijXPiTx+sy+Hw39CD+TmfZblOa9QolPFOTUEigAAkuC /CMh8DjrEU8ykD8FXhkTiGp8EByDzvHlnJIUSYBkIztIBuNlNXE29mnqmfhER4dFr6bb TPqDohmWv+56Uy543hwCjVDvlbcudJl5rNp62XN2lUxzm3euJayVaClqXTmQIOqGYkTG +4xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=G6EkFeMScJt97Zxa/Roqr4qkhmepcK8pLPvMI4jl0bE=; b=YOot0SpS3NM6ZmwjKnCMoPr5fIyNlMFACfy22RY126JUsZWzHVLr9Q7nlrVJLx6V8/ +dBWhj9SXZ0wX296izYvfhRNyW46wRHwMeARXPJhNrZVqhuIDr+WWdivtRJIWsfQevPP oiyoZ2gnYnlKKN9z46TNBQI11n+ck24PC6GLpHbICrEFaX30ACL0I5HVQR29YdKLTe7K Ax0+Iv5TcsyPA+1/NNEPRAIMBrKSA+/ps7BoHr1Ev4EEbm3b/5lVcQmv7GyEcTn1RQPo 6NwsDdkITCKoQxV323uj43fc3oTXL9cja+RpYBe6liWixo8LB0I1621+quvkbVofEebc zB0g== X-Gm-Message-State: APjAAAUP3VKqe3ODW7VCHJFSCXloKb5fl+MOZmUT+AvRk6QgHa0Ay4eQ jWTO6/k0bcsyQZM4LXNSLvgPUWZvs0+C6k+0 X-Received: by 2002:a37:98c6:: with SMTP id a189mr12586235qke.230.1573825036610; Fri, 15 Nov 2019 05:37:16 -0800 (PST) Date: Fri, 15 Nov 2019 14:37:11 +0100 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH v2 0/1] usb: gadget: add raw-gadget interface From: Andrey Konovalov To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Alan Stern Cc: Jonathan Corbet , Felipe Balbi , Dmitry Vyukov , Alexander Potapenko , Marco Elver , Andrey Konovalov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patchset (currently a single patch) adds a new userspace interface for the USB Gadget subsystem called USB Raw Gadget (I don't mind changing the name to something else if there are better ideas). This is what currently being used to enable coverage-buided USB fuzzing with syzkaller: https://github.com/google/syzkaller/blob/master/docs/linux/external_fuzzing_usb.md Initially I was using GadgetFS (together with the Dummy HCD/UDC module) to perform emulation of USB devices for fuzzing, but later switched to a custom written interface. The incentive to implement a different interface was to provide a somewhat raw and direct access to the USB Gadget layer for the userspace, where every USB request is passed to the userspace to get a response. See documentation for the list of differences between Raw Gadget and GadgetFS. This patchset has been pushed to the public Linux kernel Gerrit instance: https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/2144 Changes v1 -> v2: - Moved raw.c to legacy/. - Changed uapi header to use __u* types. - Switched from debugfs entry to a misc device. - Changed raw_dev from refcount to kref. - Moved UDC_NAME_LENGTH_MAX to uapi headers. - Used usb_endpoint_type() and usb_endpoint_dir_in/out() functions instead of open coding them. - Added "WITH Linux-syscall-note" to SPDX id in the uapi header. - Removed pr_err() if case dev_new() fails. - Reduced the number of debugging messages. Andrey Konovalov (1): usb: gadget: add raw-gadget interface Documentation/usb/index.rst | 1 + Documentation/usb/raw-gadget.rst | 60 ++ drivers/usb/gadget/legacy/Kconfig | 8 + drivers/usb/gadget/legacy/Makefile | 1 + drivers/usb/gadget/legacy/raw.c | 1057 +++++++++++++++++++++++++++ include/uapi/linux/usb/raw_gadget.h | 167 +++++ 6 files changed, 1294 insertions(+) create mode 100644 Documentation/usb/raw-gadget.rst create mode 100644 drivers/usb/gadget/legacy/raw.c create mode 100644 include/uapi/linux/usb/raw_gadget.h -- 2.24.0.432.g9d3f5f5b63-goog