From patchwork Tue May 23 16:33:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9743033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 623F160380 for ; Tue, 23 May 2017 16:34:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 547E3286B8 for ; Tue, 23 May 2017 16:34:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48548287DC; Tue, 23 May 2017 16:34:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05CFB287AB for ; Tue, 23 May 2017 16:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937098AbdEWQeU (ORCPT ); Tue, 23 May 2017 12:34:20 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:33936 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933184AbdEWQeQ (ORCPT ); Tue, 23 May 2017 12:34:16 -0400 Received: by mail-qk0-f195.google.com with SMTP id u75so23409756qka.1 for ; Tue, 23 May 2017 09:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=LsKsBcI3j5GrRXvJ3shd7gvHJ7mb6WK6Ic8s1O92Eqc=; b=nK47Acqj4DuMHSufSptJzCW084wr0wkAikI9Js+E2yWWrjcQBt//d5fzp137FVXN1h evD1l4ZvoNbwUvdtrOmLTCvzjEJ1Gh4FhFXTBLov/7QFWrxmZ/4haBr90mBj59E1NT7Z y2y3y1dnP7D4fkOYcx90n2cJ2T7sTnVR3V5XO31pCedEfr9wcur+PXnpER8hsM9NNFra 7gaY840UVf+Diu6g2ryAtrZ77O8W5fC/Rn0pjE2YTjMkqWz15F+lJUP8XMRs3TOhRyVL VZ+OFO0Q3S/izb0kvpFK/fPPIZP5BTqskZhWxcS0oVxB8PApxLWZlFFmsCcpPTAyt5PC q4IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=LsKsBcI3j5GrRXvJ3shd7gvHJ7mb6WK6Ic8s1O92Eqc=; b=FU/Pms0dYW6saL1PNwsufUtWt82LQgUcae+qdinCBW3aMIZpDkaCFsaSlD0q6R52Hs apVRegyhw6JCkPJqnBh/gWPEDxramTXurfb3TDouR2GzCwfEcmH3NQgw6KUdP+njlPiN mopRAa1iyJFSHtQjVIUlkPe39BwZcIKKfAqmOnVkIdm8u7wftvFiWep0igvFb2627nZ6 EOpukXhpodQC3onqDyPf3wtZa0iYfchs2fkMt9ZNJ7XH0bptWi7oIroGw/xcZ4OOp/QF WguTabTiMLc55EerLKVBZZnxD+RzuiTFjUcUqyVLI7JrEMiKTUIgJ4dHNQXneOgudinQ L7ww== X-Gm-Message-State: AODbwcDoYeVqiI9A67cCDRAjWjmsWZ5RPff6t7MM4MrG8wpEoNBaO1L1 yltIS7cFA1g7zW0pRPw= X-Received: by 10.233.235.72 with SMTP id b69mr26937891qkg.206.1495557255786; Tue, 23 May 2017 09:34:15 -0700 (PDT) Received: from orange.brq.redhat.com. (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id o15sm784055qki.47.2017.05.23.09.34.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 May 2017 09:34:15 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 5/5] libceph: fix error handling in process_one_ticket() Date: Tue, 23 May 2017 18:33:58 +0200 Message-Id: <1495557238-1077-6-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1495557238-1077-1-git-send-email-idryomov@gmail.com> References: <1495557238-1077-1-git-send-email-idryomov@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Don't leak key internals after new_session_key is populated. Signed-off-by: Ilya Dryomov Reviewed-by: Alex Elder --- net/ceph/auth_x.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c index d0126df33f1f..8757fb87dab8 100644 --- a/net/ceph/auth_x.c +++ b/net/ceph/auth_x.c @@ -151,7 +151,7 @@ static int process_one_ticket(struct ceph_auth_client *ac, struct timespec validity; void *tp, *tpend; void **ptp; - struct ceph_crypto_key new_session_key; + struct ceph_crypto_key new_session_key = { 0 }; struct ceph_buffer *new_ticket_blob; unsigned long new_expires, new_renew_after; u64 new_secret_id; @@ -237,13 +237,13 @@ static int process_one_ticket(struct ceph_auth_client *ac, type, ceph_entity_type_name(type), th->secret_id, (int)th->ticket_blob->vec.iov_len); xi->have_keys |= th->service; - -out: - return ret; + return 0; bad: ret = -EINVAL; - goto out; +out: + ceph_crypto_key_destroy(&new_session_key); + return ret; } static int ceph_x_proc_ticket_reply(struct ceph_auth_client *ac,