Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp150390lqs; Mon, 4 Mar 2024 19:21:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX7uzvaeWSYVPBbx2evftgUhJycC/Fg/2fJCiTrX5sIQds2vVHjETnS9HUWZVSBJp3uMtqffcVGN7AFOZN61B1BxSjBlGWdvIGr9DlLUg== X-Google-Smtp-Source: AGHT+IFSGU5TK0ZDmaw64BiAHfLjg3WtmbSlqx5JADlkYFsyuM44H+NX3kSLnkMXzTc6PGJk8SQ8 X-Received: by 2002:a05:6a20:9150:b0:1a1:4aea:c665 with SMTP id x16-20020a056a20915000b001a14aeac665mr1012788pzc.19.1709608875887; Mon, 04 Mar 2024 19:21:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709608875; cv=pass; d=google.com; s=arc-20160816; b=NtftW1FA5eYPSuNv+u0ZwWDbsA0sITsgzudOEPS4cPW4F8ShywaEma/2mmtcrIsawL s/lLTIB1CNf5ha0ekLiDQNtYG06fC49ctcOXL4pPi3rj4AiasTAT+Dg9b6TladMNeL/P PASf7RDySJUzf6ONJmDmZIaUSYW1Z++JOadlqKrXo/EUJ+S8atQeNAP7gSVcunCEMf1a OTW44VjsF4XaS/1cxL5KhZRFOsV2J2dWknbwL2AoJa68cbmn8J0dAUsl6s/GAr4kGsLe BZ/blX46mqtZXtEX8VQRTsXg0P/8GHW1FH5DrWovph2aL9uc0u8IJVwk6V/2Sk0U/Boi iPFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=g5OTOZkvI1iKHRZFDGgAFNCyc+OZsWpdVdz/BEQBjP4=; fh=kBgLTbxLBE0MF1oVtfDjRd/cb5N4Z5meTv9gF4hMr80=; b=Okj0Re+fA3uNb2qzUVmm3jh0M698GMQqU5Bua5DX/D0NklDauNVFRMAUqcpcceacXL nOhLj3AtLSUF07Is5U35QWDkuKZ7UQSXeE520EN1ZmhzSOHBt0Rh7D2t1Evwr6jtPlmc 5Wwj++MwXbSrBw4vuCywSm+mqEzuLL4JkdPiZkJysP7Urd6wBP2uG7iCHLQ0rSQkQ52k RZBLg2q4hRb2xPAyu1jCgJuHw94Oq9qs7NWF4igMDZ9URWREaXjm+zsaHTH2vMO1EqOt oyUbTKQmsowJXkSeM50H6xenSuT16Az/9Q9Bu14NYntb9c4EfAhywmo4fg6jc7sWYR5W P3tw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VorYs+JN; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-91606-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b23-20020a639317000000b005dc80c3271esi9493562pge.55.2024.03.04.19.21.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 19:21:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91606-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VorYs+JN; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-91606-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1A07AB21163 for ; Tue, 5 Mar 2024 03:21:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE16E37701; Tue, 5 Mar 2024 03:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VorYs+JN" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 639551865C; Tue, 5 Mar 2024 03:21:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709608865; cv=none; b=gi9axCILxXl0ph2LISaIhagLxv3mF2K0Z01JR12ZHjbrdkZB+0t/PIrungvX2cNG23+vUV84iigXE0q6LFDQ1h8SI99VTRXZknqHtUAcdimfMSchUFDx92S2E/N6330uuznyA+V5PmgwPM+Jh49aMsh0mPCht3bnPCnfs1SIE9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709608865; c=relaxed/simple; bh=fQxFj9FoBmTJzV/ZouAXdSy2rLJDNB1eESe76AOrgDI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=m1UhsJnx8FhzO3RPvqpkDjDGq2NAsckhOpmuubF8zd9s46zUthukW1kuBvREfJFsP69TTjHc8LVd/2ej8GpY+auvprjZtk+3hlVsfHneCY0IWHWeABHULLIb1LvqP42DIAStCV0X9t1OwNDRBybK/7ycisE9T2kynUsYlrSIwxA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VorYs+JN; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a44e3176120so287588366b.1; Mon, 04 Mar 2024 19:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709608862; x=1710213662; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=g5OTOZkvI1iKHRZFDGgAFNCyc+OZsWpdVdz/BEQBjP4=; b=VorYs+JN2iMVeIIpUm2WyXOPxI9BqGZYMR0xb3smQhOsDa2/EwJd7uZVlZpvbX0SUy EZA0bhdJgqEZi1G4blynLdm+Rw2x3W9JIVEtutBI4LwPVYhapnmOIRfeOQ4/do5cHrav m+22DLIUtpiqGKrpvCFPqaXGsTa6HouZXDzfMgiuMVuZsSZEqLGgjBOQmu7u5/a3ZB1E VtgdJga+VmCJH65H3uVW/UGJQ8uzlf+LoTKGDK7C8g1U//FSmqKmjEz0SikrV8GJj12t VEKFGVd7QGP/oMm6thIqJ0QVJBL4bPhobG0yup0sLaEsghBZognPhC5tsbtmRwLHp4/u Hhfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709608862; x=1710213662; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g5OTOZkvI1iKHRZFDGgAFNCyc+OZsWpdVdz/BEQBjP4=; b=nXB2BQepfx86suOAnDWTVdQYZ3lNcjuiA5A/EZovkV85la8Ti+yYPF6ysmJqb8YYDc gNmnSnsUQS0KYOvQqylSA5Up8LIzFCctqhiYzAQMItxE0ateQILLxPPpDI86piRK/fKR sL4eYeqv3dyexJrPDYbxr4G3JKW2E++FGuuUnJAh82liUItmJh5wYPkuhpaEXfqjXWPs y6tq4lWGyOfwD+yLMQdLv8NFSV8swKwnkTz27sFeBmhHdz3eBm4K85trHDZ4bPjVGhYH 7fbBxTvJAj9Wb7Fd34AtQv0rHh35yKS42qZY0x7sOVYsJAN8dG/Pz45yQZO2PzEajmnw Or0w== X-Forwarded-Encrypted: i=1; AJvYcCWxDdfj00LLNyrRHOIWjzuQ7lX+ElQfu7Q7KDcgewjgBAI6gQK38rBdoZ0ptnfqXp0XbH71NTVDgNyRR5B72xr6WygniLeu X-Gm-Message-State: AOJu0YwW/cQZMjzroGrQtWGO7CF867yu+b/p6Kd1fPRNicUbDR5l1IPb NrJI7Za3nciYMtrUXHQdBH4YgTqK7VuqR/0mLCbjX2WfaZhj8lGtWvPVdobaqHTlXKCwjdgqUZh uzqgnPKdn7u8SZHZIFPhgCiqgonM= X-Received: by 2002:a17:906:695:b0:a45:1850:e6ed with SMTP id u21-20020a170906069500b00a451850e6edmr3968306ejb.6.1709608861517; Mon, 04 Mar 2024 19:21:01 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <24641.1709606824@famine> In-Reply-To: <24641.1709606824@famine> From: Sam Sun Date: Tue, 5 Mar 2024 11:20:49 +0800 Message-ID: Subject: Re: [PATCH net] drivers/net/bonding: Fix out-of-bounds read in bond_option_arp_ip_targets_set() To: Jay Vosburgh Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, andy@greyhouse.net, davem@davemloft.net, Eric Dumazet , kuba@kernel.org, pabeni@redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 5, 2024 at 10:47=E2=80=AFAM Jay Vosburgh wrote: > > Sam Sun wrote: > > >Dear kernel developers and maintainers, > > > >We found a bug through our modified Syzkaller. In function > >bond_option_arp_ip_targets_set(), if newval->string is an empty > >string, newval->string+1 will point to the byte after the string, > >causing an out-of-bound read. KASAN report is listed below. > > Conceptually, the change here seems fine. However, I don't > think including the full KASAN report adds much to the description > above. > Thanks for pointing this out! I will remove this next time when I submit a patch. > >We developed a patch to fix this problem. Check the string length > >first before calling in4_pton(). > > > >Reported-by: Yue Sun > >Signed-off-by: Yue Sun > > > >diff --git a/drivers/net/bonding/bond_options.c > >b/drivers/net/bonding/bond_options.c > >index f3f27f0bd2a6..a6d01055f455 100644 > >--- a/drivers/net/bonding/bond_options.c > >+++ b/drivers/net/bonding/bond_options.c > >@@ -1198,7 +1198,7 @@ static int bond_option_arp_ip_targets_set(struct > >bonding *bond, > > __be32 target; > > > > if (newval->string) { > >- if (!in4_pton(newval->string+1, -1, (u8 *)&target, -1, NULL)) { > >+ if (!strlen(newval->string) || !in4_pton(newval->string+1, > >-1, (u8 *)&target, -1, NULL)) { > > The text beginning with "-1," is a separate line, and something > messed up the tabs. Also, this should be rewritten as > > if (!strlen(newval->string) || > !in4_pton(newval->string + 1, -1, (u8 *)&target, -1, = NULL)) { > > to avoid a long line. > Yes you are right, I should have used the checkpatch script before submitting the patch. Sorry for the inconvenience. > -J > > > netdev_err(bond->dev, "invalid ARP target %pI4 specified\n"= , > > &target); > > return ret; > > > > > --- > -Jay Vosburgh, jay.vosburgh@canonical.com I modified the patch and it is listed below. Reported-by: Yue Sun Signed-off-by: Yue Sun diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index f3f27f0bd2a6..7f765b42fad4 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -1198,7 +1198,8 @@ static int bond_option_arp_ip_targets_set(struct bonding *bond, __be32 target; if (newval->string) { - if (!in4_pton(newval->string+1, -1, (u8 *)&target, -1, NULL)) { + if (!strlen(newval->string) || + !in4_pton(newval->string+1, -1, (u8 *)&target, -1, NULL)) { netdev_err(bond->dev, "invalid ARP target %pI4 specified\n", &target); return ret; Best Regards, Yue