Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp55246ybx; Thu, 31 Oct 2019 15:50:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbQFg9yUeuv3H227vNDC10uyg1Kbk3rVULlX4MTdnx6MIzokr5KiT2puOyFfbpJXBUq2DZ X-Received: by 2002:a17:906:4b4d:: with SMTP id j13mr6363986ejv.160.1572562228751; Thu, 31 Oct 2019 15:50:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572562228; cv=none; d=google.com; s=arc-20160816; b=PqeebK7k72Y8GAQIN07VcOEMBYA5InFOIcMjUP0Vvk4ij3deelx7aFOq8YDnJdkOtW AlXz2lrdCoUIId+/K95uAQlCGZ7hnH5sV/VQQYB1esMCbpyb8R9E2ITdKge3GQRVyWMA FAKl3oxP4Hu+5bG5NbSB2v88qb3oG9/QTmzYczS1RYLBvJFxUPc8fFZYgHDrgGcEd9WY 3HHlBZfLsDDEABF+3EIiXBH3xN80YKALf7wvILHJEw1fp/MyImgCPx66T8MBW25J8d7I JhdlPRuyORrtHM3/jaEQjCb6GlK1Cw6d6SCSDe3YZKIsIOxd7Hb5wNYV9DkxogXoPfgK XAAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=bqOg5+zD8Qpj1h7Ic7EcL5kmHzAI7gRipZPMSEC5V7Q=; b=P1NbrWQvMRsGpWbOFi4+Iqz9CyGcX5IqfLm1oE+e2IBWpBnkHZ1/ObFV3YC4mNN1kb AQ0m4AALiAL77iwz0SSQg9RhNlwTNnW4l4y4G3f4tT4GRizdfl7vzDCA8BugXOZY09DR rHUCO1u3rk0cRSQ2GC9sIRCG18EedogmTqIEY+vl1/c43gLRgtyuA6O8aiZueP/Z+NkM k5UkCfLVlVfyyP9YsrriH5yoZO2aSTSEmO7MF3F8z9O1Vq4TzRwbGv3lXm5XJR8wsvkq c1lSULxGhThBgQU7Zw0LpqhMgxOe7ZfkTyGJiPcOfPtAClAcANK9u9red7fkhydwxu8B ihqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b="Z2fAm/dK"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b52si5473839ede.287.2019.10.31.15.50.04; Thu, 31 Oct 2019 15:50:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b="Z2fAm/dK"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729889AbfJaVQz (ORCPT + 99 others); Thu, 31 Oct 2019 17:16:55 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35984 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728645AbfJaVQz (ORCPT ); Thu, 31 Oct 2019 17:16:55 -0400 Received: by mail-lj1-f194.google.com with SMTP id x9so3341013lji.3 for ; Thu, 31 Oct 2019 14:16:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=bqOg5+zD8Qpj1h7Ic7EcL5kmHzAI7gRipZPMSEC5V7Q=; b=Z2fAm/dK3ZxXj0TZOs0SS3npbKPsleVuDrlV7Ep2VbXhRuVZ3qJUeVp1b1XyBF3E0B EQZtrvQiA6QquqYSckLTE6s/viHWAxzWDglPKVAqPI4VpmSVCdg7Ag1QNUwGQN/vJpTg GfwYXIfCFriIhcvBlkPebYsMnJVJQ7Y1WHNzaTx3iT4YHjAZX4iCvzOpVXBelUoD5WEY SNqYibKijmtM6W2QzbYCBZStw8Bxe3HpFD0OnU+M26De7KuIb/bcSPuZCnM4Tp/W+uBV YTSkNrKcQHQBfaek7SdmPoAzDyRuV4EIFGzuvQdnDaKWm7Ybwmo0DGai/zKO2JJDIMSl YVgA== 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:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=bqOg5+zD8Qpj1h7Ic7EcL5kmHzAI7gRipZPMSEC5V7Q=; b=QBVK2eLyIpq4KdlrJftjEDWmm2Nqox26hj6uSE7vYEDoSSTSJ8Yx7orZqALrKr7kne n3KQkVlrve9ZZMaHnFNXriUILSPJNVU12J72ZDpgseWPHcVDj405fgRUwuUbC8RmMI6k 2qj6/5FsnFrUZ+TBDktKqOXEtfmMWyq/jIeixrI6sK77D2mWBsa32Novf9KXMfmoz5c0 R8lbFbW5HGCeTpWybSRvezwIfgGBiqZIo+Ff1ku3GoKUbqxi5by3WTO/o/xZx2EunHNa LEw6Sc4XdsSzJ1N9c3uc1GwS0/Deuw0aESXqoex738PMfs1PCZt7G4GxZ8NSXQ7X6QkC Zciw== X-Gm-Message-State: APjAAAX9OTogutiNqOv42B14RKjyRWPL8kKg+32y1KgMoZFYO1vEN/fo +aHg3Wz1TZYrM7QnWV3NjkYr0rgYCUA= X-Received: by 2002:a2e:84c9:: with SMTP id q9mr5348786ljh.163.1572556613828; Thu, 31 Oct 2019 14:16:53 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id 4sm1707585ljv.87.2019.10.31.14.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 14:16:53 -0700 (PDT) Date: Thu, 31 Oct 2019 14:16:44 -0700 From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, borisp@mellanox.com, aviadye@mellanox.com, john.fastabend@gmail.com, daniel@iogearbox.net, syzbot+f8495bff23a879a6d0bd@syzkaller.appspotmail.com, syzbot+6f50c99e8f6194bf363f@syzkaller.appspotmail.com, Eric Biggers , herbert@gondor.apana.org.au, glider@google.com, linux-crypto@vger.kernel.org Subject: Re: [PATCH net] net/tls: fix sk_msg trim on fallback to copy mode Message-ID: <20191031141644.232af7ed@cakuba.netronome.com> In-Reply-To: <20191030160542.30295-1-jakub.kicinski@netronome.com> References: <20191030160542.30295-1-jakub.kicinski@netronome.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, 30 Oct 2019 09:05:42 -0700, Jakub Kicinski wrote: > sk_msg_trim() tries to only update curr pointer if it falls into > the trimmed region. The logic, however, does not take into the > account pointer wrapping that sk_msg_iter_var_prev() does. > This means that when the message was trimmed completely, the new > curr pointer would have the value of MAX_MSG_FRAGS - 1, which is > neither smaller than any other value, nor would it actually be > correct. > > Special case the trimming to 0 length a little bit. > > This bug caused the TLS code to not copy all of the message, if > zero copy filled in fewer sg entries than memcopy would need. > > Big thanks to Alexander Potapenko for the non-KMSAN reproducer. > > Fixes: d829e9c4112b ("tls: convert to generic sk_msg interface") > Reported-by: syzbot+f8495bff23a879a6d0bd@syzkaller.appspotmail.com > Reported-by: syzbot+6f50c99e8f6194bf363f@syzkaller.appspotmail.com > Signed-off-by: Jakub Kicinski > --- > Daniel, John, does this look okay? > > CC: Eric Biggers > CC: herbert@gondor.apana.org.au > CC: glider@google.com > CC: linux-crypto@vger.kernel.org > > net/core/skmsg.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) Daniel, John does this patch look reasonable? I must admit the skmsg stuff in TLS scares me, it'd appreciate an ack.