Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3892536rdg; Wed, 18 Oct 2023 08:53:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDaOIu/Z294ZNupYbu5UyCjXFkzSAl0TTYgSBcu7ydGdZbu1FfPUmLdnNZ/gkEmKsGCsad X-Received: by 2002:a05:6a00:1354:b0:6b8:2ef3:331d with SMTP id k20-20020a056a00135400b006b82ef3331dmr6065545pfu.10.1697644384601; Wed, 18 Oct 2023 08:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697644384; cv=none; d=google.com; s=arc-20160816; b=Duk0BsAAkuax1JccW32MidrNC5LKaCcqCVxNJ7nQES6xCj8Y/TktaycFnjFd9Vky8Z JtCReaPUwj+P7F55ehnTZrukFMWaCS3iNelX5Lk8eCwc7X57G3OUMH/U+lPsw6nIG8QT hboSWF05sVXLnyg/SYoCtO1idTFJWKDAiFhBhLKafTN1EEtBE5y+qTHTmCyFTy/qfGyA o+1HQlVYK2tZ6Fw3q4/v0uDONDGcW4lqrWUzzk/10l+9gEJsiOc5dff0iVDFZCsNcaok Stqc0Q2WueIh/M5wmE3neubZO/MD2I75lm/PosBedzNfrkXKVxrT31KLf2UTYEKwRUAM YDOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Lly2Ci8Bkg7FLOPJxeauaJxOsPE7Z1Taiy+2I4YevvM=; fh=ffpO0dbyf5OrQ+8fxCAUHL2zW1A0gWLMLBKrbx8JUT4=; b=0DzK9Ff35VuOzKuxAHbu2Q/4kQMQ5FT6F1fYF8VZgzthsN6FWKeisuD6+3hILqCEBd aJeV1Wo01Prgj7AFhWkXa/9I1lYrXHISm74wnla0SQdZCOGHyTN1I/V9uJVb2YXAPwDg 4RjOgYyEpl1TAt8T/ngVR0rP/RgK8gEEnEkFXyAri7XCjr9PFs3Gfo1zFrEnr4l/ULLf XxDQ20+u+C9rk72Kd0QH3Z8GJAmNca9uk14+shPOgoQ/CcuJHWe6hSJRGZuDrCBYIuBN 5VpskA5zVJQpLLOzBgE2Xj3jzrGQ5kLjVstrWkNjwQJjRTwk30+ClN+So6zW2GZly1YV sqvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="DDurZJ/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id v67-20020a626146000000b006bd92819450si1833731pfb.170.2023.10.18.08.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 08:53:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="DDurZJ/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B37D980C6DC1; Wed, 18 Oct 2023 08:53:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344810AbjJRPww (ORCPT + 99 others); Wed, 18 Oct 2023 11:52:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232289AbjJRPwv (ORCPT ); Wed, 18 Oct 2023 11:52:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F9A9123 for ; Wed, 18 Oct 2023 08:52:50 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3CE7C433C8; Wed, 18 Oct 2023 15:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1697644370; bh=b8LsAR2QdX3IC2gaSa678S7SamLDd+g6f++6ZqtXOmU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DDurZJ/tH9/Dcq2NUUAnR7bwtgDl5thIrctfw+s4q4F7B9z+LCEL9V4leztRfz6Oy QN+ti9o7Lk4il2Xp2hnzjsN60DUZJkyYwxwhGWgCcp/J6tv9XrZpdoii3QHMM6q8IS FBIF1WP+glbZTrUhUIkqwPEPvI4kpzhkxsSOShA4= Date: Wed, 18 Oct 2023 08:52:48 -0700 From: Andrew Morton To: Baoquan He Cc: Dan Carpenter , Philip Li , oe-kbuild@lists.linux.dev, Lorenzo Stoakes , lkp@intel.com, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, Linux Memory Management List Subject: Re: mm/vmalloc.c:3689 vread_iter() error: we previously assumed 'vm' could be null (see line 3667) Message-Id: <20231018085248.6f3f36101cbdfe0990c8b467@linux-foundation.org> In-Reply-To: References: <89caf59a-d3b9-409d-b1ae-9e370cb9ee7d@kadam.mountain> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 08:53:01 -0700 (PDT) On Wed, 18 Oct 2023 23:15:31 +0800 Baoquan He wrote: > From: Baoquan He > Date: Wed, 18 Oct 2023 22:50:14 +0800 > Subject: [PATCH] mm/vmalloc: fix the unchecked dereference warning in vread_iter() > Content-type: text/plain > > LKP reported smatch warning as below: > > =================== > smatch warnings: > mm/vmalloc.c:3689 vread_iter() error: we previously assumed 'vm' could be null (see line 3667) > ...... > 06c8994626d1b7 @3667 size = vm ? get_vm_area_size(vm) : va_size(va); > ...... > 06c8994626d1b7 @3689 else if (!(vm->flags & VM_IOREMAP)) > ^^^^^^^^^ > Unchecked dereference > ===================== > > So add checking on whether 'vm' is not null when dereferencing it in > vread_iter(). This mutes smatch complaint. > > ... > > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -3813,7 +3813,7 @@ long vread_iter(struct iov_iter *iter, const char *addr, size_t count) > > if (flags & VMAP_RAM) > copied = vmap_ram_vread_iter(iter, addr, n, flags); > - else if (!(vm->flags & VM_IOREMAP)) > + else if (!(vm && (vm->flags & VM_IOREMAP))) > copied = aligned_vread_iter(iter, addr, n); > else /* IOREMAP area is treated as memory hole */ > copied = zero_iter(iter, n); So is this not a real runtime bug? We're only doing this to suppress a smatch warning? If so, can we please include a description of *why* this wasn't a bug? What conditions ensure that vm!=NULL at this point?