Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4333576pxu; Mon, 12 Oct 2020 16:34:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3LqlJZeH+GeHjos6tzvApPLO6E3lk4ej+8qh2k0sGBhHGtyGkRUhSTIIORO9aiY52jyX2 X-Received: by 2002:a50:a6cf:: with SMTP id f15mr11691418edc.30.1602545670073; Mon, 12 Oct 2020 16:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602545670; cv=none; d=google.com; s=arc-20160816; b=sN+Fo7vSe5esRIv7lNwgIxXF8X0UAq8erh7vnS7sGsCprPLWYzdjgUJ3UFGY2eu5Z5 b3qR6JW4zA9gW360nxkgcK6OS3INHb15Aktv7ARQeBD0/GUE4NW05XmD0tqsrXCEaLAm RI+K5YGxIN69zhaeKn8IKAGH4bJMCZmilCU3WWcLCe90dBoiQw/gec1gP4ioYg/+hoOQ h4fjtI9HZle7KRxl4ehegvu/J/eb+VYcNpVMq8ht+yttD5bvvoLbQv0grfnRYrf5bBl+ ilzIyhTs5zY7wkLOTjtJ3iVSM5QrvFalUv4Vx+pv3OacDUfnLC9eK2VByyLIGFagqcLS 1S8Q== 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=enPYWDeMvkjJLqniOSqXUglb94GgEduMnOIL/WxIM1Y=; b=ygRspjMCNjlTuAXo2gMS+Zti4Rq+ryb9vID8nV5Ocx0V6A+ZKiVt1yKU4UNGOu67Cy vLV+25VWQXBhv9AP055cUundfe+4F7tBZDi9Zln17fwqYXAgwGyZAzkXfv+Y0kCcwvlQ Vae76/p45z5pE9KJkgIRWZgBqtzCIjxJ+s8wIV/DUaYBDz7NiPcgOEStEteT9h14Zfrm QqXO5KcMat4k1QU3IZNvpQK+LG/6c846fqemu+AnmQrnTTAyFcDED6k0Wl8BwP3GQNpj s0rJTU0sbVjkNHazP3sadKpIuh66jNXP61mMp4dDUiqcwIG2EkTJ1dKB7OQZGMvy38Gi m19Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sbnQrC8S; 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=fail (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 d17si15851712edj.42.2020.10.12.16.33.51; Mon, 12 Oct 2020 16:34:30 -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=@kernel.org header.s=default header.b=sbnQrC8S; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389411AbgJLNn4 (ORCPT + 99 others); Mon, 12 Oct 2020 09:43:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:47388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731597AbgJLNnD (ORCPT ); Mon, 12 Oct 2020 09:43:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 2B6BF20838; Mon, 12 Oct 2020 13:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510182; bh=WNWnkFrg3u7y8D9ZPKPunc+98N2g9XUHgudcluYBRiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sbnQrC8SA93iBmGRNSrxheJbHHoEwcqvSaS86+OUu40s0Jw4Ls/Cgudk81f++HPpT fhygEoot0KqfJpxVW4ktqq4TUPra0mgK9E4OOJU+98xaGJ4R0PJ2EJqnqx/nFQqOKK OfHWxm/kFf/VxJRvcSm6aWDZZHJbcmUX8j7Nan/Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Sasha Levin Subject: [PATCH 5.4 74/85] rxrpc: Fix server keyring leak Date: Mon, 12 Oct 2020 15:27:37 +0200 Message-Id: <20201012132636.408385462@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132632.846779148@linuxfoundation.org> References: <20201012132632.846779148@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: David Howells [ Upstream commit 38b1dc47a35ba14c3f4472138ea56d014c2d609b ] If someone calls setsockopt() twice to set a server key keyring, the first keyring is leaked. Fix it to return an error instead if the server key keyring is already set. Fixes: 17926a79320a ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both") Signed-off-by: David Howells Signed-off-by: Sasha Levin --- net/rxrpc/key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index 64cbbd2f16944..85a9ff8cd236a 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -903,7 +903,7 @@ int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) _enter(""); - if (optlen <= 0 || optlen > PAGE_SIZE - 1) + if (optlen <= 0 || optlen > PAGE_SIZE - 1 || rx->securities) return -EINVAL; description = memdup_user_nul(optval, optlen); -- 2.25.1