Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp877410imj; Fri, 15 Feb 2019 08:15:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IYhxG0UkYAd9LGuk18OqPM0NNC3VtlUtckcW4bYryVSpQa6imWOfg7sAQzSeR+WXIWZIVmV X-Received: by 2002:a17:902:b494:: with SMTP id y20mr11262820plr.178.1550247329334; Fri, 15 Feb 2019 08:15:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550247329; cv=none; d=google.com; s=arc-20160816; b=Jd3Bc/9p59k5loG7hTrb970NA3ApengIlG7viR4e6DrLj629gEo2qCoBuOAopoYdWV EX+GgfjYoO2Ob0HfvctOPdi34yFxtIAnaQqZD0pic4f+hZl/mHXsdEi47Hl36Pj/izpy GbRXlAbJJvo9/mdCuHgZJ7kYjvh2slihy690twBcPwBLsNsUDI9Nbg0/DUC8YZbqE/vg KAY3T4L1t1f1kLxNcX9ZM0iDMDkurQttMwU4aVLCrAXtDaXkUDyMC1jJvyKkE1yA+lmL Qcdh2OJ5nxxuoN2pGadUa/99NS+g5O/jeIakZfUVdftp/8u8JTMfdstqaVubQxhfO32D WK3w== 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 :message-id:date:subject:cc:to:from; bh=sKTOVVdGd5lbf+GfsN4zPGkM+mHzQi8CdGi+cNRu2LE=; b=bT9xZIu8zko0KOBbkXbT6uue/glEesC347l9Q9Aw/Mzd8pIpEGaQhPNkNsj7KRg1mK ZzwPU59zrBjFsEhRhITn5jLzKkvEYVoV8Dxbg+vFV/IZr+LwmZuxj1odBR6X5O81ctuz 6uDSnu9R6mBSXXS+xX+Qo5FUtlAQQ8Jcjl4WOo5dStJiYLIHLjBhLxrQXH8Teb+U0uoi FdRRcfuK2EnaofAXXrbollIHEh0O02TaVrXHLOJDOo3kxDNlRngxjd4r4qQJetDSZq/n mtuUPYTzx2bcF67hsrWs+/yi2BUukzCUPrnPEKj5u0qoIFM7TuzCKmjxD3tLgXtafqBN Qbhg== 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 o24si6390748pfa.34.2019.02.15.08.15.12; Fri, 15 Feb 2019 08:15:29 -0800 (PST) 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 S2405978AbfBOM2Q (ORCPT + 99 others); Fri, 15 Feb 2019 07:28:16 -0500 Received: from mout.gmx.net ([212.227.17.20]:42431 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405454AbfBOM2P (ORCPT ); Fri, 15 Feb 2019 07:28:15 -0500 Received: from localhost.localdomain ([218.18.229.179]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Ld0E0-1hKqgF41BI-00iDAT; Fri, 15 Feb 2019 13:28:13 +0100 From: Chengguang Xu To: gregkh@linuxfoundation.org Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, Chengguang Xu Subject: [PATCH v2 1/4] chardev: add additional check for minor range overlap Date: Fri, 15 Feb 2019 20:27:11 +0800 Message-Id: <20190215122714.28842-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:PuxX26Iwc4DsD6HQypaGn4HHmfiFlbvc+zDkpxeqQf07xuqc4qf uTMrJ+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Q8UyNWyARR/uWmhoOC4BqKPkBzpqcq8x9MbOXrIx2fAzVCeA 7BT/mFeF7z6ybs2GZASIBjY01tKonYjZtzizayk8nWVSfLJL+ssJaT1liCKV6j Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current overlap checking cannot correctly handle a case which is baseminor < existing baseminor && baseminor + minorct > existing baseminor + minorct. Signed-off-by: Chengguang Xu --- v1->v2: - Split fix and cleanup patches. - Remove printing minor range in chrdev_show(). fs/char_dev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/char_dev.c b/fs/char_dev.c index a279c58fe360..8a63cfa29005 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -159,6 +159,12 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, ret = -EBUSY; goto out; } + + if (new_min < old_min && new_max > old_max) { + ret = -EBUSY; + goto out; + } + } cd->next = *cp; -- 2.20.1