lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <80285a1a-f15d-1c21-b907-55e47a44d08e@marcan.st>
Date:   Tue, 28 Mar 2023 19:59:53 +0900
From:   Hector Martin <marcan@...can.st>
To:     Martin Povišer <povik+lin@...ebit.org>,
        Sven Peter <sven@...npeter.dev>
Cc:     Alyssa Rosenzweig <alyssa@...enzweig.io>, asahi@...ts.linux.dev,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] soc: apple: rtkit: Crop syslog messages

On 25/02/2023 01.21, Martin Povišer wrote:
> Crop trailing whitespace, null, and newline characters in syslog
> messages received from coprocessors. Notably DCP sends its messages
> including a trailing newline, so prior to this change we would end up
> cluttering the kernel log by repeated newlines at the end of messages.
> 
> Signed-off-by: Martin Povišer <povik+lin@...ebit.org>
> ---
>  drivers/soc/apple/rtkit.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c
> index 35ec35aa500d..639f5134d159 100644
> --- a/drivers/soc/apple/rtkit.c
> +++ b/drivers/soc/apple/rtkit.c
> @@ -409,11 +409,17 @@ static void apple_rtkit_syslog_rx_init(struct apple_rtkit *rtk, u64 msg)
>  		rtk->syslog_n_entries, rtk->syslog_msg_size);
>  }
>  
> +static bool should_crop_syslog_char(char c)
> +{
> +	return c == '\n' || c == '\r' || c == ' ' || c == '\0';
> +}
> +
>  static void apple_rtkit_syslog_rx_log(struct apple_rtkit *rtk, u64 msg)
>  {
>  	u8 idx = msg & 0xff;
>  	char log_context[24];
>  	size_t entry_size = 0x20 + rtk->syslog_msg_size;
> +	int msglen;
>  
>  	if (!rtk->syslog_msg_buffer) {
>  		dev_warn(
> @@ -446,7 +452,13 @@ static void apple_rtkit_syslog_rx_log(struct apple_rtkit *rtk, u64 msg)
>  			   rtk->syslog_msg_size);
>  
>  	log_context[sizeof(log_context) - 1] = 0;
> -	rtk->syslog_msg_buffer[rtk->syslog_msg_size - 1] = 0;
> +
> +	msglen = rtk->syslog_msg_size - 1;
> +	while (msglen > 0 &&
> +		   should_crop_syslog_char(rtk->syslog_msg_buffer[msglen - 1]))
> +		msglen--;
> +
> +	rtk->syslog_msg_buffer[msglen] = 0;
>  	dev_info(rtk->dev, "RTKit: syslog message: %s: %s\n", log_context,
>  		 rtk->syslog_msg_buffer);
>  

Reviewed-by: Hector Martin <marcan@...can.st>

Thanks, applied to asahi-soc/soc!

- Hector

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ