Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp920818rwd; Thu, 8 Jun 2023 09:25:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4sDXtRhWKfZqa9m0eP48QgtCFo5kTIwD9icYKtAxRocfO+W9ugxHFFUKzrDvGJ9/9Iwu4X X-Received: by 2002:a05:6a20:8413:b0:102:7c37:aef2 with SMTP id c19-20020a056a20841300b001027c37aef2mr4690410pzd.58.1686241546181; Thu, 08 Jun 2023 09:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686241546; cv=none; d=google.com; s=arc-20160816; b=zvS9PfzDCCczKB1RnvrGUSLifiYXadaCwg0F2Zomf6yUUDiwGUwvVdetXDwUA8xBkk 8styarq1qf535Lfl40ftYW353MdRJgIBTaP1aqBg5QGKYXijTvOmSfeGnbdtmWIDMsWn 1QPw7A87NNJXxu7juQykKwpmwo+7aAdtptJifA3Xkfbhae6EM+TjhNVn1fqrZ3ocQFGU keFELU72h7rxl1Sk+ZR3bUkMpJbk+i4VFWkLbrfkehzQngRaVv5N18j8UibUUzsbpBxl XsGsucZSPrWwsVyzgFW4+rY6G16iUV5CBAnqGsvkBdPAx2ttedPvp4AlEiSaDo425Hmt CC0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zWIW8U7Z6M0/bm3B8XzgMdly8W6lJnKCOG/8yWAgoUM=; b=UEYXZlLUsuOevvA/sfnRQnDAQ4epy6VQ920MmneaU3piGFZEYV7PumGurYv1YWoUwB dsFukk3KZD3BgHctyBJPu3uFPoJWm8WzOdjp1xnlz243g/Go5/VyD/mF1Ut2b/kuexd9 dZ3JB4nzYceNIf2L9CRO1gVCrD+ffY3JJJ/vEtCf9sQkqhDtZTC1G1KDihTPZcYvVnzF /lepOYW12FIK/BYqHJQae8D5R3pvrk92NbwjnkWlWKVUeeWNr96eKIJavVTn15XLgpIl 9St6n6qHuclgNurPY2CKn49rGUXqnfCZFv7oM1I2qWUcCyxnPpM0YSWacrZVlP8WlWZa LfqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TRW6izjx; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u186-20020a6385c3000000b00520dfb861fbsi1192926pgd.416.2023.06.08.09.25.31; Thu, 08 Jun 2023 09:25:46 -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=@linuxfoundation.org header.s=korg header.b=TRW6izjx; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233602AbjFHQTl (ORCPT + 99 others); Thu, 8 Jun 2023 12:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233578AbjFHQTj (ORCPT ); Thu, 8 Jun 2023 12:19:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EC0E11A; Thu, 8 Jun 2023 09:19:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F1E4F64B2E; Thu, 8 Jun 2023 16:19:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D634BC433EF; Thu, 8 Jun 2023 16:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686241175; bh=TOwT0GuJCz2bKXbQWOs8IqmDNX1diLd0cKOY/ea6+9g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TRW6izjx7+VO0YQ7ZXQ7nXFDTCyvOCxELhItwX4djo6jBb0usZ+WJ4ThHAzlHba9d z85IjLzhK3CoEMQXIt6RJkx3nDPQE+FmFRJpUNpIgFfizrchWjnEY6eNH6FQMyWiu1 23uqEAjCd0U4Dz0N5FLleaTbsVmKEbaZoS9WJjLk= Date: Thu, 8 Jun 2023 18:19:32 +0200 From: Greg KH To: Petr Mladek Cc: Kees Cook , Richard Weinberger , linux-hardening@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend Subject: Re: [RFC PATCH 0/1] Integer overflows while scanning for integers Message-ID: <2023060820-atom-doorstep-9442@gregkh> References: <20230607223755.1610-1-richard@nod.at> <202306071634.51BBAFD14@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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,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 Thu, Jun 08, 2023 at 05:27:40PM +0200, Petr Mladek wrote: > On Wed 2023-06-07 16:36:12, Kees Cook wrote: > > On Thu, Jun 08, 2023 at 12:37:54AM +0200, Richard Weinberger wrote: > > > Hi! > > > > > > Lately I wondered whether users of integer scanning functions check > > > for overflows. > > > To detect such overflows around scanf I came up with the following > > > patch. It simply triggers a WARN_ON_ONCE() upon an overflow. > > > > > > After digging into various scanf users I found that the network device > > > naming code can trigger an overflow. > > > > > > e.g: > > > $ ip link add 1 type veth peer name 9999999999 > > > $ ip link set name "%d" dev 1 > > > > > > It will trigger the following WARN_ON_ONCE(): > > > ------------[ cut here ]------------ > > > WARNING: CPU: 2 PID: 433 at lib/vsprintf.c:3701 vsscanf+0x6ce/0x990 > > > > Hm, it's considered a bug if a WARN or BUG can be reached from > > userspace, > > Good point. WARN() does not look like the right way in this case. > > Another problem is that some users use panic_on_warn. In this case, > the above "ip" command calls would trigger panic(). And it does not > look like an optimal behavior. "some users" == "most major cloud providers and a few billion Android phones" So in pure numbers, the huge majority of Linux systems running in the world have that option enabled. So please don't use WARN() to catch issues that can be triggered by userspace, that can cause data loss and worse at times. thanks, greg k-h