Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp280427imn; Fri, 1 Jul 2022 15:07:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sl+Rs5rHfUMR4aHa8rfm9PddsmTI1gMA5yjKsb7n2G6SNhFRMiKtrzD5uK8Y1bwtawg+Gw X-Received: by 2002:a63:cb:0:b0:40c:a2b4:4890 with SMTP id 194-20020a6300cb000000b0040ca2b44890mr13924067pga.304.1656713270094; Fri, 01 Jul 2022 15:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656713270; cv=none; d=google.com; s=arc-20160816; b=CR2phsPhrlQyIyIfQui9qoAQRtp4UvhWcLey6TWFUMjuGpH+eQlq9yYYuszbC76Yaq pWhMcCwT5JzyGLAGOtLGF3iaqbopROxhlVyUhM9N09U+xyjyi8GB7yyrEfSQ0fInKfUm bNQoF8vK0V6JCXwIv0OYt99/+NNWdkVnGT22kzsZ1vPO4yjYGjHOfdolhmSo1vgGIp9b +QPQLGIS/Vii6Q/huOxZvmE7G95S4j/RQU3nkNq+Nw9AxKu3K42d0gtmJaBtpA5AnKyo sJMjOGAxsgcvW6omqZVT0SZIGcGK/8jqNjChSD71KgfsySHA2g2ZIpKN0dLxF3mFBsBY NnPA== 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=3V0/ZHeDnwpkrNjAz9hZP6JxPOkXktskzD7IxMyAcKk=; b=uLEWLaWN5UJn9oggqdGxyIo8ORwC88Zvc/OgCKhW9l9WpC2ZNy9FuC0WFFrRPkBiQ4 +UEUNB3GpgkeOIis/LB6obtgq0yjOdKiw0T4AlU6ciaIwzqKSijCncEcgkjKwC1BQlLE Op4mougBI2HQc9pkYjeCb26JQjx+NHl4IyrXguSZZ1aE58AhqVf8wXMGVqL/Z/ZfB007 62naxtLP9oojKDteFo07dWckVCIrWpRMQ8aVjEp6jV+yXow9yUjzfFtS25V0cz0mv2wK 4mdYbcHJZo59nJTmF4LwWxGVIOJ5s/3HmEa2/hDq2Nu8Y+sY+78yaOs3TgHr5Rok+iGq mY3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=RLFm8noq; 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 o10-20020a170902d4ca00b0016a11ae0396si6286695plg.347.2022.07.01.15.07.38; Fri, 01 Jul 2022 15:07:50 -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=RLFm8noq; 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 S230452AbiGAVlB (ORCPT + 99 others); Fri, 1 Jul 2022 17:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbiGAVk7 (ORCPT ); Fri, 1 Jul 2022 17:40:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11F5742EF0 for ; Fri, 1 Jul 2022 14:40:57 -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=3V0/ZHeDnwpkrNjAz9hZP6JxPOkXktskzD7IxMyAcKk=; b=RLFm8noq7YFbdJKokSNBcxO/kY TH9omDc7Hvbc1D1NXGmbgnsXskL9fmEe4OsLvbYsyHlGMaHa2oFQSplmBVj5vR1sKQqztfoUkUg0R OdkqBO6ViL9NdSQZivXNzpuLjIPo9/yDilCvBXSyHm1ay7Lnt1G+Az8OTLqM/CBFZbGWC9DOdpMl3 rvGqH28jwHKug2m6KHoB422uZbIm85NOeuKTdXzGryNhp7W6lfJXznw3ivHF4DDg/54R0PxpmvXuZ j3z8A0J7b4eWe8Yp4rdXwGVSccyFu16MD5AXoKwi6v23UWbDRgXMEU6v9/n+WQX5aoT2Auz3r7evJ IKXrNGfQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7ONd-0072zi-Fk; Fri, 01 Jul 2022 21:40:49 +0000 Date: Fri, 1 Jul 2022 14:40:49 -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: <20220701094403.3044-1-adrian.hunter@intel.com> Sender: Luis Chamberlain X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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