From patchwork Wed Aug 19 09:07:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 247939 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp295506ils; Wed, 19 Aug 2020 02:08:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuv4pGXQIjNZeA4m9BnpGKtTX8TIU8AuEZsM1GF+OYJI/YIOyYZJDahsk29y0xgzozNtAa X-Received: by 2002:aa7:d9d0:: with SMTP id v16mr1441663eds.137.1597828106332; Wed, 19 Aug 2020 02:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597828106; cv=none; d=google.com; s=arc-20160816; b=Z0xrJAYkWvw/qawgewLIcwGwzyF1WSKl2sliMAyJQBUAz/0RnLom9f7DtwDOUKxkNI WmdRzW4h5am6Csiy2ZNjDAZXWlDshoS07b3dDRGTM98ZABWR5UKBrvqdRBLDkt8JVd4L tcTOWKJlkEkhtF/OSmKFPqFP2Aweyu8EhS36DKu2tvgpk4KLI9vkLSTbul1sZeKbrxbx jVoByw8+1wcgFZbBVPb4/YLdTyFyuLQA33V4TZkHvaMk84qDy/Lv7gBmeGCr8hmLryJ+ flmOUfe8RsQwfQJdSIEDkl5iLABquv/WedwAmNNLGGd6avDXtHF1lKqA34K3j19Bbbbn o8Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=2S3Y3+3U7JbeOfOYmdGRKCEy1l9JlHbwzf6eC7YVQKI=; b=iDFmNVA3fRkSpnwYVKgZpaFPKYElt9vWJl/Vr41tdHWrDiMW+rGjG9fQpHZGHBS+Qo 1I0JkEM20jI36u9YNnJrHQQ2Wz4yxwLIEpOOplz9JBdrYKKtGuKlt5bMB2jCqM2zjGTa bkYDn4V6l5HQ2NEDYLpcd31W40kwgFjpXmp9Lhgu+5lWQb//O+etZ2tuFGCBQ4OYImBO vMHXdDHIurerLT0mNHQStLLwunQIQMBOb3iVWZ5T3fuePZMtxD1btlniynDhRCLslCCR OzTYWCfJQvGFnDYCUYfaHTHQc1Sk2hmBwESMC0YRUpw+3RUG0Y350sVgSXxEwDcY9Z+5 JuGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wLbwTbWs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id bx26si15119118edb.588.2020.08.19.02.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 02:08:26 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wLbwTbWs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 768318222C; Wed, 19 Aug 2020 11:08:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wLbwTbWs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 780C182256; Wed, 19 Aug 2020 11:08:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7ECE982209 for ; Wed, 19 Aug 2020 11:08:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1041.google.com with SMTP id ha11so818908pjb.1 for ; Wed, 19 Aug 2020 02:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2S3Y3+3U7JbeOfOYmdGRKCEy1l9JlHbwzf6eC7YVQKI=; b=wLbwTbWs3Vg8TOv/INYyvY0ryZm+eS7Ox6YHeU3gdYdZBb4ZQxL6cEFRavL/toI7+M 4L+mhYU+6VAo/XZs5qud4eru8mrEWjJHvigULGqV1CEJAOg4x3eyRGZ/qoJm60KPXDTM gJmlEpddEp1+hduDZopsZnxPqvm5gpWMMqlkMp1IsZdDzi2WJ5m1qcmUXXstISdq4AeU fnXLwcfpkXR3uVBRskLYMNz/9J8Tyc6XbXU3JHdcw9CVWm12HU7d/HnU5qRlm6xAMLo7 VhM/6ZA/glZfoii6i62HMVkNqL7RnKa+aneOpUFbhLMvfkCj/ppU3S0jUKDJX2pTLItQ 1ODg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2S3Y3+3U7JbeOfOYmdGRKCEy1l9JlHbwzf6eC7YVQKI=; b=rbEV+RBbUW86B193KEazdACq/Rn7+DuM/wuDkEO+1zRMOldTwSANyYVUIR7+VC5PIA vvVbmwLgeWBWShpbjGc6XbaTAbf5pPTK0CCB0IAkzgxhhh9/N+8ZFN0EjaNMJsHceFCx fe9/pQqdrye43/FbSoy9+l0ZwqFqgTvL8QRdZhrsvbLIPONQED8wORTvps5h4SdiQ4a2 Fl1+7sWa84b+vfK1zoBNbaGMs7F2K3fLrzXb5rSHNmJKdnotr78xNcaf36aNL3FaQw2d olKkVB6MIGjcfaPf63MltRBDxieUPuZi+LyMlKHshz25V3/aODyI2MbtWc3MYtGeVP7z Pq6A== X-Gm-Message-State: AOAM532KHOJUaRD0vHQnCmkbEejRQC9A9dbzNkKFP59iJ2Zjbn6wWSAJ Y+evndyKwbaskuhvL+V+gTRrMg== X-Received: by 2002:a17:90b:154:: with SMTP id em20mr3504443pjb.173.1597828096467; Wed, 19 Aug 2020 02:08:16 -0700 (PDT) Received: from localhost.localdomain (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id h14sm27511692pfk.195.2020.08.19.02.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 02:08:15 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com Cc: tuomas.tynkkynen@iki.fi, bmeng.cn@gmail.com, sjg@chromium.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH] virtio_blk: set log2blksz correctly Date: Wed, 19 Aug 2020 18:07:32 +0900 Message-Id: <20200819090732.155299-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean 'log2blksz' in blk_desc structure must always be initialized, otherwise it will cause a lot of weird failures in file operations. For example, fs_set_blk_dev[_with_part]() examines a block device against every file system with its probe function. In particular, ext4 file system's ext4_probe() will calls fs_devread() to fetch a super block. If log2blksz is 0, the actual 'read' size, i.e. block_len >> log2blksz, is much bigger than a buffer's size, and it can end up with memory corruption. Signed-off-by: AKASHI Takahiro Fixes: f4802209e59d ("virtio: Add block driver support") --- drivers/virtio/virtio_blk.c | 1 + 1 file changed, 1 insertion(+) -- 2.28.0 Reviewed-by: Bin Meng diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c index 992118c60758..1799f5c5eb36 100644 --- a/drivers/virtio/virtio_blk.c +++ b/drivers/virtio/virtio_blk.c @@ -115,6 +115,7 @@ static int virtio_blk_probe(struct udevice *dev) return ret; desc->blksz = 512; + desc->log2blksz = 9; virtio_cread(dev, struct virtio_blk_config, capacity, &cap); desc->lba = cap;