Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3584219ybl; Mon, 19 Aug 2019 22:17:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCOqgl9OhWrBFtjrAJZw2N0kJmBvTSZruk/xRsNm94i8MxEsrJSYYK9yOMwTRRn1gre7Ji X-Received: by 2002:a17:902:e30b:: with SMTP id cg11mr26837985plb.335.1566278274337; Mon, 19 Aug 2019 22:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566278274; cv=none; d=google.com; s=arc-20160816; b=YZqPkbbYU4JI1gUuBtJvhtZQkUCuuKR/a5N4+PGm55/SGO9LMBJrEq6nbfZmcAefON GcdTTpjYkJqF/7DFEQScbH7bEbSIEiuvKnYs4h/JRSp7xJNAN9ygmgQRLSKgjHf9J5nX RGWVhxC7eLg5CozlS2giMeI5INSts0iFjQ2Quu+fncBH2mH4zUQj61W5Ew/VovL6iqAZ S+Ho1hExXk4gDscNmmGYinb0HoyRV2jF9T1xV8BgdJvYa6JFD6uLmJMX9TC4vguVEsqS WbjZg6GofwNM062lyaAVyracEZGCY6mYtDrb+/g6uYMqnRx9DG62TKujFu6RHF/YL5wC S87Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=K9tXVaDYowv5bpbaTMDm753oQMxXGl7hp7rsvZH90aw=; b=KlPjz0C13nRESKt/1MGYTQ6+tG3rJ+y7JOL+XBmMl5ZYm3FsytTJw1sEZXB4d4iGkd YYJZSwyusrIEZ9ERV63XFpdsVbrPxSN78drv2YAgr4u53PT2ZD3GYSELASmWgQ7kArkn +czoRCkBO7fa0bqrid1dVKG+B05346PTbIGJApUmr77zS2Psyr36Y5xTc7gp1WT6SaWl Pseoxib+mNLde09+/MPL6+7QabrwFBGA183kTbXZSvZxRceza7I9y6u2PWlcZJNTwnl0 Jl8DSTXfFA0798JNPb+K9TFLv1Shptibtg19TNjr426zjNI/pPhiRdso87m7AlHAuSBK UXFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o33si8990360plb.415.2019.08.19.22.17.37; Mon, 19 Aug 2019 22:17:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729147AbfHTFQs (ORCPT + 99 others); Tue, 20 Aug 2019 01:16:48 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:42876 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729060AbfHTFQs (ORCPT ); Tue, 20 Aug 2019 01:16:48 -0400 Received: by mail-yb1-f195.google.com with SMTP id h8so1549007ybq.9; Mon, 19 Aug 2019 22:16:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K9tXVaDYowv5bpbaTMDm753oQMxXGl7hp7rsvZH90aw=; b=QNV7X5kxBbVBSwNUIZMBudwI3tHCpcn/YN/6/9UIfJPfDsNYdZaIlKrjxIvItlrqhJ 890rIgJ17zGjrl5qb+YJG2ELiSEM/EdLXTHF9ACfOsVWYRygMFtkVYHmKE2EWMmMqHga zkzE2JEPhxmkzFgM3+EaJ06MW/ESyLQjkpFphgimYjQuG+yDQDDHQUfjMJWcNwIXKEGs YREChWQA0DTrPCtE+Tp0haNjd5Kmq/Cfcr9lMAckB0WSBlT6gH2fvC+Q5VHglRmLsW// 3BdHq1zGojFK/PpcLAmnyDPoGL6nq0yJufILk5h6zqWzYzU1PEWvX0pBzZ+tkfGilIib pEIg== X-Gm-Message-State: APjAAAX1dYINJRd9vNqVUGVjI45naBfw45scEvkS3K3vaeQ3fXiD/jSb EK68+2Gf85zHmY96UQpflU9Pwuzl8ufNBQ== X-Received: by 2002:a5b:98c:: with SMTP id c12mr18786567ybq.238.1566278207495; Mon, 19 Aug 2019 22:16:47 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id 207sm3654969ywo.90.2019.08.19.22.16.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Aug 2019 22:16:46 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Tyler Hicks , ecryptfs@vger.kernel.org (open list:ECRYPT FILE SYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] ecryptfs: fix a memory leak bug Date: Tue, 20 Aug 2019 00:16:40 -0500 Message-Id: <1566278200-9368-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In parse_tag_1_packet(), if tag 1 packet contains a key larger than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES, no cleanup is executed, leading to a memory leak on the allocated 'auth_tok_list_item'. To fix this issue, go to the label 'out_free' to perform the cleanup work. Signed-off-by: Wenwen Wang --- fs/ecryptfs/keystore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index 216fbe6..4dc0963 100644 --- a/fs/ecryptfs/keystore.c +++ b/fs/ecryptfs/keystore.c @@ -1304,7 +1304,7 @@ parse_tag_1_packet(struct ecryptfs_crypt_stat *crypt_stat, printk(KERN_WARNING "Tag 1 packet contains key larger " "than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES\n"); rc = -EINVAL; - goto out; + goto out_free; } memcpy((*new_auth_tok)->session_key.encrypted_key, &data[(*packet_size)], (body_size - (ECRYPTFS_SIG_SIZE + 2))); -- 2.7.4