Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4201325imu; Mon, 14 Jan 2019 17:25:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN44gB8j2A/pawKBlvC6w4ni4SVEOFW/F81ZP0Jx7zqM7GVMVWcAvkbMHyuK6scdMXB5IX2L X-Received: by 2002:a17:902:1d4a:: with SMTP id u10mr1398511plu.122.1547515532357; Mon, 14 Jan 2019 17:25:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547515532; cv=none; d=google.com; s=arc-20160816; b=0MWNFnw5kAnvdCuVqfRWs5TTfwsRJD4qlPHk6klaetd0U8BwfKO0PcMeehQuvvdKls 15HAFBi/bC6sFlmTRiHbJlqN+op7QYU7sjGhbj7pgmUzn2HZKPntA9/kkG1UvELLJnlU h7F44tdaUPqo69mNxCvdjgeKngh0sXq36eIvaRVDLpkErEzYj4UUUYWF38tG+jMmNnDW 8oNSkVb+s5A0D85pm7MNcv4SbV51XFYPOgQld21f+VDlYguOBVA8BfIoUqjB+Simg6tz qLvLqblG/V3lao7uW4cdqcdq9bJJaZyQLeLskwUCuJs2mwEmehCeqYsiOuf9uqQRXRAa qscw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=YmcABwfNUJF9dDu8ObsqvMi8NHBXHK+ON9pk86F9MU4=; b=1EdWdLnNWAGnWHr35I6qOwOFTaTugGhh4E6NlG/Fh2rHTumpDDTcIVbEnqMye5XPMT GS9rBIFhxWeuiUBJI694u9ywezsUOSVJMv7oOLKtuZonYWQt5rq332EbPccMV1ONdpEl 2EmveGLsEXqBjBziEuZ9HTbkADACqtkVrFXklVMzslP8gYDT94vvMWKs63qwI0Oq/+mM 3mzoF82r1mGJ9d/dPZiWXWU9arGIWPQIoa8cdN06fisJztr7WmOA8hsQTMP5spKDFQcS d17DC0dDFdg9FNyKhv9PjBLZJRuiQkKQDVH1IaTUNiRFMHm5+OgAysQ41N0NZiZMMJct VK/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E7lRSvmK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l64si1704764pge.168.2019.01.14.17.25.08; Mon, 14 Jan 2019 17:25:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E7lRSvmK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727355AbfAOBHe (ORCPT + 99 others); Mon, 14 Jan 2019 20:07:34 -0500 Received: from mail-vk1-f195.google.com ([209.85.221.195]:34951 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726769AbfAOBHd (ORCPT ); Mon, 14 Jan 2019 20:07:33 -0500 Received: by mail-vk1-f195.google.com with SMTP id b18so249488vke.2 for ; Mon, 14 Jan 2019 17:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YmcABwfNUJF9dDu8ObsqvMi8NHBXHK+ON9pk86F9MU4=; b=E7lRSvmKe89TA5qnFsUOx6/jJh8AlQnop0mN8lFBVWs3j+NcBu3svULuXbrYxwqpVy gPp3v/3oVCiK0i2rrACYFivip3z9NaCuC4FKwkRGWCblaAQNDGLia6EZfFj/BmrzWB/6 bW96eChs2Vl87JMxGoTcAdv+tvLM2JBD7wGSw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YmcABwfNUJF9dDu8ObsqvMi8NHBXHK+ON9pk86F9MU4=; b=gDxQAYoxUQPieYY0GPo27FIELLRKOEKfNUAFuU+ijwFO6N8NQ4hK5uGxoXUO4nzlle Tiy8UIgdvjyz44NLg7mjhlWNljWytjMA4SD87Ulf59CIajsGnl31OHAygEmJEYEqRxY6 JQr9gSuDKy9V0OiX2Kof75YQ9Nb/QhPKHawopnGn+IHFFJi9VXIR0YbJ13LR6iVp9o1I Rhg1vFXBoBcYjCW8IvbyT7y/icHdwMEY+q8qtRwEt2qPbt7QPUQrWFzZLIxWLvCuAE99 1Ui9XQywQm0zr/0XtNO1ZKf2n/p4/+mcZwk8/2WbnNI4FFl201v3+7JPWejiv3TMEi3p dQMA== X-Gm-Message-State: AJcUukdjDK5jG5cWTKwipOGS8w/dX8GV55l71RK3pdyaooLR9edgfO4w mMyk5GG9HyO/aY4aKxRKuvr8PKVHW60= X-Received: by 2002:a1f:4158:: with SMTP id o85mr545576vka.42.1547514452473; Mon, 14 Jan 2019 17:07:32 -0800 (PST) Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com. [209.85.217.47]) by smtp.gmail.com with ESMTPSA id w65sm4121267vsc.16.2019.01.14.17.07.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 17:07:31 -0800 (PST) Received: by mail-vs1-f47.google.com with SMTP id x1so642555vsc.10 for ; Mon, 14 Jan 2019 17:07:31 -0800 (PST) X-Received: by 2002:a67:e15e:: with SMTP id o30mr607682vsl.66.1547514450824; Mon, 14 Jan 2019 17:07:30 -0800 (PST) MIME-Version: 1.0 References: <20190112152844.26550-1-w@1wt.eu> In-Reply-To: From: Kees Cook Date: Mon, 14 Jan 2019 17:07:16 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/8] lkdtm: change snprintf to scnprintf for possible overflow To: Willy Tarreau Cc: Silvio Cesare , LKML , Dan Carpenter , Will Deacon , Greg KH Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 14, 2019 at 5:02 PM Kees Cook wrote: > On Sat, Jan 12, 2019 at 7:28 AM Willy Tarreau wrote: > > From: Silvio Cesare > > Change snprintf to scnprintf. There are generally two cases where using > > snprintf causes problems. > > (I didn't find a 0/8 cover letter, so I'm replying here...) I forgot to mention: can we please get a Coccinelle rule added to catch these cases in the future? (And make sure sfr is running it? :) ) My attempt at it was: @@ expression LEN, BUF, SIZE; identifier FUNC; @@ LEN += snprintf(BUF + LEN, SIZE - LEN, ...); ... when != LEN > SIZE when != LEN >= SIZE * FUNC(..., LEN, ...) But this needs adjustment to deal with some false positives (like using min()). -- Kees Cook