Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2547851imm; Thu, 7 Jun 2018 12:31:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIfGuvRImYxAAHWiKQ8EWWhY0Kp29xU3mfYwoOAf+1fg2+wackMddScVZ5O3L3lmVsnHN7s X-Received: by 2002:a63:7f1b:: with SMTP id a27-v6mr2681403pgd.410.1528399886867; Thu, 07 Jun 2018 12:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528399886; cv=none; d=google.com; s=arc-20160816; b=y/PWWDaWgoBu7A6CpYb8ykCZSAp1jDoJ8ZmccAn6tKHTPO4Bjipa3h+HGry4UUXQtV laRgfMY/lnx0MRaU7FhpGI+I98nJzLhe29mVvYINXvPxCpF5ZK78Sbbsbb2kTk172owh JN3CHrC44aJKHvkS4ometUPXKNrNbLuXnu0/CqxKAfEkpper8YHeCHxxvApH53H/O6DV WJY1inl3Qgh94KOqGLVIkkesC4r6yD2DCExhCW3/no/RYfXGrKzWZPD8HXxXBHb6Q5zE FwFFOCa6iqmowhLwZKazo/+IbllHBnU4TRJAfq9bxYqtvUIHwrhoKQZk7EFu68dWGvBC /RCg== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=t0gsFFdZGR+xDoKWyJ6cXwo7VicnQIevVmGMpHASeh4=; b=td6FmoegZ5iqiI61M2e+3ZKUKgwx2N4rl/6XQtwxEyDDKNyL6Jk6EOSCarxWP7ghQ2 ensOrYRYRvZGJbEjoSQWaGmjhUDmiL4bTyZfb1gAaXAvK7xd1NMYivNQrLt7AKVyMl53 h8bu9KJRPygNOq4zHcdtds4MbehFduyHew+R+S8G6rjKV+kdSoBt/pjpFRzSU7GhGUdC e3Yd6wz+eqacAJKY8kSr8kBMBPwBITR8SAcs1I1BPLwfa8oE0adZO5QciAuCQoD9RMDa O4GJP/AFiPPi5fPGmJabv0q7B98BWd/9piFDnqQ4CtvX9YvTQ4G4nblVd3bKnilNfPqA LRww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=cup+qz/g; dkim=fail header.i=@chromium.org header.s=google header.b=c9msqXlS; 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=fail (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 i3-v6si53107570pld.189.2018.06.07.12.31.12; Thu, 07 Jun 2018 12:31:26 -0700 (PDT) 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=fail header.i=@google.com header.s=20161025 header.b=cup+qz/g; dkim=fail header.i=@chromium.org header.s=google header.b=c9msqXlS; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932421AbeFGT3b (ORCPT + 99 others); Thu, 7 Jun 2018 15:29:31 -0400 Received: from mail-vk0-f65.google.com ([209.85.213.65]:41169 "EHLO mail-vk0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932401AbeFGT33 (ORCPT ); Thu, 7 Jun 2018 15:29:29 -0400 Received: by mail-vk0-f65.google.com with SMTP id 128-v6so6777332vkf.8 for ; Thu, 07 Jun 2018 12:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=t0gsFFdZGR+xDoKWyJ6cXwo7VicnQIevVmGMpHASeh4=; b=cup+qz/gBGbDTg6nIU6CBWXTeOxpFtXyQJtObWdd21T1/LEF0iEPvspmbn2I70Nwth oZk+g07AFcnM6U4XykxXHfS+dqzurhICOh5eGjsRnXP3CBj+kkGbvTLEW3x8QWaTPUa0 4GpspcwMPty9mlkn/480WcNsfe7t3jQSg5ikpY+AQkp7a4exDdcLjBygKPau3CRk6JwK g2cYUmHuoPkowx4Wuu+i1HbjncCOrHjUHAsgHLpapgjfttnDdkXnK5JAneYmCAPeroq1 IyKoPIDw5eVNvVSTMYiEF9Pg2VvkZr4gTixKxJ8C4qGK0ANJvn974fMRwBmRwqtuUN/Q HWIw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=t0gsFFdZGR+xDoKWyJ6cXwo7VicnQIevVmGMpHASeh4=; b=c9msqXlSGS4aNMidzmvaxqluF8EGuL/HNZGz/ggH7RML7MWUs1GlCR+kYyU0qOReur M2Q6CXkhfVhAlv6di+qkCR/HwXJg0ZD/FEjaXa5Ii4tLcJrshwG+Jzw9/dvIjVEnkyyc 9e3ZebxkEOjaTG/5j5YiSmf3t5U/m5pvcKVhA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=t0gsFFdZGR+xDoKWyJ6cXwo7VicnQIevVmGMpHASeh4=; b=fGao1RWKu+ZozQfXvnNSMkXv1Z9fCaiVfHE3EadTgVLcDA0+yk9udmOo30LgtECRD+ jBEiq1m0pU5QcZ2e/yG4N56b4lLpHShenktjTKeXvUOnZhZRCZYGUDWBOXbLx+Fz2FI+ R4fdmUL+t28S6gPR/DxtVBz8VdkLMXdOa9jQY4DiwOd5LZyHbRSitqJ9p+HT10SbM9Rw jWqpzrWnZsxYDD1vs79f4ViWjsJGqK1kraGV6DzganrwNgUsZNY/XkcP8bVnyQ+9LhAx jfI8ZKsed4jlWTw0Ug0fno12N7ynS+mvTONZX1LNu8B85zNTupD5pDwjudNc6ubYPV1h WU5Q== X-Gm-Message-State: APt69E25XO5MeJ8gV6Pi/Kdy8HdcU4M8uuSD5hIJTKd0XPSWvTFCp7Cy I3FGATl07DWPA7G3HwH9B+gS37d7n1WgAo67Zp51Pw== X-Received: by 2002:a1f:8188:: with SMTP id c130-v6mr2026428vkd.96.1528399767521; Thu, 07 Jun 2018 12:29:27 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1f:a085:0:0:0:0:0 with HTTP; Thu, 7 Jun 2018 12:29:26 -0700 (PDT) In-Reply-To: <20180607145720.22590-2-willy@infradead.org> References: <20180607145720.22590-1-willy@infradead.org> <20180607145720.22590-2-willy@infradead.org> From: Kees Cook Date: Thu, 7 Jun 2018 12:29:26 -0700 X-Google-Sender-Auth: Zio1P6d2k20gG5V1y5ENJ19Xq3w Message-ID: Subject: Re: [PATCH 1/6] Convert virtio_console to struct_size To: Matthew Wilcox Cc: Matthew Wilcox , Linux-MM , LKML , Kernel Hardening 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 Thu, Jun 7, 2018 at 7:57 AM, Matthew Wilcox wrote: > From: Matthew Wilcox > > Signed-off-by: Matthew Wilcox > --- > drivers/char/virtio_console.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > index 21085515814f..4bf7c06c2343 100644 > --- a/drivers/char/virtio_console.c > +++ b/drivers/char/virtio_console.c > @@ -433,8 +433,7 @@ static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size > * Allocate buffer and the sg list. The sg list array is allocated > * directly after the port_buffer struct. > */ > - buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages, > - GFP_KERNEL); > + buf = kmalloc(struct_size(buf, sg, pages), GFP_KERNEL); > if (!buf) > goto fail; I feel like this one should have been caught by Coccinelle... maybe the transitive case got missed? Regardless, I'll figure out how to improve the script and/or take these. Thanks! -Kees -- Kees Cook Pixel Security