Message ID | 20241209165717.94215-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 1D468E7717D for <linux-mm@archiver.kernel.org>; Mon, 9 Dec 2024 16:57:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 940BF8D008C; Mon, 9 Dec 2024 11:57:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C6888D0058; Mon, 9 Dec 2024 11:57:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B6268D008C; Mon, 9 Dec 2024 11:57:50 -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 520428D0058 for <linux-mm@kvack.org>; Mon, 9 Dec 2024 11:57:50 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C7F371C7111 for <linux-mm@kvack.org>; Mon, 9 Dec 2024 16:57:49 +0000 (UTC) X-FDA: 82876026996.05.1EC54CC Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf06.hostedemail.com (Postfix) with ESMTP id 41CB1180017 for <linux-mm@kvack.org>; Mon, 9 Dec 2024 16:57:33 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Zl0a1Cfo; spf=pass (imf06.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.170 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=1733763453; 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=sUP+2JyKnLRQco8QsCJe4ce6gkYVIGp7F338G8iPtHg=; b=GhxXxLRPVkHB0X6WGUTIUj/n3s+W0RqRjHjDEjIUCCgUE6k9F//5fDENl/Zkzi7Q/jRwU7 C52ceZiDMD/rVMoVzQJFlTw2btxyIduenVDzcSNCgg3s+TjDPeROkLTBYzWBA6avsheBMF qUW2+VTqC6Qj3/QmjSJ/rrNeWXj1i4E= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Zl0a1Cfo; spf=pass (imf06.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.170 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733763453; a=rsa-sha256; cv=none; b=W25PhAsnkTi20BIWMsbQMRfP5dJLvCWaX75ICQZu431GrQ1XKha4uTFZmlotJKZVi0CLmw IOIgnxW2Qy6EDW0hiFGOBB9j0jdml7FGg0Zm2/UKsoKEJL5+OO2Vq34lvyFiz/wk6nJz0P iFgYvMLnXk9878z/Mf/HilT/cqyG40o= Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7e6cbf6cd1dso2566171a12.3 for <linux-mm@kvack.org>; Mon, 09 Dec 2024 08:57:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733763466; x=1734368266; 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=sUP+2JyKnLRQco8QsCJe4ce6gkYVIGp7F338G8iPtHg=; b=Zl0a1Cfo25m+BWVA7agj87epqVa4IaeqzeiPFfdTNfECn7KOHsxBupyrjP3dbG6lzw 2JeIj6GF3VaK0RB3spaPxmOBnUHtOq0Z68ODJTX1msg5ZyYpuDetkA8JUhJs8hm3tWm9 ehZNa6ix1nc8IxdxJbMhqjlRInrfUN6+sN6knAu52PufO6XIpJKlm4kr4JbIXgPVEAMf 6DBZB6Ta61KaCacGtAZV2Lf8d68fMMGuS3J2Q9f//nMGhXmGAJ5Inqagp2AAnUxtP1gN 24/778eoGbbjZAuCeGAQ7dohd4kQvx0lGRwLrdiDVx0N40/BrPLwY7+nBkfqkbLscchN 7NYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733763466; x=1734368266; 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=sUP+2JyKnLRQco8QsCJe4ce6gkYVIGp7F338G8iPtHg=; b=bQpYh7OMSYrbO1P9pX7XUtcIsPP/QyMu/IeaozraH7gazL/4Oi8aG2qnRnrKzYXGjw WwuVjvpeJvDSod2wQDZU4+1fD1QxL6IEIAu8fcWCbBccKdDdwtYVNLxGcvNQf78a9Rk6 fxLVR5sJHBaGJuEPnEpAJW+aCl/tSj2RMDwRXqPuGjsahP4wbTvfqy+qjvLJzKSREbNH uCMq5eGyi1e5uSVyd5MygZog6ihSpThS0d4LMPqngQAP5LG7/P3onevxp8fToX4HkM5t 9dbZCgPDmiNOVZKlHk7QGzIHciR+WFvChDfQ6nW82Zw/QgQ8bdrpNgyccoI54aAFVvRC K23Q== X-Gm-Message-State: AOJu0Yyny5tPn83oRdaUJMwEgcRMO2+aIH410fHuo55/FoWAzHFOeZzK 8AgqEfmbBKTtqdn8vzet7oRr+bF3iNn0AFDFr7ZFNFE0XCvbC2hepwJkPaHI19gExg== X-Gm-Gg: ASbGncs2yo4AolIWeZYE+zgQg4Ep5j2GB7UDyJaQ0hkc6zLHwDm7tae28fJW9bltzy1 Kba7BObbVjTEPFVjKTkddh8/b8Oy3psC+N94jo3pWjIVtK8dW7Q+MpukATooQCLJKRtNP7lW9Ed KBzEQqX8tgt4gPzgH1pTpoJvvEu8SO+Ze+egB0Cz7zOQubzfWOmjM+c2I0KNP9kmJdIhgD54ykw O4dYQA17NDWP/G5ubeN4W8IStUtihRQp16Vbnop4S5kfZEunRaAHa9NtAUr0VJ0XFdqx04= X-Google-Smtp-Source: AGHT+IFU9XNL4TYYMN57+MI1JthzbOjTs3oeXC9tvV2S1ujsyt7L/AjZO37t5fVZBxfj6fd+QgbvFA== X-Received: by 2002:a05:6a21:e88:b0:1e1:a6a6:848 with SMTP id adf61e73a8af0-1e1a6a60975mr9194204637.25.1733763466179; Mon, 09 Dec 2024 08:57:46 -0800 (PST) Received: from KASONG-MC4.tencent.com ([106.37.120.120]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7273c7f3f1fsm514201b3a.13.2024.12.09.08.57.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Dec 2024 08:57:45 -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 v2 1/2] zram: refuse to use zero sized block device as backing device Date: Tue, 10 Dec 2024 00:57:15 +0800 Message-ID: <20241209165717.94215-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209165717.94215-1-ryncsn@gmail.com> References: <20241209165717.94215-1-ryncsn@gmail.com> Reply-To: Kairui Song <kasong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam05 X-Stat-Sign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Ji ww9iwISxPtM09lg27XFsIEoLxCgd0+YoTq3O+iAK+RA0HY5jbAt+Ekoij8EAy1dzOYdOF4QPF1Qwr5ZKNsTbUr815fqMZaJ2JADS5ndXbBe19vgK8YxUuDmYtnEHthjHuK4yVKIWnnMNOY5O708BQP7KBnG9Is9O1c3u9DU9fKOVX5vovqDyBE4C8qZ44a+/HFHWVCPMC8AQVvtOs8rd4X8vxcnhdJUf/tlXAD7NgAhAQeb9BdTOF9inVwLaVJzk1SI2E6b5JuAwoszgK7l5gBG80jhntS6mlAjzrsQFKMKC0HajPQ3mpafEtUoV1wy7SQ1LOw29KS2myp9wGtktZ7w7k4VjQ/D2Rlyoa7Rr53Xgb0yXzDusngQ6tafGIgioGAeCyAh6u7PnPS8GV7bw0L6DcZHE87Hv14RM8nojDdJiXfxEBT2N20JgotyZu0YwQoucwXpSMIMT7AUerh18vTcsXhwqNnWFHJPyFz3HB6iCvrPWa33L3DYFLUuwBVor0A1UCuyjCNLa6tH/wuynXSdqZdZ2PfXm0hbAWZ1Q0ZqXnVhfF25f3LsFrxJ/Jm8n9t1Vn X-Bogosity: Ham, tests=bogofilter, spamicity=0.064919, 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 3dee026988dc..e86cc3d2f4d2 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) {