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] [thread-next>] [day] [month] [year] [list]
Message-Id: <1A568R.RVXRB53P9YYQ1@crapouillou.net>
Date:   Thu, 03 Mar 2022 12:27:37 +0000
From:   Paul Cercueil <paul@...pouillou.net>
To:     David Laight <David.Laight@...LAB.COM>
Cc:     "'Maciej W. Rozycki'" <macro@...am.me.uk>,
        Jiri Slaby <jslaby@...e.cz>,
        'Uwe Kleine-König' 
        <u.kleine-koenig@...gutronix.de>, gregkh@...uxfoundation.org,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Mateusz Holenko <mholenko@...micro.com>,
        Neil Armstrong <narmstrong@...libre.com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Liviu Dudau <liviu.dudau@....com>,
        Baruch Siach <baruch@...s.co.il>, linux-kernel@...r.kernel.org,
        Paul Mackerras <paulus@...ba.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Michal Simek <michal.simek@...inx.com>,
        Karol Gugala <kgugala@...micro.com>,
        Jerome Brunet <jbrunet@...libre.com>,
        Peter Korsgaard <peter@...sgaard.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Alexander Shiyan <shc_work@...l.ru>,
        Krzysztof Kozlowski <krzysztof.kozlowski@...onical.com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Fabio Estevam <festevam@...il.com>,
        Russell King <linux@...linux.org.uk>,
        Ludovic Desroches <ludovic.desroches@...rochip.com>,
        Andy Gross <agross@...nel.org>,
        bcm-kernel-feedback-list@...adcom.com,
        NXP Linux Team <linux-imx@....com>,
        linux-serial@...r.kernel.org, Vineet Gupta <vgupta@...nel.org>,
        Orson Zhai <orsonzhai@...il.com>,
        Tobias Klauser <tklauser@...tanz.ch>,
        Patrice Chotard <patrice.chotard@...s.st.com>,
        Albert Ou <aou@...s.berkeley.edu>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Manivannan Sadhasivam <mani@...nel.org>,
        Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        Takao Orito <orito.takao@...ionext.com>,
        Vladimir Zapolskiy <vz@...ia.com>,
        Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Sudeep Holla <sudeep.holla@....com>,
        Richard Genoud <richard.genoud@...il.com>,
        Chunyan Zhang <zhang.lyra@...il.com>,
        Nicolas Ferre <nicolas.ferre@...rochip.com>,
        "David S. Miller" <davem@...emloft.net>,
        Taichi Sugaya <sugaya.taichi@...ionext.com>,
        Palmer Dabbelt <palmer@...belt.com>,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        Kevin Hilman <khilman@...libre.com>,
        Baolin Wang <baolin.wang7@...il.com>,
        Shawn Guo <shawnguo@...nel.org>,
        Andreas Färber <afaerber@...e.de>
Subject: RE: [PATCH v3] serial: make uart_console_write->putchar()'s character
 an unsigned char

Hi David,

Le jeu., mars 3 2022 at 11:44:42 +0000, David Laight 
<David.Laight@...LAB.COM> a écrit :
> From: Maciej W. Rozycki
>>  Sent: 03 March 2022 11:31
> ..
>>   It does, but, oh dear, it's a "solution" to a problem we have 
>> created in
>>  the first place.  Why do we ever want to have signed characters in 
>> the TTY
>>  layer, and then to vary between platforms?  It's asking for 
>> portability
>>  issues.
> 
> C 'char' is signed because the pdp/11 byte load sign extended.

That's incorrect. The C standard does say that "the implementation 
shall define char to have the same range, representation, and behavior 
as either signed char or unsigned char".

C 'char' is signed on x86 (and MIPS and Sparc etc.). It is unsigned on 
ARM, PowerPC and Risc-V among others.

> I guess some ABI use unsigned char to avoid issues with all
> the functions that take/return an int parameter that is
> either a 'char' cast to 'unsigned char' or EOF.
> 
> EOF is usually (-1) - but doesn't have to be.
> But it needs to be different from any value obtained
> by casting a 'char' to 'unsigned char'.
> (But that may only need to be all characters, not all values of 
> 'char'.)

Is the putchar() callback ever going to be called with EOF? I don't 
think so.

> Then you get the requirement that:
> 	sizeof (int) >= sizeof (short) >= sizeof (char)
> which means that it is perfectly valid for all 3 to be the same size 
> [1].
> In that case 'unsigned char' promotes to 'unsigned int'
> which probably breaks some code.

We're talking about Linux here. Ints are 32-bit.

Cheers,
-Paul


Powered by blists - more mailing lists