Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1522622pxb; Thu, 7 Oct 2021 09:22:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0buBhjQNrpmOVap8a68RQd4AgS61V/0MZg8NU/dQNSbLJEQaIh9KyLJsQRVD9LuDzrR38 X-Received: by 2002:a17:90b:1c82:: with SMTP id oo2mr6026303pjb.53.1633623739916; Thu, 07 Oct 2021 09:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633623739; cv=none; d=google.com; s=arc-20160816; b=CA8si9E75vzPAJe1RaxiG8UMC7kSdCwN7/D0eEPbj6oui6wSMIE7exxKjFuOIXhjFi iFuPLAxW1+QV9KJTCOLgNas2sKyzlpvi0AnNv2wBEjORiyZdH4oBrrg+/raw/V+WZ4eN 99D+XJx+UOi8jzZ1bAZEwRUF1EWdfXpoSrNai+XEcYw1J+1ICVxKu8kP52/ZUMauj7h8 yexvjZY3SVtXF00qm/VJDPrgO3qiJLoMGJuqcBpBSb9U1FTgDijBlrvsYemlA5RfLZY3 +g9AiMcxO/+YnCJzArT02zXtkuOIcV9TG4PusobAUCaeBs8EjheIvPCWzybXmOlahOm8 +L1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=O1GhLGWnxXGBpNii+0ZtmA1sQUDiB7XFXuzl87a00Vo=; b=dQ9VRo7OorQdx7y4klledPLxm4cGgd98/crI2ft/EQb9gE7O8Lfuki67QODua0OqRz obBx7TUFrpoxu92TBIcuIk+g/zUqz+cgtl8zBb0KIPHb3dR47lN5luOmIz0oymwT7JgB TjqMurYoUP9NBJHvgbdsUmyjx/CKzw9FtCPHkn2qYTVVnxorev84EEEa0zDxcBY4hbVx YTIJEAB74IabHquTubYORaANZHXy/sZI9fIzrAgL7PBeTRsOT+id/B2ITn0aOY9IYa38 cCc5mlii9T1ETC42bbWv0Vdb3Zt+reXr9gXPvQuTnGmEBcT4uvuvvesboeDJwMSDRVTs 0LpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y6Xs1be4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si16188plx.447.2021.10.07.09.22.06; Thu, 07 Oct 2021 09:22:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y6Xs1be4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242274AbhJGQXF (ORCPT + 99 others); Thu, 7 Oct 2021 12:23:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:37332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241846AbhJGQXE (ORCPT ); Thu, 7 Oct 2021 12:23:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 85CE061245; Thu, 7 Oct 2021 16:21:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633623671; bh=BalsQIewaM6OZkJRMKgt4kFUsr36Qobh/+HBXkovAsc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=y6Xs1be47WqT0hbyAxXWOXgLhzPJqv324AjeinCjB5EwuxW2nCL+3jVTqN3Eut4Rp pK25QjEfVNzObZVMj9ZY/oV4CWe5p87JLz8VzVnLhSRI8pAPXFQgSQ+d7yJBZVhM+1 S0fykHY/yLcLt09glThJFAA5xohUVMFG2jX2nykc= Date: Thu, 7 Oct 2021 18:21:08 +0200 From: Greg Kroah-Hartman To: Jann Horn Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Eric Dumazet , "Eric W. Biederman" , Luiz Augusto von Dentz , Marcel Holtmann , "David S. Miller" , Sasha Levin Subject: Re: [PATCH 4.14 54/75] af_unix: fix races in sk_peer_pid and sk_peer_cred accesses Message-ID: References: <20211004125031.530773667@linuxfoundation.org> <20211004125033.335733437@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 07, 2021 at 05:57:54PM +0200, Jann Horn wrote: > On Mon, Oct 4, 2021 at 3:00 PM Greg Kroah-Hartman > wrote: > > > > From: Eric Dumazet > > > > [ Upstream commit 35306eb23814444bd4021f8a1c3047d3cb0c8b2b ] > > > > Jann Horn reported that SO_PEERCRED and SO_PEERGROUPS implementations > > are racy, as af_unix can concurrently change sk_peer_pid and sk_peer_cred. > > > > In order to fix this issue, this patch adds a new spinlock that needs > > to be used whenever these fields are read or written. > > > > Jann also pointed out that l2cap_sock_get_peer_pid_cb() is currently > > reading sk->sk_peer_pid which makes no sense, as this field > > is only possibly set by AF_UNIX sockets. > > We will have to clean this in a separate patch. > > This could be done by reverting b48596d1dc25 "Bluetooth: L2CAP: Add get_peer_pid callback" > > or implementing what was truly expected. > > > > Fixes: 109f6e39fa07 ("af_unix: Allow SO_PEERCRED to work across namespaces.") > > >From what I can tell, this fix only went into the stable trees for > >=4.14? SO_PEERGROUPS only appeared in 4.13, but the SO_PEERCRED in > 4.4 and 4.9 seems to have exactly the same UAF read as it has on the > newer kernels. It doesn't apply cleanly there, can you provide a working backport? thanks, greg k-h