From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 39D853898524 for ; Thu, 30 Apr 2020 20:47:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 39D853898524 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-349-ptmd6ioEMPa4h0XKpSNzxQ-1; Thu, 30 Apr 2020 16:47:55 -0400 X-MC-Unique: ptmd6ioEMPa4h0XKpSNzxQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 93B8A107ACF8; Thu, 30 Apr 2020 20:47:53 +0000 (UTC) Received: from greed.delorie.com (ovpn-112-52.phx2.redhat.com [10.3.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D41D5D9F1; Thu, 30 Apr 2020 20:47:52 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.14.7/8.14.7) with ESMTP id 03UKlo3L001957; Thu, 30 Apr 2020 16:47:50 -0400 From: DJ Delorie To: Florian Weimer Cc: libc-alpha@sourceware.org, amonakov@ispras.ru, schwab@linux-m68k.org Subject: Re: [patch] Use unsigned constants for ICMP6 filters [BZ #22489] In-Reply-To: <87pnbu31fl.fsf@mid.deneb.enyo.de> (message from Florian Weimer on Sun, 26 Apr 2020 13:56:46 +0200) Date: Thu, 30 Apr 2020 16:47:50 -0400 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-23.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2020 20:47:58 -0000 How's this? >From aa8ad2eacb64a5e0e81892b87665fa50f66ad87a Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 24 Apr 2020 17:18:41 -0400 Subject: Use unsigned constants for ICMP6 filters [BZ #22489] The core problem here is that the filter array is unsigned but the computed constants are signed. This both causes a signededness conversion at the &=3D step and may cause undefined behavior if the MSB is being modified. This patch uses unsigned constants to avoid both cases. - DJ diff --git a/inet/netinet/icmp6.h b/inet/netinet/icmp6.h index a75722887d..5fed0fbca1 100644 --- a/inet/netinet/icmp6.h +++ b/inet/netinet/icmp6.h @@ -85,16 +85,16 @@ struct icmp6_hdr #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */ =20 #define ICMP6_FILTER_WILLPASS(type, filterp) \ -=09((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) =3D=3D 0= ) +=09((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) =3D=3D = 0) =20 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \ -=09((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) !=3D 0) +=09((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) !=3D 0) =20 #define ICMP6_FILTER_SETPASS(type, filterp) \ -=09((((filterp)->icmp6_filt[(type) >> 5]) &=3D ~(1 << ((type) & 31)))) +=09((((filterp)->icmp6_filt[(type) >> 5]) &=3D ~(1U << ((type) & 31)))) =20 #define ICMP6_FILTER_SETBLOCK(type, filterp) \ -=09((((filterp)->icmp6_filt[(type) >> 5]) |=3D (1 << ((type) & 31)))) +=09((((filterp)->icmp6_filt[(type) >> 5]) |=3D (1U << ((type) & 31)))) =20 #define ICMP6_FILTER_SETPASSALL(filterp) \ =09memset (filterp, 0, sizeof (struct icmp6_filter));