Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3464641imw; Mon, 11 Jul 2022 09:07:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sd/S2+eGsuJoHvYMISYa0RO0sluNN+yXABuiarn4vReZLUv4wVfiBzOLsD9JaQBEvfphuf X-Received: by 2002:a05:6a00:134e:b0:52a:d5b4:19bb with SMTP id k14-20020a056a00134e00b0052ad5b419bbmr3876559pfu.45.1657555674115; Mon, 11 Jul 2022 09:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657555674; cv=none; d=google.com; s=arc-20160816; b=oxE9LyQdvZjKz8FSYNibQTFWnFWMQSYpzRp1L2MCst5Y4rnZ+xxn8JDuKmvFEE9nVL fYdJtFYJpEYqyS9MYdCJwbP9GtNSKsDo4IdG2FbUpSbzuLXA54U71xlR5KPGoV8CXNLa 5pejs0dbgPd8ge/W1/bmh6ilnMtDan6dE8PB/QPph9CtPqc4XF2wsqfLBrbrJHGnTu+W cgmPcLC3xhTKAXieGM5VPgyX+0VVch2XE/wkXutx2pQcgppj09QARDigwX0iW7luNrjT o0rcR0OVuQ165/sPy4JvMFyn1RPT8GCo0n35MEJR/l6rLAaiTRXTOuRA4krIg0DpgIJ1 r0Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=8tw7+5o1eNNksdmkuvrSyMN7jBNIPnt7KKD+kh71+7w=; b=VOtPiKOpGVFyY9VOebLS9eCcuuy2CUhrHeGNLoI/rJ6COQ+58HIpd6ToBwtrRIPh0+ n/YCHLFit0UkfTAEkwkq2XBhuXEzes+3bPeqFqGa4JUVlBmA4+eOxyAi2yMN0k+pGzuW 5EnuXDoBPyJC/59Ex2bSiHJ24B+YNYAOQpG7OpDqT8J6OkUZtaAjnerJ+8NqyqQN1LoB PWVRu1bROJKDHcVpsNrTgxWehELqcFkVvNSFm434xKvTk/cqUqctkMF3JAV7vDMRiImS 5ebfdi/0y2nnhfa5SYcLa+SaYqZmdx5jlcMr16F6djeNQCjnrdWOu+vna7g4SobTFeui 3xUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=I1ZnIgnm; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a170902ccc400b0016b880a67bcsi10228111ple.579.2022.07.11.09.07.41; Mon, 11 Jul 2022 09:07:54 -0700 (PDT) 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=@infradead.org header.s=bombadil.20210309 header.b=I1ZnIgnm; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230402AbiGKQCk (ORCPT + 99 others); Mon, 11 Jul 2022 12:02:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbiGKQCi (ORCPT ); Mon, 11 Jul 2022 12:02:38 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9E05422F1 for ; Mon, 11 Jul 2022 09:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8tw7+5o1eNNksdmkuvrSyMN7jBNIPnt7KKD+kh71+7w=; b=I1ZnIgnm2ujuBsAUXF0WHAl0d0 SG/pigoiiZB4fSofQyGQoMQinBvx5eQKskB6k9vA+Hn2a51XL8DZ+DO5zbP7wEA1HZ/d1EQ8KwrFT CewerfxW5HiaABPrAeTGlKisjXXNnn0fYwjqxYnw3c43HGvp9plNVNC8vCUkYhk7cENYIjZfR7dK0 UeEd0CL1lpIbY6SlJLRvXb5v+4KegnJS2IdI9X6xApYjWNpliVZBJVt5Xb9vKulkJ13n8NmRb5dPt S0jqWIGoQo8BLwGZunT4OLly8jyIksrSkc3usX5DVdt6K/hQ9LV2bzvxsUU+Dh6OrKJI/Ct+cqtEH NFSonGEg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAvrg-0035XW-Hj; Mon, 11 Jul 2022 16:02:28 +0000 Date: Mon, 11 Jul 2022 09:02:28 -0700 From: Luis Chamberlain To: Adrian Hunter Cc: Aaron Tomlin , Arnaldo Carvalho de Melo , Jiri Olsa , linux-kernel@vger.kernel.org Subject: Re: [PATCH] modules: Fix corruption of /proc/kallsyms Message-ID: References: <20220701094403.3044-1-adrian.hunter@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,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 Mon, Jul 11, 2022 at 10:48:16AM +0300, Adrian Hunter wrote: > On 2/07/22 00:40, Luis Chamberlain wrote: > > On Fri, Jul 01, 2022 at 12:44:03PM +0300, Adrian Hunter wrote: > >> The commit 91fb02f31505 ("module: Move kallsyms support into a separate > >> file") changed from using strlcpy() to using strscpy() which created a > >> buffer overflow. That happened because: > >> 1) an incorrect value was passed as the buffer length > >> 2) strscpy() (unlike strlcpy()) may copy beyond the length of the > >> input string when copying word-by-word. > >> The assumption was that because it was already known that the strings > >> being copied would fit in the space available, it was not necessary > >> to correctly set the buffer length. strscpy() breaks that assumption > >> because although it will not touch bytes beyond the given buffer length > >> it may write bytes beyond the input string length when writing > >> word-by-word. > >> > >> The result of the buffer overflow is to corrupt the symbol type > >> information that follows. e.g. > >> > >> $ sudo cat -v /proc/kallsyms | grep '\^' | head > >> ffffffffc0615000 ^@ rfcomm_session_get [rfcomm] > >> ffffffffc061c060 ^@ session_list [rfcomm] > >> ffffffffc06150d0 ^@ rfcomm_send_frame [rfcomm] > >> ffffffffc0615130 ^@ rfcomm_make_uih [rfcomm] > >> ffffffffc07ed58d ^@ bnep_exit [bnep] > >> ffffffffc07ec000 ^@ bnep_rx_control [bnep] > >> ffffffffc07ec1a0 ^@ bnep_session [bnep] > >> ffffffffc07e7000 ^@ input_leds_event [input_leds] > >> ffffffffc07e9000 ^@ input_leds_handler [input_leds] > >> ffffffffc07e7010 ^@ input_leds_disconnect [input_leds] > >> > >> Notably, the null bytes (represented above by ^@) can confuse tools. > >> > >> Fix by correcting the buffer length. > >> > >> Fixes: 91fb02f31505 ("module: Move kallsyms support into a separate file") > >> Signed-off-by: Adrian Hunter > > > > Queued up thanks! > > > > Luis > > Thanks for processing this. > > I notice it is -rc6 and I do not see it in Linus' tree. This is a fix > for a regression, shouldn't it be included in 5.19? Yeah sorry this will get to Linus today. Luis