Message ID | 20240203233600.gu4qci36fpnro3ui@begin |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-51322-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp119276dyb; Sat, 3 Feb 2024 15:36:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMBWy0gxFc3sPaa6+PN71xtu09cwQ+xRgVQhOYSNWDJx7B3leMZ3w0f7FBUiwqX/VllEp3 X-Received: by 2002:a17:906:5941:b0:a36:917f:5562 with SMTP id g1-20020a170906594100b00a36917f5562mr6573295ejr.15.1707003393223; Sat, 03 Feb 2024 15:36:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707003393; cv=pass; d=google.com; s=arc-20160816; b=JWODJ8VMOtmo9kINX4uEwITtsGLrRJnmCDkNsmMrmZ37olwXwipknrHXI4xxPtAJIG xT3Ya+AVzevZ1rwZ0V6hk1qNtszZe6SFCNmmLojusZY3oCM9U/BLWgJWpdbMTB9pPMWu GPP0dqSB5+4Um5HcwvQ/XCQyns/uTmMwOMYg3irii8PN+GESxuW0kOjzAv9vrJVTsHXS iN4EMHy3OL3QanP7BiXM3MrwB21yZqUHbPtEz9Hfgk13FIPBrFhSJb6LXsGzSB54i4lK 9yd3NF9HJfr1daYUvoTw6doBWEXkuX8UbEUKRlhlNChxCdzyxekeFpYkdlpnYg8HZ4gb /AdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:mail-followup-to:message-id :subject:cc:to:from:date; bh=HhklRYFP9TbWGTzkzsFa7wRnWGEGgzpg/gENcA/90IQ=; fh=qiMdhcIhnCB5ivCc51qQprysQGH4bKA2/3anSUgwIKY=; b=hBxwWc24WDvqqKoKQcagV1dlf/U8BcfeH51clneYtV7wHVz4wNRXxP/L4UIObLpPg2 0/YDJfZZ0nEzmtAsbZthdquNRa+uUwaREhX2nfCGr/vmEd3cXsUt5AHVugHC80sK103T pbYwAOlFNsj+BxYVl3dA6G9NyA405WsjHxKy5e0wusW2STMSg8fsJZFSnHZjLSsCQAvD 6UPg2l4RNJFbmwOF/o6XPR6eaZpQNtRxvaAu/sgiLTeLadhG4jRTQeWjcH0vOL2nShYn A+CpBK39nNVtW79S0JeKjuThI8yv8rMp9nytDdNfF2tYwfb7+8DQP2Zbpmfw9DR3CvAw O6Ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=bounce.ens-lyon.org); spf=pass (google.com: domain of linux-kernel+bounces-51322-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51322-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXJ9k5tO/mtmSg0bonpyciMRo7scVi0uK8MB/wGb99jGlAAkGDGD0qdsBk7z/kaCFeiLncah8ynTl88cJVDYEb0KnD3OA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w18-20020a170906131200b00a376758d1eesi682541ejb.702.2024.02.03.15.36.32 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 15:36:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51322-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=bounce.ens-lyon.org); spf=pass (google.com: domain of linux-kernel+bounces-51322-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51322-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 376421F23DC4 for <ouuuleilei@gmail.com>; Sat, 3 Feb 2024 23:36:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BF2E171C1; Sat, 3 Feb 2024 23:36:07 +0000 (UTC) Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF6E01640B for <linux-kernel@vger.kernel.org>; Sat, 3 Feb 2024 23:36:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707003366; cv=none; b=iQENOG+J74VvqZZlqZIBj3YecEm8qRt8GEHczpOhmL/OglyvTOlbjYQTc0HZkcwT9SvM/7gC3b36cb/IXjiIFIEO3DYHlJLRstiJ5YfJ6oO+6iczk3PVopE4wX2OoY5Co9yfV3ULJCFMQ7k/Bgu0bWvd1WBtnSmdX37g1Azu15c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707003366; c=relaxed/simple; bh=9QAMVE7vIgYbhc9zYIQ6LwGCGWiggyyOA9kPhC2rVTc=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=L18mWVJUjiFSWVYniN8OQSzha64dDYqoXH3nBG6+U9f7X5YdEU7vFBraASYMDIv7FCL3w6M9uUA3s1wQJllZ+/Uj2j5XqPugqX35+E6sYupVmXM+XK9v0LF5YgX8NJQSB2EBDv2XD1q+Sr1ftL6f7mr35LJ7POlrOljboZ8n2aE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org; arc=none smtp.client-ip=140.77.166.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 3E888A0317; Sun, 4 Feb 2024 00:36:01 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d_HqECJQ4n_A; Sun, 4 Feb 2024 00:36:01 +0100 (CET) Received: from begin (aamiens-653-1-111-57.w83-192.abo.wanadoo.fr [83.192.234.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id B1A99A022B; Sun, 4 Feb 2024 00:36:00 +0100 (CET) Received: from samy by begin with local (Exim 4.97) (envelope-from <samuel.thibault@ens-lyon.org>) id 1rWPYG-00000003Vbv-0tIp; Sun, 04 Feb 2024 00:36:00 +0100 Date: Sun, 4 Feb 2024 00:36:00 +0100 From: Samuel Thibault <samuel.thibault@ens-lyon.org> To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, speakup@linux-speakup.org Subject: [PATCH] speakup: Fix 8bit characters from direct synth Message-ID: <20240203233600.gu4qci36fpnro3ui@begin> Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, speakup@linux-speakup.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170609 (1.8.3) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789922789847465744 X-GMAIL-MSGID: 1789922789847465744 |
Series |
speakup: Fix 8bit characters from direct synth
|
|
Commit Message
Samuel Thibault
Feb. 3, 2024, 11:36 p.m. UTC
When userland echoes 8bit characters to /dev/synth with e.g.
echo -e '\xe9' > /dev/synth
synth_write would get characters beyond 0x7f, and thus negative when
char is signed. When given to synth_buffer_add which takes a u16, this
would sign-extend and produce a U+ffxy character rather than U+xy.
Users thus get garbled text instead of accents in their output.
Let's fix this by making sure that we read unsigned characters.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Fixes: 89fc2ae80bb1 ("speakup: extend synth buffer to 16bit unicode characters")
Cc: stable@vger.kernel.org
---
drivers/accessibility/speakup/synth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Sun, Feb 04, 2024 at 12:36:00AM +0100, Samuel Thibault wrote: > When userland echoes 8bit characters to /dev/synth with e.g. > > echo -e '\xe9' > /dev/synth > > synth_write would get characters beyond 0x7f, and thus negative when > char is signed. When given to synth_buffer_add which takes a u16, this > would sign-extend and produce a U+ffxy character rather than U+xy. > Users thus get garbled text instead of accents in their output. > > Let's fix this by making sure that we read unsigned characters. > > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> > Fixes: 89fc2ae80bb1 ("speakup: extend synth buffer to 16bit unicode characters") > Cc: stable@vger.kernel.org > > --- > drivers/accessibility/speakup/synth.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > --- a/drivers/accessibility/speakup/synth.c > +++ b/drivers/accessibility/speakup/synth.c > @@ -208,8 +208,9 @@ void spk_do_flush(void) > wake_up_process(speakup_task); > } > > -void synth_write(const char *buf, size_t count) > +void synth_write(const char *_buf, size_t count) > { > + const unsigned char *buf = (const unsigned char *) _buf; > while (count--) > synth_buffer_add(*buf++); > synth_start(); Nit, I think you need a blank line after the new variable definition. And why can't we just change these to be u8 instead of "char"? Wouldn't that solve this issue overall better? We made much the same type of changes to the tty layer recently. thanks, greg k-h
Greg KH, le sam. 03 févr. 2024 16:03:20 -0800, a ecrit: > On Sun, Feb 04, 2024 at 12:36:00AM +0100, Samuel Thibault wrote: > > When userland echoes 8bit characters to /dev/synth with e.g. > > > > echo -e '\xe9' > /dev/synth > > > > synth_write would get characters beyond 0x7f, and thus negative when > > char is signed. When given to synth_buffer_add which takes a u16, this > > would sign-extend and produce a U+ffxy character rather than U+xy. > > Users thus get garbled text instead of accents in their output. > > > > Let's fix this by making sure that we read unsigned characters. > > > > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> > > Fixes: 89fc2ae80bb1 ("speakup: extend synth buffer to 16bit unicode characters") > > Cc: stable@vger.kernel.org > > > > --- > > drivers/accessibility/speakup/synth.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > --- a/drivers/accessibility/speakup/synth.c > > +++ b/drivers/accessibility/speakup/synth.c > > @@ -208,8 +208,9 @@ void spk_do_flush(void) > > wake_up_process(speakup_task); > > } > > > > -void synth_write(const char *buf, size_t count) > > +void synth_write(const char *_buf, size_t count) > > { > > + const unsigned char *buf = (const unsigned char *) _buf; > > while (count--) > > synth_buffer_add(*buf++); > > synth_start(); > > Nit, I think you need a blank line after the new variable definition. Ok. > And why can't we just change these to be u8 instead of "char"? Wouldn't > that solve this issue overall better? I was wondering, but an example of caller is synth_direct_store, which calls string_unescape_any_inplace on the buffer, which does take a char* and I guess won't change. Samuel
--- a/drivers/accessibility/speakup/synth.c +++ b/drivers/accessibility/speakup/synth.c @@ -208,8 +208,9 @@ void spk_do_flush(void) wake_up_process(speakup_task); } -void synth_write(const char *buf, size_t count) +void synth_write(const char *_buf, size_t count) { + const unsigned char *buf = (const unsigned char *) _buf; while (count--) synth_buffer_add(*buf++); synth_start();