From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 266E1385DC00 for ; Fri, 8 May 2020 20:22:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 266E1385DC00 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-138-U-6-2KI0O66I5QgE4_2qLw-1; Fri, 08 May 2020 16:22:14 -0400 X-MC-Unique: U-6-2KI0O66I5QgE4_2qLw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27597BFC0; Fri, 8 May 2020 20:22:13 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-187.ams2.redhat.com [10.36.113.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A10A10021B3; Fri, 8 May 2020 20:22:11 +0000 (UTC) From: Florian Weimer To: DJ Delorie via Libc-alpha Cc: DJ Delorie , schwab@linux-m68k.org Subject: Re: [patch] Use unsigned constants for ICMP6 filters [BZ #22489] References: Date: Fri, 08 May 2020 22:22:10 +0200 In-Reply-To: (DJ Delorie via Libc-alpha's message of "Fri, 08 May 2020 16:10:28 -0400") Message-ID: <87eerui3d9.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: Fri, 08 May 2020 20:22:23 -0000 * DJ Delorie via Libc-alpha: > Florian Weimer writes: >> I'd say that the filter array *elements* are unsigned, but I don't >> feel strongly about that. > > Ok, hopefully one last version and then we can paint the bike shed ;-) > > From 4ce3470246e0336e53010d66f30a1040a7e1f4bb 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 elements are unsigned > but the computed constants are signed. This both causes a > signededness conversion at the &= 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 */ > > #define ICMP6_FILTER_WILLPASS(type, filterp) \ > - ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) > + ((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) == 0) > > #define ICMP6_FILTER_WILLBLOCK(type, filterp) \ > - ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) > + ((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) != 0) > > #define ICMP6_FILTER_SETPASS(type, filterp) \ > - ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))) > + ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1U << ((type) & 31)))) > > #define ICMP6_FILTER_SETBLOCK(type, filterp) \ > - ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))) > + ((((filterp)->icmp6_filt[(type) >> 5]) |= (1U << ((type) & 31)))) > > #define ICMP6_FILTER_SETPASSALL(filterp) \ > memset (filterp, 0, sizeof (struct icmp6_filter)); Looks good to me know. Reviewed-by: Florian Weimer Thanks, Florian