From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7893 invoked from network); 21 Feb 2023 16:05:12 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 21 Feb 2023 16:05:12 -0000 Received: (qmail 26324 invoked by uid 550); 21 Feb 2023 16:05:09 -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 26287 invoked from network); 21 Feb 2023 16:05:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1676995496; i=nullplan@gmx.net; bh=FAFv2athhiZ2ufOoUlaHDs8jiVxJFDuxdU+az3fGj8o=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=LduPQK2HzDffXeqVIf1J71wY3rr6WW4F6kU+2ljPg+7fRVzOqbc5F8h9M0omAXNdD JMz4KHFW4fT4c0kFXp9lh3OauNBq+SLWgLXBWAfMnIARaRAu7LhSHaNUDu83RBOLa3 kAfLJMOeLy68xAwyov6wXYFFURYbZZH3ZcEZQcB7gQheV/NC8x7Q2inND0SvnRYam5 mMSJwkNbI7q/HnbaN/aRwfrJakfaOX8awoTHc4sqMQWhzxltLuAlsZyiTM88cUyo58 NWCy6YNyMRW6iEWEXFSHlwG8nsMb61XV7GKgsUPyPe9d+TfMT1/E/WLyoSsa9r70fp YfgS40TAxJd4g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Date: Tue, 21 Feb 2023 17:04:55 +0100 From: Markus Wichmann To: musl@lists.openwall.com Message-ID: <20230221160455.GF1903@voyager> References: <99826a90-6658-099e-9df8-d0bba78b8f0f@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99826a90-6658-099e-9df8-d0bba78b8f0f@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Provags-ID: V03:K1:lCozl5F27OENXHTIz8Cr2SUSVR51JzmRqFiNhJdlIcExLoUoJSf Jj/sj+zvCW70cu0q7onpMWaC+Lll5Lw8QFGTY+/vPt88WljsrdJP/oEr/S+K6w+iyZ5uInw xA+0JdexuATgHgPPOu6XzMIFvQsbwFJHIQ0XHO4Mo6tl94j1oupXvxcyJnxmzZEIiGyBuIv LiIJ08aBuJhkMU/4t8CXg== UI-OutboundReport: notjunk:1;M01:P0:So0JfI1ABzc=;l08GRTaDKb9QM3s8SYNSn/QqAH2 jDKx+gsw03ObWFG5dcDuUJ4yfhj2hHJqyxdL0X/1dVUe0ryEcNluvOeB8ZKkwMLgAz5TL3u9T rGuQ3bvZISvCUezc+a6XkiYBZcDU92e5y9n7B3JZLUeStUSUdAf81n/hNOXoAZufC0nooskAc 0OKD91B/DAQLDFbijVKqAE+jpCSs9kOtV8Hg6ALclv82bJ9pJriONXqd4JIo00hxMMwbdi+Ig PkdvQOx+O4Q5XXankkXdpFUqnz0mB0RL0Tdq1hRGH56TTgucWQA2ZOVWltRME/0Cy/y2T5I6r HBliwKMnlEiYBpZstBl52ZOs9TMbfcUCgRQrWSi5jLBxWmV35qzu56QZiu0k96QwMT6VktkMi qD/FBmOS8rG8WNCErfu44Oj2UfBHt3fwKiuu5bsgSQ7SSWuDdquWYvzpvBafmOZRucMzl1h2Q yZJFOIyiItIjAOGqKLisVSurqVQCnV3RYLCXZX09nMk9K0pU5ywW69QRL5DoXhFWYgP6DLpMh +O3pOGvLsKQAuuttcodMw1bmJm1ML2Ik7qAQhbI5wm+EGHE5WIN2skdvBJg4oSw8m82RgxLcH cxVPkerUyXWMriFrR1Q3//N3ToXx4xcd3vv5mdYfBuhUlXtRtho7lP7cnan3vWVpxjdH+ttvs K3XefUwxmUI8L5ltsk5bnH//rbYC9RaOCqgntDgZBQLqCDtzEprETSMReIuRh4AHh6YpAihKn a2QQjLBOBmOxzwDLc/6doQGKTZXQlGb0X8n7Hom1AtE2t9V3CbKVoQL93DAOjh+onY9fTfEv1 k5SrFFxAGWHKizW6VpYVZ0sOEc6hzZzRj925g/+HdlZV02N+gYa3ODOTNjpfxgWHsF47TsZY1 j/u46OwhxE1t34nC1RyhM3XmCvJCbloiF5l7ei7yez9Y0vLz3FXhuzgw3rMXpmlwHMtiKF9pS DXx/Tw== Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] Re: [BUG] ioctl: overflow in implicit constant conversion On Mon, Feb 20, 2023 at 09:26:05PM -0800, Ralph Little wrote: > Hi, > I have been picking up some old pending issues related to the SANE proje= ct. > One of our CI builds is on Alpine and it is generating warnings for ioct= l() > calls from the musl library: > > |error: overflow in conversion from 'long unsigned int' to 'int' changes > value from '2147577985' to '-2147389311' [-Werror=3Doverflow] > | > ||ioctl (fd, PPRSTATUS, &status); > > ||I see that Olaf Meeuwissen raised this issue a couple of years ago and= the > discussion petered out somewhat and I don't believe that the issue was e= ver > really resolved: > > https://www.openwall.com/lists/musl/2020/01/20/2 > > Is there any possibility that this could be addressed in the near future= ? > I see that Alpine have closed their issue and are not interested in patc= hing > their downstream musl: > > https://gitlab.alpinelinux.org/alpine/aports/-/issues/7580#note_287168 > > Cheers, > Ralph Little > > > > > So, I had a look at it. As far as I can tell, the issue is that musl declares ioctl()'s second argument to be an int. Together with the other defintions, this means that any _IOC_READ constant will overflow and generate those warnings. Also, this is technically undefined behavior, as value bits are shifted into the sign bit of a signed integer. Linux itself defines the ioctl syscall to have a second argument of type unsigned int. So this issue could be resolved by simply making the second argument of the ioctl() function unsigned. Does that create ABI issues? To my knowledge, all ABIs pass ints and unsigned ints the same way. Even if on some 64-bit arch there was a sign extension at the top, only the low 32 bits are defined. Ciao, Markus