mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Al Viro <viro@zeniv.linux.org.uk>, Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 3.19.y-ckt 07/40] atomic_open(): fix the handling of create_error
Date: Wed, 25 May 2016 10:30:10 -0700	[thread overview]
Message-ID: <1464197443-20056-8-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1464197443-20056-1-git-send-email-kamal@canonical.com>

3.19.8-ckt22 -stable review patch.  If anyone has any objections, please let me know.

---8<------------------------------------------------------------

From: Al Viro <viro@zeniv.linux.org.uk>

commit 10c64cea04d3c75c306b3f990586ffb343b63287 upstream.

* if we have a hashed negative dentry and either CREAT|EXCL on
r/o filesystem, or CREAT|TRUNC on r/o filesystem, or CREAT|EXCL
with failing may_o_create(), we should fail with EROFS or the
error may_o_create() has returned, but not ENOENT.  Which is what
the current code ends up returning.

* if we have CREAT|TRUNC hitting a regular file on a read-only
filesystem, we can't fail with EROFS here.  At the very least,
not until we'd done follow_managed() - we might have a writable
file (or a device, for that matter) bound on top of that one.
Moreover, the code downstream will see that O_TRUNC and attempt
to grab the write access (*after* following possible mount), so
if we really should fail with EROFS, it will happen.  No need
to do that inside atomic_open().

The real logics is much simpler than what the current code is
trying to do - if we decided to go for simple lookup, ended
up with a negative dentry *and* had create_error set, fail with
create_error.  No matter whether we'd got that negative dentry
from lookup_real() or had found it in dcache.

Acked-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[ kamal: backport to 3.19-stable: context ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/namei.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 6c363c9..42d17dd 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2810,22 +2810,10 @@ no_open:
 		dentry = lookup_real(dir, dentry, nd->flags);
 		if (IS_ERR(dentry))
 			return PTR_ERR(dentry);
-
-		if (create_error) {
-			int open_flag = op->open_flag;
-
-			error = create_error;
-			if ((open_flag & O_EXCL)) {
-				if (!dentry->d_inode)
-					goto out;
-			} else if (!dentry->d_inode) {
-				goto out;
-			} else if ((open_flag & O_TRUNC) &&
-				   S_ISREG(dentry->d_inode->i_mode)) {
-				goto out;
-			}
-			/* will fail later, go on to get the right error */
-		}
+	}
+	if (create_error && !dentry->d_inode) {
+		error = create_error;
+		goto out;
 	}
 looked_up:
 	path->dentry = dentry;
-- 
2.7.4

  parent reply	other threads:[~2016-05-25 17:31 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25 17:30 [3.19.y-ckt stable] Linux 3.19.8-ckt22 stable review Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 01/40] compiler-gcc: integrate the various compiler-gcc[345].h files Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 02/40] [3.19-stable only] fix backport "IB/security: restrict use of the write() interface" Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 03/40] Revert "usb: hub: do not clear BOS field during reset device" Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 04/40] [3.19-stable] x86: LLVMLinux: Fix "incomplete type const struct x86cpu_device_id" Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 05/40] regulator: s2mps11: Fix invalid selector mask and voltages for buck9 Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 06/40] regmap: spmi: Fix regmap_spmi_ext_read in multi-byte case Kamal Mostafa
2016-05-25 17:30 ` Kamal Mostafa [this message]
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 08/40] crypto: hash - Fix page length clamping in hash walk Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 09/40] drm/radeon: fix PLL sharing on DCE6.1 (v2) Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 10/40] get_rock_ridge_filename(): handle malformed NM entries Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 11/40] ALSA: hda - Fix white noise on Asus UX501VW headset Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 12/40] Input: max8997-haptic - fix NULL pointer dereference Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 13/40] drm/i915: Bail out of pipe config compute loop on LPT Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 14/40] ALSA: hda - Fix subwoofer pin on ASUS N751 and N551 Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 15/40] tools lib traceevent: Free filter tokens in process_filter() Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 16/40] tools lib traceevent: Do not reassign parg after collapse_tree() Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 17/40] workqueue: fix rebind bound workers warning Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 18/40] ocfs2: fix posix_acl_create deadlock Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 19/40] nf_conntrack: avoid kernel pointer value leak in slab name Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 20/40] net: fec: only clear a queue's work bit if the queue was emptied Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 21/40] net/mlx4_en: Fix endianness bug in IPV6 csum calculation Kamal Mostafa
2016-05-26  8:18   ` Tariq Toukan
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 22/40] macvtap: segmented packet is consumed Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 23/40] tcp: refresh skb timestamp at retransmit time Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 24/40] arm64: bpf: jit JMP_JSET_{X,K} Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 25/40] decnet: Do not build routes to devices without decnet private data Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 26/40] route: do not cache fib route info on local routes with oif Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 27/40] net: use skb_postpush_rcsum instead of own implementations Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 28/40] vlan: pull on __vlan_insert_tag error path and fix csum correction Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 29/40] ipv4/fib: don't warn when primary address is missing if in_dev is dead Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 30/40] bpf: fix double-fdput in replace_map_fd_with_map_ptr() Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 31/40] net_sched: introduce qdisc_replace() helper Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 32/40] net_sched: update hierarchical backlog too Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 33/40] sch_htb: update backlog as well Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 34/40] sch_dsmark: " Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 35/40] netem: Segment GSO packets on enqueue Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 36/40] net: fix infoleak in llc Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 37/40] net: fix infoleak in rtnetlink Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 38/40] VSOCK: do not disconnect socket when peer has shutdown SEND only Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 39/40] net: bridge: fix old ioctl unlocked net device walk Kamal Mostafa
2016-05-25 17:30 ` [PATCH 3.19.y-ckt 40/40] net: fix a kernel infoleak in x25 module Kamal Mostafa

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=1464197443-20056-8-git-send-email-kamal@canonical.com \
    --to=kamal@canonical.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®