Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1771964ybg; Sat, 19 Oct 2019 02:10:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqz43QZ9PTUkIMC7jr5V0c7r3BZTmi8cAgWEC5PMyvjXQZQPtqzdoI7a8ucZ/hmv7f4Z/JO2 X-Received: by 2002:a50:eb4d:: with SMTP id z13mr13957285edp.175.1571476248606; Sat, 19 Oct 2019 02:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571476248; cv=none; d=google.com; s=arc-20160816; b=l3g22Kl8nubK2n+wuIGGuQO3wr5SgtF4OpG/gxwWKRfDMHuMvyaQV37m0/O8doRqDw HxXg2L/S3TK57RTPZz7aQ7GkBifxQ5cNcXETX7seVcC4gwNI6YSqfFvyU6tiIz9jJR+L H7+KWO8nK2pheE0vk0QLr7+e4r5GwF1GEz7+t43+lXfg/j29VcUPOK8WHLOCw3KJOF4r kv9x390/Nb1FSKSOXX4sF8ztFFkp5fJ5A9r7Rme0tCjmup8Dtlq5GDyk48MyBgs8KgTW 4zpvD/k5bDjEczMOxTvTikrqI9joPu1h4HjwEZJegvQT9/n/exawvPL4wVYH1yfS1B9O qBew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=pP5qADOEJChl554c8OUfyr4rzxhx2T8TeyOObOAt9fk=; b=ii0gg2+oeWwib0BzYm7jPZSfYoHcxr20jq/D4m3lAEt5dhZ0O77sIdIvK/h8d1apIh exRNJnbiWAbhLxGCIozYO1aoDzGzs3L3PpI8ifBQZC/bPKy68fbrh1DB8kjNZ9ASzlte ls/3dL+qsbt0zIlueHIG4QJL3iLNVRNclpXdZsay42qQLzvaI9Pnx//ZcIidaI5I2EH/ Rc5Gj6LmDRwXPCJmDTDaRg7MtmY2r16Ht8zKhfwburVdVqAcZZxK3sFS62G96pyhU+t+ tpEijg9DdadpH0HJZTn2HJ3xKDpKjskT+Na9hu6aLebarpxpG18Pj6NVv4Xwz7DE4brZ cXQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lSZOPZ5s; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oa24si4853746ejb.41.2019.10.19.02.10.25; Sat, 19 Oct 2019 02:10:48 -0700 (PDT) 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=@kernel.org header.s=default header.b=lSZOPZ5s; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439974AbfJRSzQ (ORCPT + 99 others); Fri, 18 Oct 2019 14:55:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:55574 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbfJRSzQ (ORCPT ); Fri, 18 Oct 2019 14:55:16 -0400 Received: from localhost (unknown [38.98.37.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6F60220640; Fri, 18 Oct 2019 18:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571424915; bh=K/12HBOLREs70oPt0BZw/4JhTqL9elo+MXR7+xUsZpc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lSZOPZ5s+y6I0QKlrMUyTBW6wCcQf+ClsnwoUbqkZ0ShgPjqSHXIqLI1ZUmD9voHo yVeGB/LPOjtZuCbmteO7cUk+fNre3cNoksos3d9qDvait1oTrFbG1ewzJq71c+lmx1 STz8i25nWbFnfehNscC5vHfMSPlSsNncz7Sd001g= Date: Fri, 18 Oct 2019 11:54:58 -0700 From: Greg Kroah-Hartman To: Johan Hovold Cc: Alan Stern , Oliver Neukum , "Paul E . McKenney" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable Subject: Re: [PATCH RFC v2 2/2] USB: ldusb: fix ring-buffer locking Message-ID: <20191018185458.GA1191145@kroah.com> References: <20191018151955.25135-1-johan@kernel.org> <20191018151955.25135-3-johan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191018151955.25135-3-johan@kernel.org> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 18, 2019 at 05:19:55PM +0200, Johan Hovold wrote: > The custom ring-buffer implementation was merged without any locking > whatsoever, but a spinlock was later added by commit 9d33efd9a791 > ("USB: ldusb bugfix"). > > The lock did not cover the loads from the ring-buffer entry after > determining the buffer was non-empty, nor the update of the tail index > once the entry had been processed. The former could lead to stale data > being returned, while the latter could lead to memory corruption on > sufficiently weakly ordered architectures. Ugh. This almost looks sane, but what's the odds there is some other issue in here as well? Would it make sense to just convert the code to use the "standard" ring buffer code instead? thanks, greg k-h