Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4292631ybg; Mon, 21 Oct 2019 06:50:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqysnUetBUT4pPXXu68jUgeCI3ZjCFWN0fy2am5dv2UgVl9o7oEkR+HncMAgN7fdZiVTqrvh X-Received: by 2002:a17:906:e2cb:: with SMTP id gr11mr7748550ejb.205.1571665837912; Mon, 21 Oct 2019 06:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571665837; cv=none; d=google.com; s=arc-20160816; b=j/OgMUvmvAT2PESQ6eK/TmwrHYTm5JJzWcfZ4rMSziWU/8ClkbEwEPtMdbEOwRSoJD kHNydzF4RW9lPkX6RleaFnbE6S1G+Q19qYZtupXSlAlXBDY5XIyM+5TJZpWehvalSXB8 RPvV40gZbGLhZEf6CF1URUipT+sZh/4GCZ6mbAIIk1mcBWCIjWolsy59VKYqNVHfSIi5 cdY4NCd/f/IsbNii4/cc+56H81G4dvt+T2R2tChgradXy2dSIq827Iqz4dyxTrY39qcK OomecL1QIVp2FNHA2xyBQBOWs84mAvHyEjq+Wp/rq4VUm0cVyxoujTBodz1TAeC7qnDU 1KbA== 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=w5j+Lat9YxNNRNq3aR2kkN7kRaLXRgh7NcOuToJD3pA=; b=OoaTUkqllA0D+DhkVTdFDTYjBoDlHBUBe5yoObCD6UuhAxggbIDv3JyfXa867HUKXN Rl1IP9pyNYlJafKfxqKCs0SYIrTePczcIo2xb8HC1p6hpdUoRff/hUku6ho62MACOlUP Umf/SRRmX3bN6B32vGy1YwkA654bjV+Prn0tL/Fnv/mWsQobGiSzdVF5vpBr6ENsFmmb 9r7X0bp59TaWcoYFG+o/T1fbwnAFSfVw2RvV5PVbDOLfxev3O+6+Wfvo6/2qNfORBoFQ 3vo0AyyeH4C69IASsYK3aPpp2s53w5BAlMFi2u8tc5df3HthxH9RIPQKiIEXBujGPHug 8kJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E13iGTfv; 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 g53si2674882edb.313.2019.10.21.06.50.14; Mon, 21 Oct 2019 06:50:37 -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=E13iGTfv; 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 S1729137AbfJUNtB (ORCPT + 99 others); Mon, 21 Oct 2019 09:49:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:46506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728083AbfJUNtB (ORCPT ); Mon, 21 Oct 2019 09:49:01 -0400 Received: from localhost (unknown [107.87.137.115]) (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 6C2612053B; Mon, 21 Oct 2019 13:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571665738; bh=ySbWnaqJexdqBk/baKlyM5Agouu1qs77BQ86seAmqVQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=E13iGTfvwvVEb4mMT8FTeElz6uhJ/XfVhU+BRahFUOWjpvj1qmGUPkJQydFX6hROl MyjylgyBFfLuWERg2YGJxh/QlzVhuWjUhJfKSZyE9CTaKnvXnGjgnD6B2iUvHP/E18 XErPOq6Bw6TGFhHbIxNdh4KYA3IX/pInIg8c2iWo= Date: Mon, 21 Oct 2019 09:48:56 -0400 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: <20191021134856.GA35072@kroah.com> References: <20191018151955.25135-1-johan@kernel.org> <20191018151955.25135-3-johan@kernel.org> <20191018185458.GA1191145@kroah.com> <20191021085627.GD24768@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191021085627.GD24768@localhost> 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 Mon, Oct 21, 2019 at 10:56:27AM +0200, Johan Hovold wrote: > On Fri, Oct 18, 2019 at 11:54:58AM -0700, Greg Kroah-Hartman wrote: > > 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? > > Yeah, long term that may be the right thing to do, but I wanted a > minimal fix addressing the issue at hand without having to reimplement > the driver and fix all other (less-critical) issues in there... > > For the ring-buffer corruption / info-leak issue, these two patches > should be sufficient though. > > Copying the ring-buffer entry to a temporary buffer while holding the > lock might still be preferred to avoid having to deal with barrier > subtleties. But unless someone speaks out against 2/2, I'd just go ahead > and apply it. Ok, feel free to resend this and I'll queue it up, it's gone from my queue :( thanks, greg k-h