From patchwork Tue Apr 5 15:17:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8752901 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C8A59C0553 for ; Tue, 5 Apr 2016 15:17:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BF402038E for ; Tue, 5 Apr 2016 15:17:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D4B6200C1 for ; Tue, 5 Apr 2016 15:17:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758715AbcDEPRi (ORCPT ); Tue, 5 Apr 2016 11:17:38 -0400 Received: from prv-mh.provo.novell.com ([137.65.248.74]:53940 "EHLO prv-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758588AbcDEPRi convert rfc822-to-8bit (ORCPT ); Tue, 5 Apr 2016 11:17:38 -0400 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Tue, 05 Apr 2016 09:17:36 -0600 Message-Id: <5703F32D02000078000E345C@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Tue, 05 Apr 2016 09:17:33 -0600 From: "Jan Beulich" To: "Linus Torvalds" , "Al Viro" Cc: "linux-fsdevel" Subject: [PATCH v2] vfs: avoid atomic f_pos accesses for non-seekable files References: <5703E2E602000078000E3331@prv-mh.provo.novell.com> <5703E7AE02000078000E3397@prv-mh.provo.novell.com> In-Reply-To: Mime-Version: 1.0 Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 9c225f2655 ("vfs: atomic f_pos accesses as per POSIX") may have gone a little too far: We've had a report of a deadlock of an application accessing a /proc file through the same file descriptor from multiple threads. While /proc files are regular ones, them (and similarly others which are) often not being seekable really already makes them deviate from how regular files would behave. The issue was specifically observed on /proc/xen/xenbus (which doesn't exist in the upstream kernel), when an application's read blocks (waiting for a watch to trigger) while the write that would satisfy the read then waits for the position update mutex to be released. Since for non-seekable files the file position is kind of a strange thing anyway, also don't enforce atomic position updates for them. (I do recognize that the application isn't really standard conforming, as it should use multiple file descriptors from all I understand. But it worked fine before that change, and so they claim the kernel to be at fault.) Signed-off-by: Jan Beulich Acked-by: Linus Torvalds --- v2: Add a paragraph to the description outlining the actual issue observed. --- fs/open.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 4.6-rc2/fs/open.c +++ 4.6-rc2-nonseekable-no-atomic-pos/fs/open.c @@ -1142,7 +1142,8 @@ EXPORT_SYMBOL(generic_file_open); */ int nonseekable_open(struct inode *inode, struct file *filp) { - filp->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); + filp->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE | + FMODE_ATOMIC_POS); return 0; }