Re: PATCH: Disallow a netmask of zero unless the IP is also all zeroes
Re: PATCH: Disallow a netmask of zero unless the IP is also all zeroes
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Greg Sabino Mullane writes:
> I say "of course" but few people (even tech ones) know the distinction.
> (Nor should they have to! But that's for a nearby thread). This patch aims
> to prevent this very bad footgun by only allowing a /0 if the IP consists
> of only zeroes. It works for ipv4 and ipv6.
More generally, should we reject if the netmask causes *any* nonzero
IP bits to be ignored? Our CIDR type already imposes that rule:
regression=# select '1.2.3.4/24'::cidr;
ERROR: invalid cidr value: "1.2.3.4/24"
LINE 1: select '1.2.3.4/24'::cidr;
^
DETAIL: Value has bits set to right of mask.
I'm a bit distressed to realize that hba.c isn't using cidr_in.
Maybe we should try to share code instead of duplicating yet more.
regards, tom lane
Re: PATCH: Disallow a netmask of zero unless the IP is also all zeroes
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 11 Feb 2025, at 21:25, Tom Lane wrote: > I'm a bit distressed to realize that hba.c isn't using cidr_in. > Maybe we should try to share code instead of duplicating yet more. +1. I have a note along these lines on my never-shrinking TODO, I think it would be great if we took a stab at that. -- Daniel Gustafsson
Re: PATCH: Disallow a netmask of zero unless the IP is also all zeroes
От:
Greg Sabino Mullane <htamfids@gmail.com>
Дата:
On Tue, Feb 11, 2025 at 3:25 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
More generally, should we reject if the netmask causes *any* nonzero
IP bits to be ignored? Our CIDR type already imposes that rule:
Yeah, I like that idea a lot. That's a great DETAIL message.
Cheers,
Greg
Re: PATCH: Disallow a netmask of zero unless the IP is also all zeroes
От:
Andreas Karlsson <andreas@proxel.se>
Дата:
On 2/11/25 9:25 PM, Tom Lane wrote: > Greg Sabino Mullane writes: >> I say "of course" but few people (even tech ones) know the distinction. >> (Nor should they have to! But that's for a nearby thread). This patch aims >> to prevent this very bad footgun by only allowing a /0 if the IP consists >> of only zeroes. It works for ipv4 and ipv6. > > More generally, should we reject if the netmask causes *any* nonzero > IP bits to be ignored? Our CIDR type already imposes that rule: +1 From me too. I think we should fix the general issue rather than special casing /0. Andreas