From patchwork Wed Jun 21 10:16:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 694864 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D63AEB64D8 for ; Wed, 21 Jun 2023 10:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231356AbjFUKQe (ORCPT ); Wed, 21 Jun 2023 06:16:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231913AbjFUKQ2 (ORCPT ); Wed, 21 Jun 2023 06:16:28 -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 48D1D19A5; Wed, 21 Jun 2023 03:16:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D44CC614F0; Wed, 21 Jun 2023 10:16:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B9B5C433C9; Wed, 21 Jun 2023 10:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687342576; bh=11Ude6JWACvWtTFWg1oYhYS4qyMJAJHJEtjni1SdwG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L4ehPnHa0tzB431PC0EfNwXOcvrf9ZsVu+rkYydgiyxbVAejq9Tx4MfIKKYhTyObi tCy4u3+GbFrAnDTJ1TkylxNydlgzbBpsysgR6zJ7V3oBssbFSjkyJHVsS4Mb/My9cA +KW+6wqMsUwt00ViS+3qz7qkrfACZJwKnMMz2lzVsTJSzCBn078vAKzKgvzznpNN0+ TcLFNxA1vT96J/I8laUCKty1YdXXb86nq6a9oYhL/kPw+lhvYXjEztSv6EwNhSH+Mk cQyesvIYgf2d4egMUbSJBf5Hkd7Ih09GmVmydrIxP0dcw0P29nLJzt+UgjnAX6xpKK AFuWH5GIUN8dQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 1/6] tty_audit: use TASK_COMM_LEN for task comm Date: Wed, 21 Jun 2023 12:16:06 +0200 Message-ID: <20230621101611.10580-2-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621101611.10580-1-jirislaby@kernel.org> References: <20230621101611.10580-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org This is the preferred way of declaring an array for get_task_comm(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index ca7afd7b2716..b98b1aef5f6f 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -69,7 +69,7 @@ static void tty_audit_log(const char *description, dev_t dev, ab = audit_log_start(audit_context(), GFP_KERNEL, AUDIT_TTY); if (ab) { - char name[sizeof(current->comm)]; + char name[TASK_COMM_LEN]; audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u major=%d" " minor=%d comm=", description, pid, uid, From patchwork Wed Jun 21 10:16:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 696176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D960CEB64D7 for ; Wed, 21 Jun 2023 10:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231803AbjFUKQd (ORCPT ); Wed, 21 Jun 2023 06:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbjFUKQ2 (ORCPT ); Wed, 21 Jun 2023 06:16:28 -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 C729719AE; Wed, 21 Jun 2023 03:16:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5F0FF614F8; Wed, 21 Jun 2023 10:16:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B563BC433CB; Wed, 21 Jun 2023 10:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687342577; bh=t0EF3q3/QR/P6ZCvJ8zNTv13i5zjB/3psPexq7LNhgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FKdIbAfL+30GDkJK5lShtthDH94/jUwHsIyZyji61PqbfxKSGZ9gEpVmvBcefKzCf +0M5U2qsIFsqBjzZg9QHVqU/6uBLLStfsqkwZQbSdqhHZTzrIQjRDNCbf2G7mJR7Km fd35CGiV4o4LAw/v4KVklqf7c9Xs+iEgOjQMuYmO759KLOAG8DBTUzqKLoTXpilFJz WadX/NX9FqNFsEIlBtZaz/woCZM3E2xzO2FDRjfW1BNTmB/VYwmiSG+/BOE0w67ohA bE3HMWg7xf+DCVdpwytGpyljGxxwWvopdpQzM1jVlpzH2iL4dpopHs+S2SuVAkHxBm wEuER1NSMz8xw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 2/6] tty_audit: use kzalloc() in tty_audit_buf_alloc() Date: Wed, 21 Jun 2023 12:16:07 +0200 Message-ID: <20230621101611.10580-3-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621101611.10580-1-jirislaby@kernel.org> References: <20230621101611.10580-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org tty_audit_buf_alloc() manually erases most of the entries after kmalloc(). So use kzalloc() and remove the manual sets to zero. That way, we are sure that we do not omit anything. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_audit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index b98b1aef5f6f..43f34465b9df 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -33,16 +33,16 @@ static struct tty_audit_buf *tty_audit_buf_alloc(void) { struct tty_audit_buf *buf; - buf = kmalloc(sizeof(*buf), GFP_KERNEL); + buf = kzalloc(sizeof(*buf), GFP_KERNEL); if (!buf) goto err; + buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL); if (!buf->data) goto err_buf; + mutex_init(&buf->mutex); - buf->dev = MKDEV(0, 0); - buf->icanon = 0; - buf->valid = 0; + return buf; err_buf: From patchwork Wed Jun 21 10:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 694863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A96B2EB64DC for ; Wed, 21 Jun 2023 10:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbjFUKQf (ORCPT ); Wed, 21 Jun 2023 06:16:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbjFUKQa (ORCPT ); Wed, 21 Jun 2023 06:16:30 -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 5936519B6; Wed, 21 Jun 2023 03:16:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE374614F7; Wed, 21 Jun 2023 10:16:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4068DC433C9; Wed, 21 Jun 2023 10:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687342579; bh=fI73SiBO6xUlZ6yV48DEr6cjU7NZbUlp7BYYrDl0vJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tb4AeXeCjM4ZKM2XUG2d8z1OEeVQ1xnZlhY05Q0tcBoMi34DP3HWvrQjdJT5daLrP o5ffbra6/Fu1YC+4/12840hYNfZCBTp/8nqI4VOUwnAcgFLn0lwEXbIJ6rAOTdTPpg 3oA2tpJ0C1ebFLaR+sdaupVtXzKreRTk82ZyUrdHLstb1zsY5skriBYwaTFyRHyQk5 X5ajMTk3OJIxe70WpKOONlkcpE6dMSEFjaJJ6yCmClIS4fwsql3PIM6aIC64eT2bRa CtNXkMZoIgDY1osi7JPNAU0XW7l/Y33aHHDZAO9R2HVhHDr9IYuXr6iYCT+gOwI1bL mIHw+sZhLFnsA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 3/6] tty_audit: invert the condition in tty_audit_log() Date: Wed, 21 Jun 2023 12:16:08 +0200 Message-ID: <20230621101611.10580-4-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621101611.10580-1-jirislaby@kernel.org> References: <20230621101611.10580-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org If we cannot obtain an audit buffer in tty_audit_log(), simply return from the function. Apart this is mostly preferred in the kernel, it allows to merge the split audit string while still keeping it readable. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_audit.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index 43f34465b9df..c6c27acad2ad 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -66,20 +66,20 @@ static void tty_audit_log(const char *description, dev_t dev, uid_t uid = from_kuid(&init_user_ns, task_uid(current)); uid_t loginuid = from_kuid(&init_user_ns, audit_get_loginuid(current)); unsigned int sessionid = audit_get_sessionid(current); + char name[TASK_COMM_LEN]; ab = audit_log_start(audit_context(), GFP_KERNEL, AUDIT_TTY); - if (ab) { - char name[TASK_COMM_LEN]; - - audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u major=%d" - " minor=%d comm=", description, pid, uid, - loginuid, sessionid, MAJOR(dev), MINOR(dev)); - get_task_comm(name, current); - audit_log_untrustedstring(ab, name); - audit_log_format(ab, " data="); - audit_log_n_hex(ab, data, size); - audit_log_end(ab); - } + if (!ab) + return; + + audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u major=%d minor=%d comm=", + description, pid, uid, loginuid, sessionid, + MAJOR(dev), MINOR(dev)); + get_task_comm(name, current); + audit_log_untrustedstring(ab, name); + audit_log_format(ab, " data="); + audit_log_n_hex(ab, data, size); + audit_log_end(ab); } /* From patchwork Wed Jun 21 10:16:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 696174 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9051AEB64DC for ; Wed, 21 Jun 2023 10:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231750AbjFUKQj (ORCPT ); Wed, 21 Jun 2023 06:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbjFUKQc (ORCPT ); Wed, 21 Jun 2023 06:16:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCE9C19BF; Wed, 21 Jun 2023 03:16:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6887A614D8; Wed, 21 Jun 2023 10:16:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF978C433CB; Wed, 21 Jun 2023 10:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687342580; bh=DBc50eolmnp7GyiCEV1ZK/Q/T32LP3koeS8WDoxsOIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SfRPYbc0nGO2Dzu3+KWemjFHN166/ezCgHVX1MIYCqACkmzgTQXgrnf9ZZMaVVUPF ugcEzePpMTtKKG90sNQEE+Xsnw9sqVVGwKiXz2ntFFQnYEiE8zX8pN5672xDAmK8Nd siSn4bOVncIMEOgsXUMMH++jz/9P2EXuw6ClzOd1R2GHKqDCQJVRpUtzU1YdYGLmPn ikKQ6JixHqH960T671T08WJqC/RFbItdHGSy8nar9jUC3Krinur3FC6J6xhAUVZw8e w9G6y4GIytBGfjC0K4EuK+wVvNYB08x/Rl8gNV22E4JPpc88iijGr6MYuHEhQPLL40 0iHHzv4gy+A8g== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 4/6] tty_audit: make icanon a bool Date: Wed, 21 Jun 2023 12:16:09 +0200 Message-ID: <20230621101611.10580-5-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621101611.10580-1-jirislaby@kernel.org> References: <20230621101611.10580-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Use bool for tty_audit_buf::icanon in favor of ugly bitfields. And get rid of "!!" as that is completely unnecessary. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_audit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index c6c27acad2ad..6cf8b63368ee 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -15,7 +15,7 @@ struct tty_audit_buf { struct mutex mutex; /* Protects all data below */ dev_t dev; /* The TTY which the data is from */ - unsigned icanon:1; + bool icanon; size_t valid; unsigned char *data; /* Allocated size N_TTY_BUF_SIZE */ }; @@ -202,8 +202,8 @@ static struct tty_audit_buf *tty_audit_buf_get(void) void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size) { struct tty_audit_buf *buf; - unsigned int icanon = !!L_ICANON(tty); unsigned int audit_tty; + bool icanon = L_ICANON(tty); dev_t dev; audit_tty = READ_ONCE(current->signal->audit_tty); From patchwork Wed Jun 21 10:16:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 696175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99393EB64D7 for ; Wed, 21 Jun 2023 10:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbjFUKQh (ORCPT ); Wed, 21 Jun 2023 06:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231294AbjFUKQe (ORCPT ); Wed, 21 Jun 2023 06:16:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE48110F0; Wed, 21 Jun 2023 03:16:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E875C614FD; Wed, 21 Jun 2023 10:16:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AAD9C433C0; Wed, 21 Jun 2023 10:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687342582; bh=zHSBUMeolRXKfp/Yo8BVUgIz5T+GFyJ1SF9F8vHu5rs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUYS/39wW7sKEek9iEIIAK6FKAd6KmceDePeyBw/4UMyJ4lZiqtFejDQl8pxKiI0+ G4dXkys30iWiJA5kwxqr0g8zFF877MdTsLWMKxDvOSmAQiWLQSZauO068wwSO7ZFYq bRT2gwy0zFsD1Z2yW1TDStKZYGLSJocvQdYwsC8zVLHLzvbg7NaPmLhy8Lg01Z3wbA Rxb/Iki/3Cg4t/RZKn1ZK0fgR02O/ZXhaFO3A/bnfkLdoSsGxik7SqWyDyRJP1j/82 82ZRXEr27Z/GSAYObiQMu/7SgszTwTYeRKdM/PatpBPO7HxQE5YhNTrvPpBls505En zn29bQsuQkV0w== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 5/6] tty_audit: make tty pointers in exposed functions const Date: Wed, 21 Jun 2023 12:16:10 +0200 Message-ID: <20230621101611.10580-6-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621101611.10580-1-jirislaby@kernel.org> References: <20230621101611.10580-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Both tty_audit_add_data() and tty_audit_tiocsti() need only to read from the tty struct, so make the tty parameters of them both const. This aids the compiler a bit. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty.h | 11 ++++++----- drivers/tty/tty_audit.c | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h index 1e0d80e98d26..89769a1f1f97 100644 --- a/drivers/tty/tty.h +++ b/drivers/tty/tty.h @@ -99,14 +99,15 @@ extern int tty_ldisc_autoload; /* tty_audit.c */ #ifdef CONFIG_AUDIT -void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size); -void tty_audit_tiocsti(struct tty_struct *tty, char ch); +void tty_audit_add_data(const struct tty_struct *tty, const void *data, + size_t size); +void tty_audit_tiocsti(const struct tty_struct *tty, char ch); #else -static inline void tty_audit_add_data(struct tty_struct *tty, const void *data, - size_t size) +static inline void tty_audit_add_data(const struct tty_struct *tty, + const void *data, size_t size) { } -static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch) +static inline void tty_audit_tiocsti(const struct tty_struct *tty, char ch) { } #endif diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index 6cf8b63368ee..5cbe28ac1763 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -134,7 +134,7 @@ void tty_audit_fork(struct signal_struct *sig) /* * tty_audit_tiocsti - Log TIOCSTI */ -void tty_audit_tiocsti(struct tty_struct *tty, char ch) +void tty_audit_tiocsti(const struct tty_struct *tty, char ch) { dev_t dev; @@ -199,7 +199,8 @@ static struct tty_audit_buf *tty_audit_buf_get(void) * * Audit @data of @size from @tty, if necessary. */ -void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size) +void tty_audit_add_data(const struct tty_struct *tty, const void *data, + size_t size) { struct tty_audit_buf *buf; unsigned int audit_tty; From patchwork Wed Jun 21 10:16:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 694862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA17BEB64DD for ; Wed, 21 Jun 2023 10:16:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231736AbjFUKQh (ORCPT ); Wed, 21 Jun 2023 06:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231313AbjFUKQe (ORCPT ); Wed, 21 Jun 2023 06:16:34 -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 04C0610FF; Wed, 21 Jun 2023 03:16:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 78E57614FB; Wed, 21 Jun 2023 10:16:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9E68C433CA; Wed, 21 Jun 2023 10:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687342583; bh=hjwp7ItGmHIggbX9Pd6LvtVbXVqDEOR8otZ+Y4JaTu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uNvkdiF4FusRU1x/rqIMyQ2ujF5y1MPWfSO9o0oEqlpV0XUXUd37+A9SraY/aNTFr UOsxhdWmZuFgvnpDmWEEtW3IiMSzN906hBDGtvwYfQJk9CBG+Px7x1F97Sk0WDKAEp IKCfdLkf9BWKD4QlK5rIJf+0dsrApspERH7kXbeJ0ng4U/e5oBSR3EByiGZ406B53c ac0+whiE4mwjcHuUVqrolEX4d+RTaUqC8JL8qmcunl+hfMX3W8M5r0DKvBEbdmrI8P yGnKKTbEeMx+2aVTKCkVHleHi6xrw1eidMXnsV4Cda+hNE80MBvATXhgR5cyjKisr+ seiJ0y1csL0CA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 6/6] tty_audit: make data of tty_audit_log() const Date: Wed, 21 Jun 2023 12:16:11 +0200 Message-ID: <20230621101611.10580-7-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621101611.10580-1-jirislaby@kernel.org> References: <20230621101611.10580-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 'data' are only read (passed down to audit_log_n_hex()), so they can be const -- the same what is expected in audit_log_n_hex(). Only a minor cleanup to be consistent. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index 5cbe28ac1763..24d010589379 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -59,7 +59,7 @@ static void tty_audit_buf_free(struct tty_audit_buf *buf) } static void tty_audit_log(const char *description, dev_t dev, - unsigned char *data, size_t size) + const unsigned char *data, size_t size) { struct audit_buffer *ab; pid_t pid = task_pid_nr(current);