From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82A9822E3F0 for ; Thu, 8 Jan 2026 03:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767841986; cv=none; b=KYteUonvo+S7i+v9z2vY2Q0r/spFHS/wMuVVVJkyNyDVBngBJnumLM4gd28An7ga1BIPHf1vTS7NOoWhB7WDjguoXpgHpX47nhZJ8FSJK91XK0pnjwLvDTwti6XJz/OaCK2+CKg17i0E67GaNtJY6Tijk4TMVzfcMryaFxI8zTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767841986; c=relaxed/simple; bh=fe7d+qbaDY6YPOii9FuSS84J5s6xgxGlYPqdVJzJPI4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Fu7X132QSqNkMs/YEVx6ijIJk20xVm6FjP9NeGT4FEhNH1NYU+9xaWPfT2dA3nvucoKP/oUL5kSe3KbZZa2DpsTSs9AI0Iaz1YdnLDkw76y3tgjcY3Kg9Gv58ZBEg31gjx55tvMNfA3HdI9xC4PZYXzdg9HZSVCc85YZKNvp4ho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XZ3QQmad; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XZ3QQmad" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767841983; 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=TqkA5ZayFeDWxiqiqN+hD7LCP7d5sRCdB4Jg02yJh4U=; b=XZ3QQmadLtUt6NbvXBZDMzckqk69QDfTW2HHeu24Dd3NfhAXS4wRCvt1hHg1/UDaVnaDFW EdiMjKuK+XAlAjsPq6iJVcnt3GCxA9GrXvCSxSQ0dESQqemQB9zY/iKNPEptnx6LsBBAzV fMrTQnXXkyvWcHcsaWKgvW8g7AacMwI= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-360-4mEiVWWRMB-s2KIbFUWGeQ-1; Wed, 07 Jan 2026 22:13:00 -0500 X-MC-Unique: 4mEiVWWRMB-s2KIbFUWGeQ-1 X-Mimecast-MFC-AGG-ID: 4mEiVWWRMB-s2KIbFUWGeQ_1767841979 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A1A5F195608E; Thu, 8 Jan 2026 03:12:58 +0000 (UTC) Received: from localhost (unknown [10.72.112.41]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A20B319560A2; Thu, 8 Jan 2026 03:12:56 +0000 (UTC) Date: Thu, 8 Jan 2026 11:12:46 +0800 From: "bhe@redhat.com" To: David Binderman Cc: "akpm@linux-foundation.org" , "kexec@lists.infradead.org" , LKML Subject: Re: linux-6.19-rc4/kernel/kexec_core.c:425: Possible loss of data ? Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On 01/07/26 at 02:32pm, David Binderman wrote: > Hello there, > > Static analyser cppcheck says: > > linux-6.19-rc4/kernel/kexec_core.c:425:7: style: int result is assigned to long variable. If the variable is long to avoid loss of information, then you have loss of information. [truncLongCastAssignment] > > Source code is > > size = (1 << order) << PAGE_SHIFT; > > I have no idea how large order gets, but if it gets over about > 30 or so, then IMHO there will be a loss of bits. We may not need to worry about it. In all places where kimage_alloc_control_pages is called, the order is 0 or get_order(KEXEC_CONTROL_PAGE_SIZE) on mips which is 2. arch/mips/include/asm/kexec.h:#define KEXEC_CONTROL_PAGE_SIZE (4096 + 3*4096) [~]$ git grep kimage_alloc_control_pages arch/arm64/kernel/machine_kexec.c: struct page *page = kimage_alloc_control_pages(kimage, 0); arch/x86/kernel/machine_kexec_64.c: page = kimage_alloc_control_pages(image, 0); include/linux/kexec.h:extern struct page *kimage_alloc_control_pages(struct kimage *image, kernel/crash_core.c: vmcoreinfo_page = kimage_alloc_control_pages(image, 0); kernel/kexec.c: image->control_code_page = kimage_alloc_control_pages(image, kernel/kexec.c: image->swap_page = kimage_alloc_control_pages(image, 0); kernel/kexec_core.c:struct page *kimage_alloc_control_pages(struct kimage *image, kernel/kexec_file.c: image->control_code_page = kimage_alloc_control_pages(image, kernel/kexec_file.c: image->swap_page = kimage_alloc_control_pages(image, 0); > > Perhaps some sanity check on the value of order would > be a good idea ? Either that or > > size = (1UL << order) << PAGE_SHIFT; > > might be better code. That is fine if people is worried, a patch is welcome.