From patchwork Sat Oct 22 07:21:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1092153wrr; Sat, 22 Oct 2022 00:53:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67u4n/5DQsEccjVWFeNsiPBRAAYHTvSmWfE7MU0ddt2MWnH8KXXsLBP+xdwi8yLqlo1vfO X-Received: by 2002:a17:90a:bf11:b0:211:84c5:42d7 with SMTP id c17-20020a17090abf1100b0021184c542d7mr15151149pjs.122.1666425191901; Sat, 22 Oct 2022 00:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425191; cv=none; d=google.com; s=arc-20160816; b=Oc8wF3tMQrIBEweaLAjyK+Os9d6Dfgs9ez3Na0MngD1Lao3iuILxItCDI66DkUU5wv fPF6viu5cG7hOhh4Qlr8z6nFYv5jjvgvbnyyfTyVSYH0jBDtesuhIZC2wovs+stUHD5N Jw9XW9f24TnIP3vil7nxGMTnnAUVCnwGpwO+uBY/ZSbuwRpIlKVpGZxqiuX3gy1Hjcii QSzcqaQDy9oE/0qu+QvDCwVKH7DJIvuVV5pMpWLUFfDC/cvndk9wcz4fETP75uk7ELuS 4PUgceEeJ1t2S/cVov2+sFAB/99zyXNdb05c9XjIi/tL4gfDUZwWinUUmvGqJDmh1aPA U0bw== 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=So7yaurPMCSI/cLYOrEIqs0d6Tuxy3mZMVHO8TjH4CU=; b=UAlr8/DizjnNMhc2gjJxqk0dGkCZloSdrqzHS+pCC/ZtWHLPznVeQ5X9ABtjSN+jnP h0DWGdFDHDh9B4Hl3uVTsyoQ7MxDHAZ+8FOLZXZ5Kf0jCdiju3oaO8cjN+1wLQ67uujl i7Epj/vj6lJPJbNVRErY5DN0Y8IPIMQBrDuHEoGWfel4Sb6jus6+Jzo6/mxsR8sWIumC ZCmiU1ewYZf70toX565eXIxLPysjdQF+Hh/82IwESTi6lEzfEpAo7UwgSlWV0sDbKP4l EFd9/piBeZiOc8bZKH1QKmbccmRgl7bEgdRsiHpng8k0jCbtmo/5qW9gUFniUO4NFBV0 y+eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BTvD6MVn; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a632341000000b0043aebb63fc6si29170692pgm.81.2022.10.22.00.52.58; Sat, 22 Oct 2022 00:53:11 -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=BTvD6MVn; 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 S231814AbiJVHwm (ORCPT + 99 others); Sat, 22 Oct 2022 03:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231947AbiJVHtl (ORCPT ); Sat, 22 Oct 2022 03:49:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6E8B2C2ADD; Sat, 22 Oct 2022 00:46:23 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 472CD60B4A; Sat, 22 Oct 2022 07:43:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 581ACC433D7; Sat, 22 Oct 2022 07:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424613; bh=lRLnCd09qU2Pnvqe8b6Dy8rpdc/eTMoFLE3OYWFRwVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BTvD6MVnHvgXAfVpJmNCkGIqjRTckiI5JCurOJDn++ec5SbsJLhvVNJevtijf7jhQ 5HGOUrcpCpgFg2vFEop1E3dA2NjC8FB8P3zUh598EOH+7j2hxV12EN08a0dVnXvozh gYEmFrd/3Mut9pG3669kzs0ppuCu2IoGCqREVMUE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Guy Briggs , Paul Moore , Sasha Levin Subject: [PATCH 5.19 212/717] audit: free audit_proctitle only on task exit Date: Sat, 22 Oct 2022 09:21:31 +0200 Message-Id: <20221022072452.771100731@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747373461613136471?= X-GMAIL-MSGID: =?utf-8?q?1747373461613136471?= From: Richard Guy Briggs [ Upstream commit c3f3ea8af44d0c5fba79fe8b198087342d0c7e04 ] Since audit_proctitle is generated at syscall exit time, its value is used immediately and cached for the next syscall. Since this is the case, then only clear it at task exit time. Otherwise, there is no point in caching the value OR bearing the overhead of regenerating it. Fixes: 12c5e81d3fd0 ("audit: prepare audit_context for use in calling contexts beyond syscalls") Signed-off-by: Richard Guy Briggs Signed-off-by: Paul Moore Signed-off-by: Sasha Levin --- kernel/auditsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 65d816cda5df..73121c0185ce 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -1016,7 +1016,6 @@ static void audit_reset_context(struct audit_context *ctx) WARN_ON(!list_empty(&ctx->killed_trees)); audit_free_module(ctx); ctx->fds[0] = -1; - audit_proctitle_free(ctx); ctx->type = 0; /* reset last for audit_free_*() */ } @@ -1102,6 +1101,7 @@ static inline void audit_free_context(struct audit_context *context) { /* resetting is extra work, but it is likely just noise */ audit_reset_context(context); + audit_proctitle_free(context); free_tree_refs(context); kfree(context->filterkey); kfree(context);