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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD888C433EF for ; Fri, 5 Nov 2021 08:40:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B283A61263 for ; Fri, 5 Nov 2021 08:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232750AbhKEInY (ORCPT ); Fri, 5 Nov 2021 04:43:24 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:47642 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbhKEInY (ORCPT ); Fri, 5 Nov 2021 04:43:24 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 21422217BA; Fri, 5 Nov 2021 08:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1636101644; h=from:from:reply-to: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=E8vbIfEhNSovIv402nhTSkuyp8DaUowjHrlpN/9dLH4=; b=OtYQQNW2OnlpvxTXhmdbfNKMSq8w2a1QPjDkNMrPSgfSTcEt/xB6Bbs+V2LukWncv6y6aX N1c3PvLUeY4SHZ28KZsAYVMnvImeNxoaVKSlq4oyY/TQbJcclafuAmGnEoo0waCp9D3xAV fHIV/kxsoAWMYCwvEez+GUiN1wBD/+A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1636101644; h=from:from:reply-to: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=E8vbIfEhNSovIv402nhTSkuyp8DaUowjHrlpN/9dLH4=; b=L1f1s0EEgR/KS0cG/7276yrkSGvPwnkxB/r1NbehesKFbv3yAEQpx0gf31cMduy03DDpws sMhHBRmmmrJceDCw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id D948C2C150; Fri, 5 Nov 2021 08:40:43 +0000 (UTC) Date: Fri, 05 Nov 2021 09:40:43 +0100 Message-ID: From: Takashi Iwai To: Kalle Valo Cc: Takashi Iwai , Ping-Ke Shih , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Larry Finger Subject: Re: [PATCH] rtw89: Fix crash by loading compressed firmware file In-Reply-To: <87zgqjqaae.fsf@codeaurora.org> References: <20211105071725.31539-1-tiwai@suse.de> <87zgqjqaae.fsf@codeaurora.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, 05 Nov 2021 09:25:13 +0100, Kalle Valo wrote: > > Takashi Iwai writes: > > > On Fri, 05 Nov 2021 08:17:25 +0100, > > Takashi Iwai wrote: > >> > >> When a firmware is loaded in the compressed format or via user-mode > >> helper, it's mapped in read-only, and the rtw89 driver crashes at > >> rtw89_fw_download() when it tries to modify some data. > >> > >> This patch is an attemp to avoid the crash by re-allocating the data > >> via vmalloc() for the data modification. > > > > Alternatively, we may drop the code that modifies the loaded firmware > > data? At least SET_FW_HDR_PART_SIZE() in rtw89_fw_hdr_parser() looks > > writing it, and I have no idea why this overwrite is needed. > > Strange, isn't the firmware data marked as const just to avoid this kind > of problem? Does rtw89 have wrong casts somewhere which removes the > const? Yes. SET_FW_HDR_PART_SIZE() does the cast, dropping the const. thanks, Takashi