Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4408580pxu; Mon, 12 Oct 2020 19:21:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrPF6DQOM9QfBHM/oo4rC+XSstvaBDEXyRUfG2BqCpMe2lfe5eF3VsSwhMlAKEvZg0YfUo X-Received: by 2002:aa7:c915:: with SMTP id b21mr17440102edt.25.1602555661179; Mon, 12 Oct 2020 19:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602555661; cv=none; d=google.com; s=arc-20160816; b=TqNeWurDfAHRXQzIEbl3vlsPWMwKzssEdimS9HMi1RWOXO6kQTgQgWtYa8XcHVINo8 uK7B46TqEyUUdWJK9xRn2ir7lSIFLpY+zBScmxT5w/eRwyei1i6Wiu1YpIc8YVp3zZqp G433mUer24KgMYwJYu1ebG4gB9LoUTh06SOv1XBv25kXh/K0O5+Dq/h3/ByKMC78hwMg SbcSLmku/t9La1GeY65rKV5AVc2HI22Wh/CdI5+IwspgzOT62yO0pPrZ1+kZaJE+vJCb ebcYpMdmzxxrUk0r07QkNioZ24tBcQwG0T499TWvGhMIhTqk6FVk0nBG90QtPdnNBGHh neQA== 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=jnJ3hB+3WzXXuO3YKs2R81Lh/nIhlhBa6YECzpFehBo=; b=vlbQ0KeG1urQvKtNyWrLx9s4JVRc5Oxh7iyd4bs1Rg1JIAE+EQ2wY6xN9KQPW4C3bp ec5xAI+YT6srjSFb0yoznP8uPJlUa1kFuQkJcIvec662VphNPvDCYz1zmA/SyIDPlAAU AnTboxTbtb0QK62JH9RtjQNnole+E/M/8pAjk6vCSwT/UyLv6EGBLxwqr+3yqadF6vby YnkVlofL3R1dIfYnY1Ag4lRAL0j3afqjDK4tbRWQ37WkyxLM7wij596HC4H8z6FuxvZb Ph6BmNnMMc9nVCK8/siJ4ZdafVaYwKLkSk6aczReE5ZtNMg6E0AUoKEtUh5eGfkHKp/G gfSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0mYJyRgy; 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 v22si13076493ejj.27.2020.10.12.19.20.38; Mon, 12 Oct 2020 19:21:01 -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=0mYJyRgy; 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 S1731791AbgJLOCG (ORCPT + 99 others); Mon, 12 Oct 2020 10:02:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:40152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730501AbgJLNiB (ORCPT ); Mon, 12 Oct 2020 09:38:01 -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 574A22224A; Mon, 12 Oct 2020 13:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509872; bh=VG9CSanfmLO4eHxmZo/+noXJhoJKQEcs8kV3iIYycxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0mYJyRgyn17n3C+pv6eMQndEvQ0mKwLgJ7CvM0F6dhvckH0I8P+JCPIItqLW+3UtC fxu/5CaBfFLTIfN9PlivR2Y1OVsAUyNRy4PQads8V2jyRkkspyYOxkGResOS/5kIxM yaus0z/yZBNHk1iTQpN8W1jUtS7KtVplBMtBXA60= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Sasha Levin Subject: [PATCH 4.14 66/70] rxrpc: Fix server keyring leak Date: Mon, 12 Oct 2020 15:27:22 +0200 Message-Id: <20201012132633.380426962@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132630.201442517@linuxfoundation.org> References: <20201012132630.201442517@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 1fe203c56faf0..2fe2add62a8ed 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -905,7 +905,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