From: DJ Delorie <dj@redhat.com>
To: Florian Weimer <fw@deneb.enyo.de>
Cc: libc-alpha@sourceware.org, amonakov@ispras.ru, schwab@linux-m68k.org
Subject: Re: [patch] Use unsigned constants for ICMP6 filters [BZ #22489]
Date: Fri, 08 May 2020 16:10:28 -0400 [thread overview]
Message-ID: <xnmu6i5gsr.fsf@greed.delorie.com> (raw)
In-Reply-To: <87r1w0ix93.fsf@mid.deneb.enyo.de> (message from Florian Weimer on Sun, 03 May 2020 22:23:04 +0200)
Florian Weimer <fw@deneb.enyo.de> 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 <s.korolev@ndmsystems.com>
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));
next prev parent reply other threads:[~2020-05-08 20:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 21:35 DJ Delorie
2020-04-25 8:53 ` Andreas Schwab
2020-04-25 17:15 ` DJ Delorie
2020-04-25 17:48 ` Andreas Schwab
2020-04-25 21:23 ` DJ Delorie
2020-04-25 21:30 ` Andreas Schwab
2020-04-25 21:41 ` DJ Delorie
2020-04-26 11:25 ` Alexander Monakov
2020-04-26 11:56 ` Florian Weimer
2020-04-30 20:47 ` DJ Delorie
2020-05-03 20:23 ` Florian Weimer
2020-05-08 20:10 ` DJ Delorie [this message]
2020-05-08 20:22 ` Florian Weimer
2020-05-11 21:09 ` DJ Delorie
2020-05-12 7:35 ` Andreas Schwab
2020-04-26 8:03 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xnmu6i5gsr.fsf@greed.delorie.com \
--to=dj@redhat.com \
--cc=amonakov@ispras.ru \
--cc=fw@deneb.enyo.de \
--cc=libc-alpha@sourceware.org \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).