Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2277890imm; Thu, 7 Jun 2018 08:06:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKrmTiaO+79OAleQCTlThpf4RMo9vRgjW8yoki8V+tw+lND3Fd0JJU3lIW1YraprbjYopgv X-Received: by 2002:a63:714c:: with SMTP id b12-v6mr1151807pgn.420.1528383964700; Thu, 07 Jun 2018 08:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383964; cv=none; d=google.com; s=arc-20160816; b=uB3/RJWI1vi85X11pQEwtda4Rd2AsXDLiu6RylGpZ611QPaMOQI2QaVvo9K/ZptRef mYjevuSPG+kkYsV1kooYDfFr59eFWJXwd3EASeQYSLjqRv1aveasSi5b6VOGZ+j+tV5B owQ61OB5m7SzXecJHmYMStFpAXOgSPsg575+gMA95IxYstp//emcllYAQ2/qD1wC2zcO fxjZTl6rTc+4M8lovfet/g1HyJOAhjFXcD432vpsv9cJuTKCw/KsJROq6oCPrbYfKmeC NTnyV8Sh8TYSifh9DvsMGJQ7wRjDizE2y7b/a0L5xFlksjkyjOXgqhOEEROHA5NB75qy V4Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=98yjkklivsLbW2LLMV7Du9lhFuOR6jnR8kvF2505urs=; b=R2fGZ5XGE++mPyFNF6g1f6K3TdWIzt+IMY4/7lRJTF2vdEwuZbGQiQqYuq1H71o8Eq OX0PKqQF2YdG4eIMkDdKCYYMFqX0Ee946/sY5EFXxfiExZ+rFiCuLMozi5zFPqG27dl/ 7ucMmPWe5MuzBc17rP4k+lsbza8TUPIUlDvwfdXLjW0RG9qMVsG4dgn3anQycaHHKJQ4 bF4+3JbW/s2eMbk2a7s6T1sAODFMip8q3bRDtcGBanfSAWWxxN80lKy4nL/oRbpdFayq R91b2KuLFD1zqL1OYHuIRH1F/UnRicTKwgOuGHN/JbBCNa+kBGNXizY9cHt3I08yvLr6 wfIQ== 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 y4-v6si10471421plp.120.2018.06.07.08.05.49; Thu, 07 Jun 2018 08:06:04 -0700 (PDT) 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 S965096AbeFGPEn (ORCPT + 99 others); Thu, 7 Jun 2018 11:04:43 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41585 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936055AbeFGPEQ (ORCPT ); Thu, 7 Jun 2018 11:04:16 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbm-0005dI-6K; Thu, 07 Jun 2018 15:09:46 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb3-0002tZ-BB; Thu, 07 Jun 2018 15:09:01 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Tejun Heo" , "Ivan Vecera" , "Al Viro" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 145/410] kernfs: fix regression in kernfs_fop_write caused by wrong type In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Ivan Vecera commit ba87977a49913129962af8ac35b0e13e0fa4382d upstream. Commit b7ce40cff0b9 ("kernfs: cache atomic_write_len in kernfs_open_file") changes type of local variable 'len' from ssize_t to size_t. This change caused that the *ppos value is updated also when the previous write callback failed. Mentioned snippet: ... len = ops->write(...); <- return value can be negative ... if (len > 0) <- true here in this case *ppos += len; ... Fixes: b7ce40cff0b9 ("kernfs: cache atomic_write_len in kernfs_open_file") Acked-by: Tejun Heo Signed-off-by: Ivan Vecera Signed-off-by: Al Viro Signed-off-by: Ben Hutchings --- fs/kernfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -267,7 +267,7 @@ static ssize_t kernfs_fop_write(struct f { struct kernfs_open_file *of = kernfs_of(file); const struct kernfs_ops *ops; - size_t len; + ssize_t len; char *buf; if (of->atomic_write_len) {