Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp150171pxm; Tue, 22 Feb 2022 08:00:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCGk0CApvVI98ncFfW+TC/NXea9yxg0PqiYPTZbTkjc5MnzUW918QNg2fvmZLrVcN4oK2O X-Received: by 2002:a65:6a13:0:b0:373:14f6:5d33 with SMTP id m19-20020a656a13000000b0037314f65d33mr20266225pgu.62.1645545609405; Tue, 22 Feb 2022 08:00:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645545609; cv=none; d=google.com; s=arc-20160816; b=iDL7tljX7CJOkIl6z99Tw08hlPKox64ZMbAtAPBGbcMZvkcqDrKaqJvTOwE2+8l4++ XN0cLqwhKZL1yZVoqPy29I/i+gAKfT1tno66zSpF+UutDvpN8ueA7DP/K06IzW5ZqK2g TgtdubYOdbHhZe9KbXQQm/Yxzw25xKOaVTda4/vr0MWbud0P8bQ69fDjQuwJMbKfXwzh W81yyiQjz8w40nlx5HSIQpxZ76qSt9rfv396MGg9mgQuvElbfA22FFNOP9aLRkS9TU+x YEGCX2vDxmaT0eAeC346gYZOxZZP+FTNTX1shmI6gXRVRGK5pPuZ4GeVxLTKWnAkkD7k HsZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=Ex20pGdyVA6rdZa+N+dbyBUHdPBBAkWrdlc+5TIlRVw=; b=JEPuGuQdxJpF6cpBljq7Wn5vXQF+w3AfvHVMyTBZYqm8pZdFgiUSKfC3d6DaaJZuH9 Ru1gcDvWfHkQTaNkddil+ES+1PZeSNVbuMtjFeegiRleMcAk29QNzBW9gam1Sj9ojNGa tJ/I1VNj87FI15YDVcGixFZ51VN7/FZqf4qfO7SlrFpYMC2mou4P4c+UkM9aCoga2Rp9 fkmZGmmYUenJHdRaBqm4SIrK03HD1ljx0ygKtJGDzbTK0owfqhIMw3zwQEIibo16gOk5 TOoZphdeDLbPXkdhveLJ1W8U0mPYN+Io9hPz93Pyp4KZQFXDjjHt4qf+MweLEnulgMdl jLEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=LZj1lTQW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17si33593472plh.123.2022.02.22.07.59.52; Tue, 22 Feb 2022 08:00:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=LZj1lTQW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232723AbiBVOHZ (ORCPT + 99 others); Tue, 22 Feb 2022 09:07:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232550AbiBVOHV (ORCPT ); Tue, 22 Feb 2022 09:07:21 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 237C7583B4 for ; Tue, 22 Feb 2022 06:06:46 -0800 (PST) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (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 smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 7EFD83FCA5 for ; Tue, 22 Feb 2022 14:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645538769; bh=Ex20pGdyVA6rdZa+N+dbyBUHdPBBAkWrdlc+5TIlRVw=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=LZj1lTQWYAuXyOw8wPcwYXN57oHdRLVT9Zx7hDEThfmdURtJXyXj304gTuNmsiX6C qi3rImXtthv/qtln2EnHrAJo+RmXE2SUrvJrCm0vpN94dPZUDSkQY3A4kia09D8RgI XasGZm7RvAfVG0d1ltt0lfmdHfri7AbcZfsTPWOCcxKJ3Sh93S72HwtCtFeHD1Tfys T/ciF2fpg/bOsy5NcS2/Tyqmm/COZmi3CXoCiyAt9u9zXbtt7vtBhpLWYyWDtdTI6F h0iAFHZ/9bZV3HYZrk+8+g2rYjZwYoVBzzOG+PWjHIc8L0QJNi9oJM5w493DS+tCad Hjg8ocD+6UnJQ== Received: by mail-ej1-f71.google.com with SMTP id v2-20020a170906292200b006a94a27f903so5827692ejd.8 for ; Tue, 22 Feb 2022 06:06:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=Ex20pGdyVA6rdZa+N+dbyBUHdPBBAkWrdlc+5TIlRVw=; b=4dIMRvbVGMxRpzbJymriWvZqhM3ulV6Og2fHgQe6CbfA6iH0NfeCepTmSrdeyOus+8 5XiAUBZ/x5dp/29azkWt7jo8FPJ2FrdrqZ0Pth1/17rqe8JgWuWqxCN8teyvqFndNoje Ifx1oa6E+kxtu8Zwqw40H6GGtv/FRlEw/1jez8yET6zfwbicH56wUcUnZlD6H15XFlX1 zrC/G86ZqMciO/Al3eqSJjXNMzcwQJHn5M2UIN+JXhHRvczebJgsnNJvaHIMotHT/81Y dzzplq4nYWQbpXJSPoil3lZMSOiaSz3ZliAQH+pW3ImmmTl/jUOL5JyyhqV0xU/eiAcs Wpjw== X-Gm-Message-State: AOAM5326WYHiAfqYLPrtJ//sB2HefpDJxs5byvN51W6cllpJSaIzXhi0 0/bbQhAvHef1CFTdwcFnfysdhKx7xX7hgGFawJU4EEeOP2zOcGS0G3uktTl8S3l3BvnNa5l1I+F CudVb3QuK9Tfm25n/KLy7cx4QVbVoAyDoXkDUA/m22w== X-Received: by 2002:a17:906:bc46:b0:6cd:e855:18fc with SMTP id s6-20020a170906bc4600b006cde85518fcmr18907781ejv.263.1645538769163; Tue, 22 Feb 2022 06:06:09 -0800 (PST) X-Received: by 2002:a17:906:bc46:b0:6cd:e855:18fc with SMTP id s6-20020a170906bc4600b006cde85518fcmr18907772ejv.263.1645538769004; Tue, 22 Feb 2022 06:06:09 -0800 (PST) Received: from [192.168.0.124] (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id z11sm2185298ejr.99.2022.02.22.06.06.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Feb 2022 06:06:08 -0800 (PST) Message-ID: Date: Tue, 22 Feb 2022 15:06:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [RFT PATCH 0/3] Fix kfree() of const memory on setting driver_override Content-Language: en-US To: Rasmus Villemoes , Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Bjorn Andersson , Mathieu Poirier , Andy Gross , Srinivas Kandagatla , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org References: <20220222132707.266883-1-krzysztof.kozlowski@canonical.com> <708eabb1-7b35-d525-d4c3-451d4a3de84f@rasmusvillemoes.dk> From: Krzysztof Kozlowski In-Reply-To: <708eabb1-7b35-d525-d4c3-451d4a3de84f@rasmusvillemoes.dk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/02/2022 14:51, Rasmus Villemoes wrote: > On 22/02/2022 14.27, Krzysztof Kozlowski wrote: >> Hi, >> >> Drivers still seem to use driver_override incorrectly. Perhaps my old >> patch makes sense now? >> https://lore.kernel.org/all/1550484960-2392-3-git-send-email-krzk@kernel.org/ >> >> Not tested - please review and test (e.g. by writing to dirver_override >> sysfs entry with KASAN enabled). > > Perhaps it would make sense to update the core code to release using > kfree_const(), allowing drivers to set the initial value with > kstrdup_const(). Drivers that currently use kstrdup() or kasprintf() > will continue to work [but if they kstrdup() a string literal they could > be changed to use kstrdup_const]. The core here means several buses, so the change would not be that small. However I don't see the reason why "driver_override" is special and should be freed with kfree_const() while most of other places don't use it. The driver_override field definition is here obvious: "char *", so any assignments of "const char *" are logically wrong (although GCC does not warn of this literal string const discarding). Adding kfree_const() is hiding the problem - someone did not read the definition of assigned field. Best regards, Krzysztof