From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44A85C65BAE for ; Thu, 13 Dec 2018 12:10:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1180420880 for ; Thu, 13 Dec 2018 12:10:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1180420880 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-integrity-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729106AbeLMMKF (ORCPT ); Thu, 13 Dec 2018 07:10:05 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:44368 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728767AbeLMMKF (ORCPT ); Thu, 13 Dec 2018 07:10:05 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.91 #2 (Red Hat Linux)) id 1gXPoX-0006BE-4Z; Thu, 13 Dec 2018 12:10:01 +0000 Date: Thu, 13 Dec 2018 12:10:01 +0000 From: Al Viro To: Goldwyn Rodrigues Cc: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, zohar@linux.ibm.com, syzbot+ae82084b07d0297e566b@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, linux-integrity@vger.kernel.org, linux-unionfs@vger.kernel.org, dvyukov@google.com Subject: Re: [PATCH] fs: Evaluate O_WRONLY | O_RDWR to O_RDWR Message-ID: <20181213121000.GM2217@ZenIV.linux.org.uk> References: <20181213115717.p7ncktng2ihxw5md@merlin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181213115717.p7ncktng2ihxw5md@merlin> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org On Thu, Dec 13, 2018 at 05:57:17AM -0600, Goldwyn Rodrigues wrote: > A user can open(O_WRONLY | O_RDWR) and the options are valid. > However, OPEN_FMODE() evaluates both FMODE_READ and FMODE_WRITE, > as negative. We also need to protect the lower layers from this > anomaly. > > Solve it by dropping O_WRONLY, so O_RDWR takes precedence. Congratulations, you've broken fdutils... Passing 3 in lower bits of open() flags is *not* the same as O_RDWR; behaiviour is different and deliberately chosen by existing userland code. IOW, NAK.