Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id B1FD7632F80 for ; Mon, 14 Dec 2009 21:41:34 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 90745-03 for ; Tue, 15 Dec 2009 01:41:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tyo202.gate.nec.co.jp (TYO202.gate.nec.co.jp [202.32.8.206]) by mail.postgresql.org (Postfix) with ESMTP id A20A762DB89 for ; Mon, 14 Dec 2009 21:41:22 -0400 (AST) Received: from mailgate3.nec.co.jp ([10.7.69.192]) by tyo202.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id nBF1evMl016334; Tue, 15 Dec 2009 10:40:57 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id nBF1evt28013; Tue, 15 Dec 2009 10:40:57 +0900 (JST) Received: from mail03.kamome.nec.co.jp (mail03.kamome.nec.co.jp [10.25.43.7]) by mailsv4.nec.co.jp (8.13.8/8.13.4) with ESMTP id nBF1eB7c013216; Tue, 15 Dec 2009 10:40:57 +0900 (JST) Received: from shikibu.jp.nec.com ([10.26.220.2] [10.26.220.2]) by mail02.kamome.nec.co.jp with ESMTP id BT-MMP-415225; Tue, 15 Dec 2009 10:40:33 +0900 Received: from [10.19.71.82] ([10.19.71.82] [10.19.71.82]) by mail.jp.nec.com with ESMTP; Tue, 15 Dec 2009 10:40:32 +0900 Message-ID: <4B26E910.4060604@ak.jp.nec.com> Date: Tue, 15 Dec 2009 10:40:32 +0900 From: KaiGai Kohei User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Stephen Frost CC: KaiGai Kohei , Robert Haas , Josh Berkus , pgsql-hackers@postgresql.org Subject: Re: Row-Level Security References: <20091212203003.GL17756@tamriel.snowman.net> <4B24381F.7050407@agliodbs.com> <603c8f070912121918i59f807e3n5ed4d4699227e43@mail.gmail.com> <4B24AAED.2080706@kaigai.gr.jp> <603c8f070912130411q765c7e9aw371b468229b8e32@mail.gmail.com> <4B25C5B2.9010108@ak.jp.nec.com> <603c8f070912132135l43bdf060sa5207b5a4d2c918c@mail.gmail.com> <4B25DE99.2050801@ak.jp.nec.com> <603c8f070912140318i6bbc1d63o9e81d409d0b342b6@mail.gmail.com> <4B2626ED.7030104@kaigai.gr.jp> <20091214134714.GS17756@tamriel.snowman.net> In-Reply-To: <20091214134714.GS17756@tamriel.snowman.net> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.562 tagged_above=-10 required=5 tests=AWL=0.037, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/1292 X-Sequence-Number: 151995 Stephen Frost wrote: > KaiGai, > > * KaiGai Kohei (kaigai@kaigai.gr.jp) wrote: >> The reason why I put on the security hook in ExecScan() is to avoid the >> problem that row-cost user defined function can be evaluated earlier >> than row-level security policy. (I believed it was a well-known problem >> at that time yet.) So, I didn't want to append it before optimization. > > This is a problem which needs to be addressed and fixed independently. > >> I also believe this matter should be resolved when we provide row-level >> security stuff, because it is a security feature. > > This issue should be fixed first, not as part of some large-scale patch. > > If you have thoughts or ideas about how to address this problem as it > relates to views, I think you would find alot of people willing to > listen and to discuss it. This must be independent of SELinux, > independent of row-level security, and isn't something based on any of > the patches which have been submitted so far. None of them that I've > seen resolve this problem in a way that the community is willing to > accept. Sorry, I don't have something good idea at the moment. IIRC, one headache issue is that user may provide well indexable conditions, such as "SELECT * FROM view_x WHERE id = 1234". In this case, if we strictly keep the order of evaluation between inside and outside of the view, its performance penalty will over reasonable tradeoff to the better security. Someone pointed out user given conditions which can be replaced by index scan are "trusted", so all we need to focus on are conditions which need to check for each tuples. I also think it is a right direction, as long as we can restrict who can define index access method in appropriate way. If we can focus on the order of evaluation on the non-indexed conditions, the point is order_qual_clauses() which sort the given qual list based on the cost evaluation. If we can mark condition node a flag which means this node come from inside of view or row-level policy, it is not difficult to keep evaluation order. However, it is just my quick idea. It might miss something. We need to consider the matter for more details... -- OSS Platform Development Division, NEC KaiGai Kohei