Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1023030yba; Thu, 4 Apr 2019 02:38:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1A2YyxPXBDBegXLHhGIBx0NLwzokhOPtB1Gsa2pwLIBQ+W326FDFE5ibkgowkzXY6c8Q+ X-Received: by 2002:a62:205c:: with SMTP id g89mr4865395pfg.34.1554370737579; Thu, 04 Apr 2019 02:38:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370737; cv=none; d=google.com; s=arc-20160816; b=Lx0MCJTKMb5UZDP/zjXuqBLwxng4xHdG88ZeEDVtjtYWJ3AABVb2jITU1LJN1i30Nx dGbRYag4C2oBAG180KcWlqpxvR5GtYn7tlNLZNAHTKSFGHLbAVCSsdgBfjIWLaFF1dK9 7if86eIsOXn95K1AaLila9WADyghBIR7Mcu9ZX3Mr3YWVSbVVyNeUbhyovxJWMpVvIU4 i8jxr/eTrjNTON8G5z6IPXNz/jEQdJ/Q0jNhLThcByUz+2J+/ds1M+NYeyifE1Ae71K8 BcyPoWulIQP4aWNdMOz4WFyqn39qsutP2kZYaVdenbOOOrnDPwyeo4Pcnnn/5nMfrtXN HWeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=M95cZgaEkQPj5TeaUUP2VuVG2elPe+2ZoahkdlN+xBE=; b=IpAAbAcW0xtWbXG0G/9SeW84k3ODwqqLMtHg2/07ZYo3LY8OEpsjfo8uyXOZW2glQ2 vJs98tMJO42AVJLSfcEY/OBKsd8UbLCI8peGHiyBxeAFwEJ+p5A60/nRfwAJC2GMEo36 GYhJMw9Y49qfywmtr/pn5yrJ+/ukp4ACzAWmIKV+4Am8WnRXQySRBVZjJlPaOpq2vhSt 45lV+oF0gttpGHUA1P3iJoAPHNZq2db4K3A2H1Wz9MIjD9pPqu5AARb6le+LrRwqDMhX Z54GeT2umCIrF06px50xIGHO+oxipz+iMivGDbmSQE33W/ETzRmSxtThVXIcNCoROoJH asJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="zeUF/kLh"; 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 184si16660158pfd.233.2019.04.04.02.38.42; Thu, 04 Apr 2019 02:38:57 -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; dkim=pass header.i=@kernel.org header.s=default header.b="zeUF/kLh"; 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 S1732010AbfDDJEi (ORCPT + 99 others); Thu, 4 Apr 2019 05:04:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:42476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731990AbfDDJEf (ORCPT ); Thu, 4 Apr 2019 05:04:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D34302190C; Thu, 4 Apr 2019 09:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368675; bh=LKNrg6J55Gu+5893+dJvkQyWzV1nv4kYhrpZsDCEhJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zeUF/kLhcBtPePkEObkN1DZx0c501yuXShmkNDGrzu7XBosGK4Z3Xf3sgk7WJ28Ze uSpInqIFl+6mbIOT4OdOkfyeNZg/eJE87eiveIpJRFui5ME/41uyajvP1qMhJGHLks qrjKRmWutwqLgCl+nRLX6QBfSz6S+EAp9km9CCFw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Coly Li , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 112/187] bcache: fix input overflow to sequential_cutoff Date: Thu, 4 Apr 2019 10:47:29 +0200 Message-Id: <20190404084608.549662173@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 8c27a3953e92eb0b22dbb03d599f543a05f9574e ] People may set sequential_cutoff of a cached device via sysfs file, but current code does not check input value overflow. E.g. if value 4294967295 (UINT_MAX) is written to file sequential_cutoff, its value is 4GB, but if 4294967296 (UINT_MAX + 1) is written into, its value will be 0. This is an unexpected behavior. This patch replaces d_strtoi_h() by sysfs_strtoul_clamp() to convert input string to unsigned integer value, and limit its range in [0, UINT_MAX]. Then the input overflow can be fixed. Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/md/bcache/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 59bf13faf752..01c7c4452a26 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -295,7 +295,9 @@ STORE(__cached_dev) dc->io_disable = v ? 1 : 0; } - d_strtoi_h(sequential_cutoff); + sysfs_strtoul_clamp(sequential_cutoff, + dc->sequential_cutoff, + 0, UINT_MAX); d_strtoi_h(readahead); if (attr == &sysfs_clear_stats) -- 2.19.1