Received: by 10.223.176.5 with SMTP id f5csp3406265wra; Mon, 29 Jan 2018 12:43:16 -0800 (PST) X-Google-Smtp-Source: AH8x2257z2CzheoAwDk0li+oHI99Pjdactbhhqd8/fVhpFF0c61f9U2bc+W2bQmNY3CzgRD4//bl X-Received: by 10.98.66.152 with SMTP id h24mr27873677pfd.13.1517258596110; Mon, 29 Jan 2018 12:43:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517258596; cv=none; d=google.com; s=arc-20160816; b=S2tc/ylWR0F/AaFkfhSMi6sqYw94sMhCtUAyLhsrTuMn6pi9KvNI4QYr/lLDTBqDbb HuuglvFrqKn/1BJ66aUjhZ/7Gvj0Hn69klt+rlKdtVA5IMWo9sx8TR8F8pq8F29mtkmc 0m9vfcO2jCd8QKgjyMHa5DAlY85BVXu4N3F7dd3iNZYYRg+nn9wtk1hyOGHxibcp0Htt a6xIn16M42vVbnv+nR8aM0L4Y/j/1BzfCKeh1ErF++tjGRFI6cNxmAar25JHRG+IF3u9 tJeMDJNSyh934hYRyoaAfl/WASjQjEXxUHi2CP8lH8pSE/N6SdyLm/sNl142ym6TL5y5 TwdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=eamesSzjDBzDij8FZmFc8E+MWKDeEEJ1fxNvK+F+tck=; b=P87uzjjSUKVtlAm+e6hm5I4CT1st3DnHemSRLiKFPpm2uX6nZPaoPE4gbn+Hsgag9S mc0HjYymZc2UmUmxMJ2LW5d9dEoTVhXjZQoFxGxoHnPt7mkHJP2L0ONnSMbCbzpeFq/s 9xaHHR7qaSNYYh0WkiaPREqMBJTpKoknxOpObxO0UUc5ZffyjHvP0iDvQIkcQ8W5h5vX HPogH+KGL6oqQet0cVB2nZYUPr2YuEqEZDWFZCmWYoG/wbkWyfUBfnr1MEVHJSWXjBh7 04WSjqSPwxk1VauW2oMDomEzxElQ1BlonotMco82MVB1798ldChI4RvJ5jvyTXPRdFJq SGUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h23si2025302pfh.80.2018.01.29.12.43.01; Mon, 29 Jan 2018 12:43:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754000AbeA2UMx (ORCPT + 99 others); Mon, 29 Jan 2018 15:12:53 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35988 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753489AbeA2UMv (ORCPT ); Mon, 29 Jan 2018 15:12:51 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CC8E12FE9; Mon, 29 Jan 2018 13:08:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Brandenburg , Linus Torvalds Subject: [PATCH 4.14 02/71] orangefs: initialize op on loop restart in orangefs_devreq_read Date: Mon, 29 Jan 2018 13:56:30 +0100 Message-Id: <20180129123827.486989889@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Brandenburg commit a0ec1ded22e6a6bc41981fae22406835b006a66e upstream. In orangefs_devreq_read, there is a loop which picks an op off the list of pending ops. If the loop fails to find an op, there is nothing to read, and it returns EAGAIN. If the op has been given up on, the loop is restarted via a goto. The bug is that the variable which the found op is written to is not reinitialized, so if there are no more eligible ops on the list, the code runs again on the already handled op. This is triggered by interrupting a process while the op is being copied to the client-core. It's a fairly small window, but it's there. Signed-off-by: Martin Brandenburg Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/orangefs/devorangefs-req.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/orangefs/devorangefs-req.c +++ b/fs/orangefs/devorangefs-req.c @@ -162,7 +162,7 @@ static ssize_t orangefs_devreq_read(stru struct orangefs_kernel_op_s *op, *temp; __s32 proto_ver = ORANGEFS_KERNEL_PROTO_VERSION; static __s32 magic = ORANGEFS_DEVREQ_MAGIC; - struct orangefs_kernel_op_s *cur_op = NULL; + struct orangefs_kernel_op_s *cur_op; unsigned long ret; /* We do not support blocking IO. */ @@ -186,6 +186,7 @@ static ssize_t orangefs_devreq_read(stru return -EAGAIN; restart: + cur_op = NULL; /* Get next op (if any) from top of list. */ spin_lock(&orangefs_request_list_lock); list_for_each_entry_safe(op, temp, &orangefs_request_list, list) {