From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 52F2CC00A5A for ; Wed, 18 Jan 2023 02:17:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE61E6B0071; Tue, 17 Jan 2023 21:17:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C96816B0072; Tue, 17 Jan 2023 21:17:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5EB66B0074; Tue, 17 Jan 2023 21:17:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A67156B0071 for ; Tue, 17 Jan 2023 21:17:29 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6D070A215F for ; Wed, 18 Jan 2023 02:17:29 +0000 (UTC) X-FDA: 80366308218.05.6F9DB1A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id D0EBF80004 for ; Wed, 18 Jan 2023 02:17:27 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LC+sUflL; spf=pass (imf30.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674008247; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PP8025B7vYjGqOUOci8HcWNNJvoXEzim4g39pJBVbi4=; b=WhGzj4/Gar5qLak1pHmxf4fKAm6dzAu/zJvtB5gCXPF9O0eN10leb2+a2Qk0BeWiMXXPOC V1tg98VSBS8X8qiYmmaCacnv53qpqyrZm3O/p87Y76zUU9ijjohpMRvU0/YiNCcmtxCvc5 jk9Lub0fd41W/sygdEbKtkC6KnzwTu4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LC+sUflL; spf=pass (imf30.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674008247; a=rsa-sha256; cv=none; b=RWRPNty0zkaajSXp6EZ8LQcodSfkZjTSrVNeGDeb/C4D0Z0EcYPuPJtps28BVOPOhmFkTX xjcVNG/aFgbMIulaDZldRQKfCtJcMIeexxYaAhqOJiuYQfcyIUd3X22MP34OFsBBS2a5Vm oWOI5fsJyjXFVU8POYwXP1sBjFQpjow= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674008247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PP8025B7vYjGqOUOci8HcWNNJvoXEzim4g39pJBVbi4=; b=LC+sUflLUodZAKjSrR81l6wB3705QXIaYBL6K0wW1p96BWDyYcDoh8+K/3tgmwZl2bq3Xm 6+N91tQ/9tOzYis1B8TMELHjizYyBEkASs+dXHnV0TF8Hk31VB+RSonyDl7kKbcIpKEJRs BzxHpHCMxt0KOdYRKU6zu4dgHKP1bb0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-g9rajeCaO32cmZEiYBLGwQ-1; Tue, 17 Jan 2023 21:17:23 -0500 X-MC-Unique: g9rajeCaO32cmZEiYBLGwQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 403931871D97; Wed, 18 Jan 2023 02:17:23 +0000 (UTC) Received: from localhost (ovpn-13-29.pek2.redhat.com [10.72.13.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F504C159BB; Wed, 18 Jan 2023 02:17:22 +0000 (UTC) Date: Wed, 18 Jan 2023 10:17:19 +0800 From: Baoquan He To: Dan Carpenter Cc: oe-kbuild@lists.linux.dev, linux-mm@kvack.org, lkp@intel.com, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org Subject: Re: [PATCH v3 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Message-ID: References: <20230113031921.64716-4-bhe@redhat.com> <202301132345.KVjvHMFq-lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D0EBF80004 X-Stat-Signature: 8jp6e7ensa7doyd3uepeuxd8zmy63byw X-HE-Tag: 1674008247-393303 X-HE-Meta: U2FsdGVkX195eahg5YCMJ5NlGbkYOoUTdC1Tep37CilKL5wFHL+PR2M/v/j7FLKVsI46BKQS6eN0WA/zaib0exJ6XfTAwnOa3vFmaHeZYhcg89fYVDCuZpvu259MPqXqIwAxLqgfaIRBha1FjG3QnvcjpskjFdT8XYCYYMe8Wq9y/N+EPGwsIKbZOCUiIPOW2TUSCWTh3UpJPsZVrgpD0M0C7L8AU5YzJYTFhPqrbRIai1tvPzuy5gAzglcQPI8EXwXczWxY4hbH6klJOIxZSVzcVIMTAfcIu8AL6OD/DfbNxOgxWrgTFeRDWnF+zOVPyJR9sqIB4TaZ0SoI3PjgxGiUUSGKKZ9AsbyB5FJpVW7iQFYffICuChAyLykgZApdOttnoncUckrZ6KvfoN8aO7cCuf5+el83tipyTZeZDmxtGmycWWA1B/FECQ0x4VZRBp5g1CCYOi1ujGww/rtduscr3J2p/PRoJBO3RJuCJxca8C0M5gbiJGdZa342epHqAgoj+jU6gQg1aEr6YZqxhzT6JYsCYeXXph5A7C4MoDtbQR0cc3TGB2wJ/W1+OTrsqRv15nCzCr5Qfho8W7twVd85dFPztzrDc1CzuV++99EZyPd4lMTSGkAJ1U2O4l3oPO7C5rrzunwBSGVtVEmY/7DYJX/7NFn0FhEoJlZ7qgRAuCzU7oi1EvcWepdZrpuYhFw8cLKuK3KMMlb1rWia9oyakO1P47JjQqOEYFBjfrKRPX+0aKW6gJwLmjehVJCnxf15qtLn/gAMW0QipF3StRbVWoAOQUlRHamZdKAmbvqbwyZxCfrxbL/5RHdiKuMppmUQqYDXqS91hsOMKxzhtFGiOF5WjfSzj5tL0JzsbW0lIJIEJBHc/4/fzwnNnCIekhysV5DfcvOufijVS8dbvtFmyUYWSaTFhQSSkGQewW4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 01/16/23 at 04:08pm, Dan Carpenter wrote: > On Sun, Jan 15, 2023 at 10:08:55PM +0800, Baoquan He wrote: > > > f181234a5a21fd0 Chen Wandun 2021-09-02 3650 if ((unsigned long)addr + count <= va->va_start) > > > f181234a5a21fd0 Chen Wandun 2021-09-02 3651 goto finished; > > > f181234a5a21fd0 Chen Wandun 2021-09-02 3652 > > > f608788cd2d6cae Serapheim Dimitropoulos 2021-04-29 3653 list_for_each_entry_from(va, &vmap_area_list, list) { > > > e81ce85f960c2e2 Joonsoo Kim 2013-04-29 3654 if (!count) > > > e81ce85f960c2e2 Joonsoo Kim 2013-04-29 3655 break; > > > e81ce85f960c2e2 Joonsoo Kim 2013-04-29 3656 > > > 129dbdf298d7383 Baoquan He 2023-01-13 3657 vm = va->vm; > > > 129dbdf298d7383 Baoquan He 2023-01-13 3658 flags = va->flags & VMAP_FLAGS_MASK; > > > 129dbdf298d7383 Baoquan He 2023-01-13 3659 > > > 129dbdf298d7383 Baoquan He 2023-01-13 3660 if (!vm && !flags) > > > ^^^ > > > vm can be NULL if a flag in VMAP_FLAGS_MASK is set. > > > > > > e81ce85f960c2e2 Joonsoo Kim 2013-04-29 3661 continue; > > > > Right, after the 'continue;' line, only two cases could happen when it > > comes here. (vm != null) or (vm->flags & VMAP_RAM) is true. > > > > You're saying VMAP_RAM, but strictly speaking the code is checking > VMAP_FLAGS_MASK and not VMAP_RAM. > > +#define VMAP_RAM 0x1 /* indicates vm_map_ram area*/ > +#define VMAP_BLOCK 0x2 /* mark out the vmap_block sub-type*/ > +#define VMAP_FLAGS_MASK 0x3 > > If we assume that vm is NULL, VMAP_BLOCK is set and VMAP_RAM is clear > then it would lead to a NULL dereference. There might be reasons why > that combination is impossible outside the function but we can't tell > from the information we have here. VMAP_BLOCK has no chance to be set alone. It has to be set together with VMAP_RAM if needed. > > Which is fine, outside information is a common reason for false > positives with this check. But I was just concerned about the mix of > VMAP_FLAGS_MASK and VMAP_RAM. Thanks, I see your point now, will consider how to improve it.