From patchwork Wed Oct 3 17:19:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladis Dronov X-Patchwork-Id: 10625119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 927BB15E8 for ; Wed, 3 Oct 2018 17:19:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 718C428DBA for ; Wed, 3 Oct 2018 17:19:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 633A528DEC; Wed, 3 Oct 2018 17:19:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1399928DBA for ; Wed, 3 Oct 2018 17:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726862AbeJDAJJ (ORCPT ); Wed, 3 Oct 2018 20:09:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37582 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbeJDAJJ (ORCPT ); Wed, 3 Oct 2018 20:09:09 -0400 Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D625B3099FC2; Wed, 3 Oct 2018 17:19:51 +0000 (UTC) Received: from rules.brq.redhat.com (ovpn-200-24.brq.redhat.com [10.40.200.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6A36309136D; Wed, 3 Oct 2018 17:19:46 +0000 (UTC) From: Vladis Dronov To: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] HID: debug: fix the ring buffer implementation Date: Wed, 3 Oct 2018 19:19:33 +0200 Message-Id: <20181003171936.11271-1-vdronov@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 03 Oct 2018 17:19:51 +0000 (UTC) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patchset is fixing some aspects of the ring buffer implementation in drivers/hid/hid-debug.c. This implementation has certain problem points: - it may stuck in an infinite loop - it may return corrupted data - a reader and a writer are not protected by spinlocks, which can lead to the corrupted data The suggested patchset is a new ring buffer implementation which overwrites the oldest data in case of an overflow. One can verify the suggested ring buffer implementation by fuzzing it with modified kernel and fuzzer-reader at: https://gist.github.com/nefigtut/33d56e3870b67493cc867344aed2a062 Vladis Dronov (3): HID: debug: avoid infinite loop and corrupting data HID: debug: provide reader-writer locking for the ring buffer HID: debug: fix ring buffer implementation drivers/hid/hid-debug.c | 201 ++++++++++++++++++++++++++------------ include/linux/hid-debug.h | 1 + 2 files changed, 142 insertions(+), 60 deletions(-)