Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4298285pxu; Mon, 12 Oct 2020 15:22:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7pugpHz4IQFBrFO0ebzsPSlF/61/s2ek1Fh63mu+2PHFW+VJgsSbTLVzdiOjIQAI/QOrc X-Received: by 2002:a50:8e43:: with SMTP id 3mr17002649edx.178.1602541350758; Mon, 12 Oct 2020 15:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602541350; cv=none; d=google.com; s=arc-20160816; b=aQLv3Gs+2fVMQy/XhUGcJZKxjEzSJFAYZQDi0K882Il0bm77EGS8dCmWphf510WNyF M3rQutrVubwKOIVTZF5dkr9WdYdD5PWsaS0qEfBWnP2klqs627BnVDyYi4XkxZOruwg2 +Qhwc43kfZmulu/fMIOg1cD8Q9j+fcpxJXTTSpl+Fer77EeJefQquuoVwQYheViERni+ rBWDVhC6nQN7KGczDToatxOPa99x3BkNJqeFnz3r4/lXNrjcEgbzleeXyrWEESfgPS4K cdQCj9kuS7eT3GI/KFdapiq0Qs8Tmix0D8EHWgOXV834eVRKsai9G0uxNkvcnrmHpjgQ McDw== 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=zz4BSY2teDsfmGFuN3o0X7ekBHtPfYAldxV0pRXvpLI=; b=zmNY+VvqTRR6hXKUtlIBVq0FUENhZY1uZBdo2uFHuG+ks6INwzX2BbPF8viUPpoam+ 765NvvXIxwu9WfAOREtYGTNCBkb0sooLBTKMwUDLX2O8jSvrEIvNSs25UWWTGlbfI+2E R5LFiMhIf5pgxURYErXHgbanASd7pdyImHwDnyAyy7LOEFuu5ec3Xn7nHJ8yvQUlLttc 5d+jZXUU9+blZkSOV9uRlXjH1lN2hAicEYoC6QilyfbmC1+g4FQOz63s6TyE+YlOlbjZ AeViAwQbrnceprwK8Cs+PS3+1Ze8z+aHRlddGuR2p9nIkeDuDs9fQIvBO5ozTL75vDLA +0lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YrPjHUl8; 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 o1si13041704edv.320.2020.10.12.15.22.04; Mon, 12 Oct 2020 15:22: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=YrPjHUl8; 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 S2389124AbgJLNdO (ORCPT + 99 others); Mon, 12 Oct 2020 09:33:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:35198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389059AbgJLNdH (ORCPT ); Mon, 12 Oct 2020 09:33:07 -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 42717221EB; Mon, 12 Oct 2020 13:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509586; bh=0BeFLgFqdU3EcsLD1F/sJ6++72ggvfkwP3dYbDM0IPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YrPjHUl8HVbje0v8arv8eMxcWJS1C8vFjY5w1pqcKXcvhQIEpV6SYKomnr2JkcQCM goVfnZsUc+wGvGiGYYrNEZRykxsz9A9bTX4iX6xvJfPijZsxQYpCMeX8Mv/6n+NHS/ PO2sBXWruKkVL5Ys/q020asAo/gsYDtmkH3BfofI= 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.4 38/39] rxrpc: Fix server keyring leak Date: Mon, 12 Oct 2020 15:27:08 +0200 Message-Id: <20201012132629.911556969@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132628.130632267@linuxfoundation.org> References: <20201012132628.130632267@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/ar-key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/rxrpc/ar-key.c +++ b/net/rxrpc/ar-key.c @@ -897,7 +897,7 @@ int rxrpc_request_key(struct rxrpc_sock _enter(""); - if (optlen <= 0 || optlen > PAGE_SIZE - 1) + if (optlen <= 0 || optlen > PAGE_SIZE - 1 || rx->securities) return -EINVAL; description = kmalloc(optlen + 1, GFP_KERNEL);