Message ID | 20241204180224.31069-2-ryncsn@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48E7AE7716D for <linux-mm@archiver.kernel.org>; Wed, 4 Dec 2024 18:02:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF5836B0083; Wed, 4 Dec 2024 13:02:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA5DE6B0088; Wed, 4 Dec 2024 13:02:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1E946B0089; Wed, 4 Dec 2024 13:02:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7FE5B6B0083 for <linux-mm@kvack.org>; Wed, 4 Dec 2024 13:02:38 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E37151C7DD8 for <linux-mm@kvack.org>; Wed, 4 Dec 2024 18:02:37 +0000 (UTC) X-FDA: 82858046502.16.1C13B16 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf18.hostedemail.com (Postfix) with ESMTP id 41D751C0027 for <linux-mm@kvack.org>; Wed, 4 Dec 2024 18:02:29 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bCwgLDSg; spf=pass (imf18.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733335349; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7V53GFvkYgl3GGn7NQiYaXdsYVvKlvlq6z/L7Et1GuE=; b=6Y9zh7QItIJRvYOLZq1R9Vuv4YiG7/n7fUVGmk2qF0IQXLm8D9hsQttHkLxejlahHIJ3s0 IOlcBwGT1p8OCq66IEsL3y5og/UtkWC7KoDuMgbKZ5AabVJ4EjtouRBlc0yCwIvLSfZjDA Et5kwkgRGDz81BpAeCPqEjutsWr6CSM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733335349; a=rsa-sha256; cv=none; b=4VjFQn1XFGZwGuIQ7JLHRHuPZSrU5deZZO2YiDVZ+p+Gn1hVJIGv8YjZLmGJTeuPEoMCZe m4DLO27K71GLJMi2IfJlU1ecp0YthPibhBUSo+nVA2Nq83w9L4nOub3WpUFCmvCcUGdkuM 6/lVQWd2kBVgjYOgng+e1gsQv3fABCY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bCwgLDSg; spf=pass (imf18.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7fd10cd5b1aso52858a12.2 for <linux-mm@kvack.org>; Wed, 04 Dec 2024 10:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733335354; x=1733940154; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=7V53GFvkYgl3GGn7NQiYaXdsYVvKlvlq6z/L7Et1GuE=; b=bCwgLDSgo85SCymms0Z/5ND8KgekAjugWKW9/ryorbpawH3MAbW/yZ6OodRVrf+Hni 52X4ffh1N/PwHK69ol2VxE20fk5BcJBLMVLCqDVnnW9pgctzjecLVNWWTN4dMDHVMLw6 AkbWn1DW3nrg/UKQgXrR7aTjEPw5JC9th6OsXUL3+WV8nhER4D4bzyGtVvtLuDsVWIfs Za5Wo82X803DKMP7qP3iURjfrvWs1yUz7q8h1TI3lH5C122tMQ8RzE81OuuQYq/b7xdj 2vVZrfKghYo/LAXKL8hp9C/Go+nJnYWksKYoH7ecfQf3/MlBkY4e6RMtFkBCkVso6tfF TQuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733335354; x=1733940154; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7V53GFvkYgl3GGn7NQiYaXdsYVvKlvlq6z/L7Et1GuE=; b=JaGr1gLNFpCiBUebamTVmUS5Ly/JE7Bi/4v6cGhOKkmcsyhL1oL7k+xUS8R6lkJC5q 5uyYHeZhSuM+spPxEermw/tVZRrjM5YpNIP5um+PxBijlHBp9vsuKqD6O6hl+RnxKeWs k/aJ6uCUSqLP8/Awv7zvs0Pgd8ClFOZ+qVzbACmjjvhavg+1bk7imvKI38KYFZ+xJd3c u30LETz5aql8ryG37mgi8Pp4TfgvDTjYZWbfHY9qBLqAsNmd1nOocEw5eXCCwr5p0EhC uBQ7sW7MGWWlezigedOVMIszlPJQd861H99yXQ5FJuhk9b8KkFOhZxGZKeF5J6/QzFOY KD8A== X-Gm-Message-State: AOJu0YzBUXDvRKcwnLTmPs4Kl4sXuYtYl7j7MfIV2O78ac+Ws/gsN7QQ bUHfKPV+yGGWLamNjWaDcKLEQDjpz2P4ccro89jBozsHsCafv6Raxi/AL19k4/c= X-Gm-Gg: ASbGncu/GhC5zKn/iX0jhdP5UEKoIahvDsGjFScXKPz70nxwrq03PeGC7Azp4RZiJue OnFeYlkd++aNb1GIzJ36Swr9LbgLWwgCpg4EoGsZXs09vLfIs8zMDnv6taYk8jWxtOfdOF5bl1h GAdQDEUDTgmkZK0rZgPeA5mSj+OjQu+TvFgpRcO7jphCfeDJqgYsjEBZd8RW4Q3v0JToTZsSfjU NF0lfVrAD72VxTYbk7tHUypHGVFgDebKeYnPCYEwtaZPoSghCa6iu12Io/MMlbP/nBIgtU= X-Google-Smtp-Source: AGHT+IGfGswqHPS+sVCVBRyy6YYEmMkEmFcHRdeKF8fO4AaC3KytnZpu1qaS+nFgVW1qeM0JFQPoRQ== X-Received: by 2002:a05:6a21:330b:b0:1e0:d837:c929 with SMTP id adf61e73a8af0-1e16bdd32cemr8217439637.9.1733335353855; Wed, 04 Dec 2024 10:02:33 -0800 (PST) Received: from KASONG-MC4.tencent.com ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7258947b48fsm2064736b3a.47.2024.12.04.10.02.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 04 Dec 2024 10:02:33 -0800 (PST) From: Kairui Song <ryncsn@gmail.com> To: linux-mm@kvack.org Cc: Minchan Kim <minchan@kernel.org>, Sergey Senozhatsky <senozhatsky@chromium.org>, Andrew Morton <akpm@linux-foundation.org>, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song <kasong@tencent.com>, Desheng Wu <deshengwu@tencent.com>, stable@vger.kernel.org Subject: [PATCH 1/2] zram: refuse to use zero sized block device as backing device Date: Thu, 5 Dec 2024 02:02:23 +0800 Message-ID: <20241204180224.31069-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241204180224.31069-1-ryncsn@gmail.com> References: <20241204180224.31069-1-ryncsn@gmail.com> Reply-To: Kairui Song <kasong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam10 X-Rspamd-Queue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Dbjy5VFk u/W9lcND 2Xw+lpnvOioiFePKAcejHarN7EAdSFnE7rYbfUUO5VkqFEwNEYePDgBQPmSm7rNDcZnU1ip3CaUXrC9QFSv8ZXiLMxHFU4I66E1imnAKYNxbVd8ANm0SfQfSwkMnNxfhW1Qx27aP32GY++tFQBwYZpq/28bUcM+Ho3O6/2Z6oVJSurWw9EsB7KO1yMACYJMW7tU/BfXOUPmgsycQ8/DpLGsS82GZHiC6HfU1uomMnplm4I1CtnZ+oam1THcEFTskmGs/MihZq+DRaoMBgTnM5QPtwI4jxuLbbzE29Jl1TiPS0kaQE1YWLtENw3Sca4FKdKzQ+t36CTgYpUx/Tr7J5klRJUJqRtfc7dLRaxeQXosilbusWOxDaK7SrU1/+fuADeE1kp45CmUgSX3Z3DawV8Y1g7Lx3PgmhJ1KBCCLW3t5xUY9j0xWCRqZSlMgM2/Kp8MOWqOneWqTEKoChNtwVsspUpmIXhdff8fzNjJfXVU93FdPUYI1EV2nTwT6RI68CPa9vcs0m50lc1FkIpTJG6ml+CP4RbEE5ZS4thxXktm33ho3jRDf7/i6BA48btfr3rLfuvcQfQ/mk8rCdBGH9Uy3C1bMseyKSGGF2JaOxUS5AFYQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
zram: fix backing device setup issue
|
expand
|
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 0ca6d55c9917..dd48df5b97c8 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -614,6 +614,12 @@ static ssize_t backing_dev_store(struct device *dev, } nr_pages = i_size_read(inode) >> PAGE_SHIFT; + /* Refuse to use zero sized device (also prevents self reference) */ + if (!nr_pages) { + err = -EINVAL; + goto out; + } + bitmap_sz = BITS_TO_LONGS(nr_pages) * sizeof(long); bitmap = kvzalloc(bitmap_sz, GFP_KERNEL); if (!bitmap) {