Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2656308pxj; Mon, 14 Jun 2021 04:11:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPEzNhRmfqReL+MzpmN8ZK/Epb2vLmLbnyef6kTKf/pIQ29iKMy3e2nffuOMVS6T8MqpFw X-Received: by 2002:a17:906:3057:: with SMTP id d23mr14741179ejd.131.1623669074760; Mon, 14 Jun 2021 04:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623669074; cv=none; d=google.com; s=arc-20160816; b=sNfKoB62v9qBAQqYP5Qe89e42rQTwX4Jf0BUCcbuuDMGPaJaeeErBliOgdhc3rZoAa RGFYqZuVgD5cTucK2utGkpSQYtKdOOTsnn1nq2i89cYPbHez+wQxvMhkkYH6UGrvAURC qKJJxQ+M9tJDKaGcMzX8ExrC1I6SSOOjLEnDc2cysAGfdGgObbNG/GZn9sAyEHm0MqpA 2WoAUxsgr/sE5fUlpx5L8qWNt8Duf/cJovuW6C985npDyI2M0I1ah53ZisCaD4PlI6wo L0KKiw3gE3QHEg/ckIW+nkKR0vadncFLZ5/O1iQr6Gh9DZ1T5gHg5KKYltGBFnL+W0e2 qcgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J0MLCrfL05PjEg+SYDbZ9o3qUYUk/FSfVJ/+nOddg80=; b=nA/AOvdI3Av6q8y432Jprs/LhHgWN08A/UX28UBTPRioLUXTcOhIzCzJwuIEDdxgOY QpKRRrNyW3/+gwy33D1QbPGE3saGLCRzWjTTkj2FmAfrzhIp9P7Ntw8XudHEuyk8NRBT lZzyAIGph5S5boJ2ld4aMvSfMDWqf0jW8OUs6gMbueFqtQwDrmB/GxxGWalLnO+vztIs Bc3DNZ/B3c9x9X6ssNwr/X/t/smjaNv3WgjQBtVbs01QF17ean5x3x97hUlw0IkNr15I bB6YQR/3OsAYyc16VPCgDI03etvH1CJndXapCryZscwx3z47jmUubp1Dy0+xRgTYR0NF tH9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="En/h0Yye"; 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 j23si13221959eje.719.2021.06.14.04.10.51; Mon, 14 Jun 2021 04:11:14 -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="En/h0Yye"; 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 S235623AbhFNLK6 (ORCPT + 99 others); Mon, 14 Jun 2021 07:10:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:35838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234907AbhFNK7c (ORCPT ); Mon, 14 Jun 2021 06:59:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4128261628; Mon, 14 Jun 2021 10:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667344; bh=GuPFsSuib4mnjhLtL2ddfg1ENJrgqkvaZ4q0gRNk1Tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=En/h0YyeI/mQtRWk4TMcuf1Rpmf1iUm6qPsj3pBhdqSj+ubFDMFsseMktUmKQz22y ZhJi26h0g3mGA2u/Lb1bBlNeiNz8CQU6aSC0SCuykBbnj7fRwUIQocTvRl1WYlsCAP nL7aLk3doqq/rbdZWRnuav7HLe0jOIL/z1geAV7w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeimon , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 007/131] net/nfc/rawsock.c: fix a permission check bug Date: Mon, 14 Jun 2021 12:26:08 +0200 Message-Id: <20210614102653.218539315@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102652.964395392@linuxfoundation.org> References: <20210614102652.964395392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeimon [ Upstream commit 8ab78863e9eff11910e1ac8bcf478060c29b379e ] The function rawsock_create() calls a privileged function sk_alloc(), which requires a ns-aware check to check net->user_ns, i.e., ns_capable(). However, the original code checks the init_user_ns using capable(). So we replace the capable() with ns_capable(). Signed-off-by: Jeimon Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/nfc/rawsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index 9c7eb8455ba8..5f1d438a0a23 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c @@ -329,7 +329,7 @@ static int rawsock_create(struct net *net, struct socket *sock, return -ESOCKTNOSUPPORT; if (sock->type == SOCK_RAW) { - if (!capable(CAP_NET_RAW)) + if (!ns_capable(net->user_ns, CAP_NET_RAW)) return -EPERM; sock->ops = &rawsock_raw_ops; } else { -- 2.30.2