Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3329217rwa; Tue, 23 Aug 2022 02:59:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR6tujoZ3dVObBTO9Hjz57SnJ9jAN9r6SenwTqp5aOFEdw3KYftzWDgZLIy5YQ5XvBNKOK/i X-Received: by 2002:a05:6402:50ca:b0:447:3355:76e3 with SMTP id h10-20020a05640250ca00b00447335576e3mr250428edb.72.1661248744145; Tue, 23 Aug 2022 02:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248744; cv=none; d=google.com; s=arc-20160816; b=Kt7JxeqJs1FOHdqBbJIXC7GEPC6YEKyT6HVoRpmMqLDLT6CfJl9SqdWfuPSxwqQeDo 4hkzzPFz6fVHM4wB5HkeTSLwMcM9j2H1kuAv6JtY/dDuUFCnnX24GRrb3GcIBd758Q2x L/30oqubJQEpk3cWS6FsgosLsEopy4wB3XiqfnO2dE1nwSZgIoasyO4JlY3bnA64wlwI 97uWfl8PjX2TGX4PKrD1R6BlB9XiXwQIFU+hmqDceBogRb0iF0vYnJjmzFQmDoDE9Mue 4WNj4mcei06JadkFrqykGYSuBGmBmJr6hUqr5HzCCgctUTch1J7AbA4aJ8N8woIh+iTx 1Fvw== 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=pkCbKfCWdXKL46X3URmU/HRAXdm6COuTxurVq8tJEoI=; b=bvkQkDhf5Z6m4+cWAcOeOV9wSsLYbWUxK8l03Dl9JOiC0jE9eo3C9W5l8UUysStpj7 oBpS8QgjqEndDMMViafy01zU+Q+I2UCTLjx1Bx7YOj/B7SsUzcI2s1PaZZ6/RpZii5jV bHT9YeqphYfLmXlR44CzIB77Qf4LCMkWd/aMUpZ4oTN51AFMcpIHShhsY7+5lb8oDlKc hZg31AYYMyhfYSRMga60mLbIwXHNoxbR0y838a42YGVtCNyruAWq2fNrLy3OfSd6rtpt tqSSI3RHzgEdBB3o+oScP4s+KD9JaT7t2R8/vVevjPx77PEssNT3RAqFaFwTjj4HVej9 RjDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="vPNq5+n/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020a056402440300b004437a9fcc07si2350642eda.361.2022.08.23.02.58.37; Tue, 23 Aug 2022 02:59:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="vPNq5+n/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244942AbiHWJot (ORCPT + 99 others); Tue, 23 Aug 2022 05:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352388AbiHWJlR (ORCPT ); Tue, 23 Aug 2022 05:41:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 875DC99246; Tue, 23 Aug 2022 01:42:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7AA1EB81C4A; Tue, 23 Aug 2022 08:41:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1FABC433D6; Tue, 23 Aug 2022 08:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244090; bh=2lB3I7+8Hem0I6Ax5aso+WvIIZirR+UtJ+Zd6sfcEwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vPNq5+n/VhdYNY/eIToOWc/rM3zwWJdnr/oySACxPsSjm3kvkEGiOIQNSccx1KMfJ 6WuAkoQCpaipEdU+qDosPKHtFx2UuAq6r1x3I/Je4g1WD/47dgAoINY1lUFvzmSWhq k37I0N2dIOFEqCQk2PH/5nxPup0ov5ERbcnl4Vcs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiu Jianfeng , John Johansen Subject: [PATCH 5.15 035/244] apparmor: Fix memleak in aa_simple_write_to_buffer() Date: Tue, 23 Aug 2022 10:23:14 +0200 Message-Id: <20220823080100.240361186@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiu Jianfeng commit 417ea9fe972d2654a268ad66e89c8fcae67017c3 upstream. When copy_from_user failed, the memory is freed by kvfree. however the management struct and data blob are allocated independently, so only kvfree(data) cause a memleak issue here. Use aa_put_loaddata(data) to fix this issue. Fixes: a6a52579e52b5 ("apparmor: split load data into management struct and data blob") Signed-off-by: Xiu Jianfeng Signed-off-by: John Johansen Signed-off-by: Greg Kroah-Hartman --- security/apparmor/apparmorfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -401,7 +401,7 @@ static struct aa_loaddata *aa_simple_wri data->size = copy_size; if (copy_from_user(data->data, userbuf, copy_size)) { - kvfree(data); + aa_put_loaddata(data); return ERR_PTR(-EFAULT); }