From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DE72C433E6 for ; Thu, 27 Aug 2020 22:26:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB5DD207F7 for ; Thu, 27 Aug 2020 22:26:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="K/syNsgg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727863AbgH0W0O (ORCPT ); Thu, 27 Aug 2020 18:26:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726826AbgH0W0O (ORCPT ); Thu, 27 Aug 2020 18:26:14 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1567CC06121B for ; Thu, 27 Aug 2020 15:26:14 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id i13so3388013pjv.0 for ; Thu, 27 Aug 2020 15:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=oiRYPTV9Xp4hDmIJl3FIgZQBNMfOgdOX8kJLpd9LdbA=; b=K/syNsggEMRL31WNQmgeGoNMQ/ehQnSpbyNXTjVkpgc+66YGK2IfWbpNNhuuLcOjgU S+FSsY+M1DHqAVEzjeOJ18Gp+tWus2d9m98Y/uDDwORzyIO48JoP1+9BOG2S2x3cl0Bb ilXVhL9PIdDhs3FFbbAu3iwYjyIdlqBMEhhSA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=oiRYPTV9Xp4hDmIJl3FIgZQBNMfOgdOX8kJLpd9LdbA=; b=ixrLruMePZVzpHeck1JZRhx8OUeXFxRDAnPigS/9QG/RnyoGfetwrZthfUIbLeGv69 GKaHVc8+JppaMfVU1oAOfp4E1dWHXQqtfAlMz0/Jun+G0ny5bdakd5Zg6SsbgLZIAVnl cSEgs5W08k1AXaPtIPJR3CjTD3+4ojxULKZP4qjt/OG/d0FQD0ewMEnTCWF7BjK/GxPP dP2Mtom3xswExEK9sifneLm8qOd1GQ95CQngaeGQhVu0Qy6ZJ1BxTGH5kLm+0zxuQeMD BWK0f3ZHKQfTUKKbiAnniPLhhO6jJwfKUivu2pafAgEqQ/jgCO8aZG9jniKEyGBX8NeX Mu4g== X-Gm-Message-State: AOAM533ixq6hWw/+0csNgNTz7yRdHNjb1Nr/etqby6KA3J5zlkeUHGhL OD+GGeO38cciToaTACzbsG8ZKw== X-Google-Smtp-Source: ABdhPJxONp4RrvitcYcVF82oYuZdrsKx6Ay/xu8opcvalfLsdDHC05RMM7SmB4tIPVDlVRRlXcMRHg== X-Received: by 2002:a17:90a:6b07:: with SMTP id v7mr910704pjj.138.1598567173631; Thu, 27 Aug 2020 15:26:13 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y1sm3960582pfp.95.2020.08.27.15.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Aug 2020 15:26:12 -0700 (PDT) Date: Thu, 27 Aug 2020 15:26:11 -0700 From: Kees Cook To: Andy Shevchenko Cc: Masahiro Yamada , Nick Desaulniers , Joe Perches , clang-built-linux , stable , Andy Lavr , Arvind Sankar , Rasmus Villemoes , Sami Tolvanen , Andrew Morton , Andy Shevchenko , Alexandru Ardelean , Yury Norov , Linux Kernel Mailing List Subject: Re: [PATCH v3] lib/string.c: implement stpcpy Message-ID: <202008271523.88796F201F@keescook> References: <20200825135838.2938771-1-ndesaulniers@google.com> <202008261627.7B2B02A@keescook> <202008271126.2C397BF6D@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 27, 2020 at 11:05:42PM +0300, Andy Shevchenko wrote: > In general it's better to have a robust API, but what may go wrong > with the interface where we have no length of the buffer passed, but > we all know that it's PAGE_SIZE? > So, what's wrong with doing something like > strcpy(buf, "Yes, we know we won't overflow here\n"); (There's a whole thread[1] about this right now, actually.) The problem isn't the uses where it's safe (obviously), it's about the uses where it is NOT safe. (Or _looks_ safe but isn't.) In order to eliminate bug classes, we need remove the APIs that are foot-guns. Even if one developer never gets it wrong, others might. [1] https://lore.kernel.org/lkml/c256eba42a564c01a8e470320475d46f@AcuMS.aculab.com/T/#mac95487d7ae427de03251b49b75dd4de40c2462d -- Kees Cook