From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id D01E6298A8 for ; Sat, 1 Jun 2024 04:34:21 +0200 (CEST) Received: (qmail 7753 invoked by uid 550); 1 Jun 2024 02:34:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7715 invoked from network); 1 Jun 2024 02:34:14 -0000 Date: Fri, 31 May 2024 22:34:30 -0400 From: Rich Felker To: Ismael Luceno Cc: musl@lists.openwall.com Message-ID: <20240601023429.GJ10433@brightrain.aerifal.cx> References: <20240601010328.27409-1-ismael@iodev.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240601010328.27409-1-ismael@iodev.co.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] ioctl: Fix implicit constant conversion overflow On Sat, Jun 01, 2024 at 03:03:25AM +0200, Ismael Luceno wrote: > The last parameter (result of sizeof) to _IOC in _IOR/_IOW/_IOWR causes > the underlying expression's value to be promoted to size_t. Casting it > to int resolves the issue. > > Signed-off-by: Ismael Luceno > --- > arch/generic/bits/ioctl.h | 6 +++--- > arch/mips/bits/ioctl.h | 6 +++--- > arch/mipsn32/bits/ioctl.h | 6 +++--- > arch/powerpc/bits/ioctl.h | 6 +++--- > arch/powerpc64/bits/ioctl.h | 6 +++--- > arch/sh/bits/ioctl.h | 6 +++--- > 6 files changed, 18 insertions(+), 18 deletions(-) > > diff --git a/arch/generic/bits/ioctl.h b/arch/generic/bits/ioctl.h > index 60ae8b850b17..16541d547f68 100644 > --- a/arch/generic/bits/ioctl.h > +++ b/arch/generic/bits/ioctl.h > @@ -4,9 +4,9 @@ > #define _IOC_READ 2U > > #define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0) > -#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c)) > -#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c)) > -#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c)) > +#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),(int)sizeof(c)) > +#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),(int)sizeof(c)) > +#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),(int)sizeof(c)) I don't see how this helps with the warning you're trying to suppress, since _IOC_{READ,WRITE} already have unsigned type. If you changed that, you would then have *real overflows* (undefined behavior) instead of the well-defined, valid implicit conversions -Werror is complaining about. There may be a way to improve on the situation here but it's not so simple. Rich