Re: RLS bug in expanding security quals - Mailing list pgsql-hackers

From Haribabu Kommi
Subject Re: RLS bug in expanding security quals
Date
Msg-id CAJrrPGczeBMup7xDwHJB17Jgk5ntzr2enY0LXupb5zqah0XXLg@mail.gmail.com
Whole thread Raw
In response to Re: RLS bug in expanding security quals  (Stephen Frost <sfrost@snowman.net>)
Responses Re: RLS bug in expanding security quals  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-hackers
On Thu, Oct 8, 2015 at 2:54 PM, Stephen Frost <sfrost@snowman.net> wrote:
> Haribabu,
>
> * Haribabu Kommi (kommi.haribabu@gmail.com) wrote:
>> During the testing of multi-tenancy feature from system catalog views, that
>> is described in [1], found a problem in executing "user_privileges" view
>> from information_schema. The following is the minimal test sql that
>> reproduces the problem.
>
> Interesting, thanks.
>
>> >From further analysis, I found that the same issue can happen with user
>> tables also. Attached
>> rls_failure.sql file has test steps to reproduce the issue.
>
> Just to make sure we're on the same page, this results in this assertion
> being tripped:
>
> TRAP: FailedAssertion("!(var->varattno <= rel->max_attr)", File:
> "/home/sfrost/git/pg/dev/postgresql/src/backend/optimizer/path/costsize.c",
> Line: 4152)
>
> Due to var->varattno being 1 and rel->max_attr being 0.

Yes, the same the assertion problem with assert build.

without assert build, query fails with the following error.

ERROR:  invalid attnum -2 for rangetable entry test_tbl


>> Any ideas how to handle this problem?
>
> It's quite late here, but I'll take a look at this in more depth
> tomorrow.
>
> Based on what the Assert's testing, I took an educated guess and tried
> running without the UNION ALL, which appeared to work correctly.

Yes, it works fine without UNION ALL.

And also if we change the table column datatype from name to char,
the "pull_up_subqueries" function doesn't pull the union all because of
datatype mismatch and it works fine even with row level security is enabled.

Regards,
Hari Babu
Fujitsu Australia



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: RLS bug in expanding security quals
Next
From: Michael Paquier
Date:
Subject: Re: Re: In-core regression tests for replication, cascading, archiving, PITR, etc.