Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3637842pxb; Mon, 9 Nov 2020 17:12:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9wnCmKsFWqxEDeJAVUBmdE6FG5x9j8uyA1rGeQ74kJ4rEoAtvKoFEVodBI3088IhEte+k X-Received: by 2002:a17:906:f8c5:: with SMTP id lh5mr8823663ejb.77.1604970725595; Mon, 09 Nov 2020 17:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604970725; cv=none; d=google.com; s=arc-20160816; b=UwspHvi4oDiA0r0xZzQmLSuJAFGiW+p36dc+SGG9UmRHQI1BtMCByUUWJLcVpDfs8f LEXPmNPLxaHH6W15oAEIJEKMmGWivQO2t1tpnYDLF1/7UmEYfovz2GoiJKF/Z5eCSUtX EIf/wiWMc1Z9GpgDo4LdfKLManwJbz66TUwkZL6g+2aqf74B+C2BDeveeqIOI0HsN0xx bS1RynMB2ekY4FPZ0HHUhzudnBpQaDi1TTmNWHNKqrPTXygzSlgVbJM+L2Zfz4Ab2Ljj fAQNkP8lHD9vrJW9OftVQvcb++0FiiJdhoMWODjSTW/sM82uetdJybYgEdfdgfuDr8tL 895w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=mTXlKfTWyct7ELa6NUDaZ2WTzRPRy3oG569ol0gWKuc=; b=XwH/OW2F0s13ZTQWiRVU1roBteXUisyeGic3VZx2RXvqOtWs8GiJ5dsQITuIC/3xM2 2r+ab/U2rug1hSVuBUVvK0rkEmjx3oHfTVfOlQbH8ayjk/kE+9MOmI9AFg2YN72pero1 PAdt+Mmrw2Pwc8//wwfLjkuWBztj3j2TuZuwX/lfUWxeBnDZreYYVjXSlBT+zhejPTZO VcYFFsRCH/hFYVnSiRs3gbWUjg2bhhpWW16o9IbUo1b9QTW/YbpJu3C4rnKwiorUAuRd XHETbp3iiJ652QKnzQPOrgw5NABMt/HJdk0RtFAer9oYCfOUGxfluwuv3+FJ3ZQlWY8k B9KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IJDECUgI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si8238386edh.74.2020.11.09.17.11.42; Mon, 09 Nov 2020 17:12:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IJDECUgI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730762AbgKJBHU (ORCPT + 99 others); Mon, 9 Nov 2020 20:07:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27982 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727311AbgKJBHT (ORCPT ); Mon, 9 Nov 2020 20:07:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604970438; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mTXlKfTWyct7ELa6NUDaZ2WTzRPRy3oG569ol0gWKuc=; b=IJDECUgIPK6qu/R/jc0ehpuENmBP1E8kK/Qh9gm39ZRjYHkdKdTa8/S0KWD1CjKCLcXAQt ubR5rX2hci5ML8kRhmDbvLnU7YVnMyPHVw8PyQOzLVFt+5x+72nxIdb1QqW8Q0vPAQvjDh yZRcHcqceJgYTxI9T9mC6/KZV8gk0gk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-471-n82JQp1uOrCTpvc-D-ELlg-1; Mon, 09 Nov 2020 20:07:14 -0500 X-MC-Unique: n82JQp1uOrCTpvc-D-ELlg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF1AD56C2E; Tue, 10 Nov 2020 01:07:12 +0000 (UTC) Received: from ovpn-66-145.rdu2.redhat.com (unknown [10.10.67.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id B433C100238C; Tue, 10 Nov 2020 01:07:11 +0000 (UTC) Message-ID: <737d5be9eb5af55b1a61bd8bfb49b1829a3ff916.camel@redhat.com> Subject: Re: [PATCH][next] cpumask: allocate enough space for string and trailing '\0' char From: Qian Cai To: Colin King , Paul Gortmaker , "Paul E . McKenney" , Stephen Rothwell Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Linux Next Mailing List Date: Mon, 09 Nov 2020 20:07:10 -0500 In-Reply-To: <20201109130447.2080491-1-colin.king@canonical.com> References: <20201109130447.2080491-1-colin.king@canonical.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2020-11-09 at 13:04 +0000, Colin King wrote: > From: Colin Ian King > > Currently the allocation of cpulist is based on the length of buf but does > not include the addition end of string '\0' terminator. Static analysis is > reporting this as a potential out-of-bounds access on cpulist. Fix this by > allocating enough space for the additional '\0' terminator. > > Addresses-Coverity: ("Out-of-bounds access") > Fixes: 65987e67f7ff ("cpumask: add "last" alias for cpu list specifications") Yeah, this bad commit also introduced KASAN errors everywhere and then will disable lockdep that makes our linux-next CI miserable. Confirmed that this patch will fix it. > Signed-off-by: Colin Ian King > --- > lib/cpumask.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/cpumask.c b/lib/cpumask.c > index 34ecb3005941..cb8a3ef0e73e 100644 > --- a/lib/cpumask.c > +++ b/lib/cpumask.c > @@ -185,7 +185,7 @@ int __ref cpulist_parse(const char *buf, struct cpumask > *dstp) > { > int r; > char *cpulist, last_cpu[5]; /* NR_CPUS <= 9999 */ > - size_t len = strlen(buf); > + size_t len = strlen(buf) + 1; > bool early = !slab_is_available(); > > if (!strcmp(buf, "all")) {