Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1626475lqg; Sun, 3 Mar 2024 20:42:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXgE8MyreRW/JazHgGIoapV5ce8YF1mRDTLUUbjKxOI0GcFIr4vd5osvZe6xOQMrVECRnaGj9vvkT/AiKD/QsF5yUP8SDMNfi2JGBYXkg== X-Google-Smtp-Source: AGHT+IF1/5kt8ASE1GNqP1M8rl98IeC+xhotSXY4hOIj4Ko2nVgKcAw0o9hMYzEn0bwLlTjC1ZWP X-Received: by 2002:a05:6808:2006:b0:3c1:d4ee:9d39 with SMTP id q6-20020a056808200600b003c1d4ee9d39mr8261868oiw.41.1709527357443; Sun, 03 Mar 2024 20:42:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709527357; cv=pass; d=google.com; s=arc-20160816; b=tBQx4adQk4gayLAjMt6W/tzBBlPXOofeLuZ4OnthMYe8IcojwQa48y4nziLygtFcuA RUe3TC2/WfW6GDOQeZTsReAosrnXr8hBM7wO6TK9BhcBUOGJinNwhk5MF2fxm6DPH6+E B0GeIoiJAEs1PSrkZCrP5qaW2nFupRKBFQkWxkpTu3vN6uQa3tlfJC3CuSpV7pUiMi7A 0ze4+DUzvOaNQmB8QXv+eX74DvqT2aEBQ9ht7e4RkAFNYrPqvb334teV7TcGipekHxIR qEBqITedEsHppeEU4/nHyEHiIOOvtOkapO+AiVGs7tFiBMbF3Mwy2HTg1BP6SXpyk07S ygug== 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=qgCb7iXd8J0BRB0u/H3HN+uMdSTfhHTZg+YKFQ7z3Hs=; fh=1CrRnYUFg4A3uFMKKv2ZgzyH4RFxFcomCiZeN2aTUeQ=; b=T9v9baBzdqXAsr/sEP0cQjPb7QN43XRdowdk0wUyQMAJNq/KUv0ns1OulEzW/w6V5H fxpPl+sIFZlJ3HuAzlwhimg4Zo+bwm347TpOauO6jw4ISk2gbjqDHMv6l1CXgfl88FKW /gQj9oAjBIp3bDC3Gz/bjXfUsHGPsseRbNZQiOeqUKY3/Qym0yuyyrwMgoPQxwby/aVN WId+hD9qag1kdv/VH8CowxGu6UdSW7oPx0L43vHx3VL7RaK9rJhyCKiFZcx9+w8LKB8B gT4V1lrZpka+xoCwWblSvFZu5Yi8tyajf/NWwxngaIV5roMIdf2pOCMgJ08LHk5pXYo0 aeCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="UI08V3/8"; 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-90046-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90046-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x30-20020a634a1e000000b005d91365dedasi7352678pga.613.2024.03.03.20.42.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 20:42:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90046-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="UI08V3/8"; 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-90046-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90046-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 190E628144B for ; Mon, 4 Mar 2024 04:42:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68ADA6FA9; Mon, 4 Mar 2024 04:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UI08V3/8" Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 A265517C8; Mon, 4 Mar 2024 04:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709527346; cv=none; b=j+Vq99yuMRX3euv5IGxKBddf7LmervWJGD6SIZQv1G+8UXt+F3fiOHs5+1+mEpOnO49KvBSSa1aUNfJpcWSi2fbCT0eEkT6+7zPmunCtb5a6cRHzEDWrPvbzS010//C6Wj3xRIY1gDgJGDVjp989ukBu8ypmGTceHtJaB0YKIyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709527346; c=relaxed/simple; bh=b9PGM8FqCwlg8sxVp44vM/ykXAQzOJufl+9en8YQ3ZY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YK64qLYzKCOavO36zFA8be3cvztq+onFqAHXyBKupw84EbOd6xZdgp7x2YySKuekWr4C0zIrMBXpXuyfsw+fV0wIgKvsAKv689pDeCXxXsPY6IYxqanSeGcRrKmN/cLdLLzl+sizlZicgBONyDkKbSPbgkiwXX1y6d2c2PUdiLc= 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=UI08V3/8; arc=none smtp.client-ip=209.85.218.41 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-f41.google.com with SMTP id a640c23a62f3a-a3f893ad5f4so600774766b.2; Sun, 03 Mar 2024 20:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709527343; x=1710132143; 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=qgCb7iXd8J0BRB0u/H3HN+uMdSTfhHTZg+YKFQ7z3Hs=; b=UI08V3/8yjZqp5MAjce+fF3B+X9Y+aHuBNjME0vvVMD0O35t+po8f4JjI1nC3cqXwt vOlIGnJt+Np9PUd1S1wzLwLy9l6nAeIOWvRtBB/4jJdOFYNxvCgNCE0GWxHtTw+9rQXX Zm37MBnn9z4xLfA/87j0i+Ve/0nuTgIxfNQK0Kbq49EJkqUOjJnaxfKD1tGa42BDFPbt xrKSpzR9WNenzLzQy44nrVNVtv154HJSpMFN4StoUyX/vJMre+obMQlQLYL3HnLMlvA1 kF3gyzPRrjnq002ToVZTg65PfuOI5SyuDqOiwPWfxfKwkNSbveM0mk4Yk6l4+qH0S3yq 6scQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709527343; x=1710132143; 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=qgCb7iXd8J0BRB0u/H3HN+uMdSTfhHTZg+YKFQ7z3Hs=; b=tb6mbgmrdWetvJaSfgalFDiP+IlCh6sF8hrqcX2owRGzLK8izKVJurGXt6hKGPrphq uYG9WskZepVJs21coVXs6YBbDQKAq/gqaZNZDuREwGmVsg2f6hez05XNYpl1FqtdPetd ztRu7fTvWOfZr8EKeeUiVmewFsks78ZL2a41sExyjN63X9TsdW7g7xihOepAxba9pS9p jHopNHqgSUOP8fk4I4xYhwYsQwsAx5ukXbpc1fNjyhzMCB/L9iRUwVpLvx0xrAAdLuij 4dkT74nrc15JkqAr3wq7zUza5fvYyXNlQLGayCyChvAyKsIzIDBx6s8ZQvMwP0tpMdFV 7fSQ== X-Forwarded-Encrypted: i=1; AJvYcCX44RdN7wdbil0hZ3evJfeuvpmv120BptuhxPuzOW0nUX0OMv/rQndhpgHt5ts6R9IxhiLkp3j2QrDkyZlmqY6LOGdpncIsmDC4o9aWV4zn/yVQTPBeHUfix9NdcYuIupnxw9Nw X-Gm-Message-State: AOJu0Yy/qsMo1eW2y5g0NJMYM+eYLFB9icfbz61JmBD22dxGhM+dDslL FnMg7HHx6+lOuF/2UmYmb09rkl+7UkkX8Fi+43PnTuqgCSb2rQloCdMlXtzhm/h9+O0s6Ug2f7I NSjzzmsj+A2yR8F6Ek3rX1fxIuv4= X-Received: by 2002:a17:906:54c7:b0:a44:44ff:5dd5 with SMTP id c7-20020a17090654c700b00a4444ff5dd5mr5537789ejp.21.1709527342847; Sun, 03 Mar 2024 20:42:22 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Sam Sun Date: Mon, 4 Mar 2024 12:42:11 +0800 Message-ID: Subject: Re: [Kernel bug] KASAN: slab-out-of-bounds Read in in4_pton To: Jason Xing Cc: Eric Dumazet , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, j.vosburgh@gmail.com, andy@greyhouse.net, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, syzkaller@googlegroups.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 4, 2024 at 11:20=E2=80=AFAM Jason Xing wrote: > > Hi Sam, > > On Fri, Mar 1, 2024 at 11:23=E2=80=AFPM Sam Sun = wrote: > > > > On Fri, Mar 1, 2024 at 4:18=E2=80=AFPM Eric Dumazet wrote: > > > > > > On Fri, Mar 1, 2024 at 3:41=E2=80=AFAM Sam Sun wrote: > > > > > > > > Dear developers and maintainers, > > > > > > > > We found a bug through our modified Syzkaller. Kernel version is b4= 01b621758, > > > > Linux 6.8-rc5. The C reproducer and kernel config are attached. > > > > > > > > KASAN report is listed below > > > > > > > > ``` > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > BUG: KASAN: slab-out-of-bounds in strlen+0x7d/0xa0 lib/string.c:418 > > > > Read of size 1 at addr ffff8881119c4781 by task syz-executor665/810= 7 > > > > > > > > CPU: 1 PID: 8107 Comm: syz-executor665 Not tainted 6.7.0-rc7 #1 > > > > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-= 1 04/01/2014 > > > > Call Trace: > > > > > > > > __dump_stack lib/dump_stack.c:88 [inline] > > > > dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106 > > > > print_address_description mm/kasan/report.c:364 [inline] > > > > print_report+0xc1/0x5e0 mm/kasan/report.c:475 > > > > kasan_report+0xbe/0xf0 mm/kasan/report.c:588 > > > > strlen+0x7d/0xa0 lib/string.c:418 > > > > __fortify_strlen include/linux/fortify-string.h:210 [inline] > > > > in4_pton+0xa3/0x3f0 net/core/utils.c:130 > > > > bond_option_arp_ip_targets_set+0xc2/0x910 drivers/net/bonding/bond= _options.c:1201 > > > > __bond_opt_set+0x2a4/0x1030 drivers/net/bonding/bond_options.c:767 > > > > __bond_opt_set_notify+0x48/0x150 drivers/net/bonding/bond_options.= c:792 > > > > bond_opt_tryset_rtnl+0xda/0x160 drivers/net/bonding/bond_options.c= :817 > > > > bonding_sysfs_store_option+0xa1/0x120 drivers/net/bonding/bond_sys= fs.c:156 > > > > dev_attr_store+0x54/0x80 drivers/base/core.c:2366 > > > > sysfs_kf_write+0x114/0x170 fs/sysfs/file.c:136 > > > > kernfs_fop_write_iter+0x337/0x500 fs/kernfs/file.c:334 > > > > call_write_iter include/linux/fs.h:2020 [inline] > > > > new_sync_write fs/read_write.c:491 [inline] > > > > vfs_write+0x96a/0xd80 fs/read_write.c:584 > > > > ksys_write+0x122/0x250 fs/read_write.c:637 > > > > do_syscall_x64 arch/x86/entry/common.c:52 [inline] > > > > do_syscall_64+0x40/0x110 arch/x86/entry/common.c:83 > > > > entry_SYSCALL_64_after_hwframe+0x63/0x6b > > > > RIP: 0033:0x7f797835cfcd > > > > Code: 28 c3 e8 46 1e 00 00 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 4= 8 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01= f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 > > > > RSP: 002b:00007ffff464ffb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000= 001 > > > > RAX: ffffffffffffffda RBX: 00007ffff46501b8 RCX: 00007f797835cfcd > > > > RDX: 00000000000000f5 RSI: 0000000020000140 RDI: 0000000000000003 > > > > RBP: 0000000000000001 R08: 0000000000000000 R09: 00007ffff46501b8 > > > > R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 > > > > R13: 00007ffff46501a8 R14: 00007f79783da530 R15: 0000000000000001 > > > > > > > > > > > > All > > > > > > > > > > > > > > We analyzed the cause of this bug. In the function "bond_option_arp= _ip_targets_set" in > > > > drivers/net/bonding/bond_options.c, newval->string can be controlle= d by users. If string > > > > > > > > is empty, newval->string+1 points to the address after newval->stri= ng, causing potential > > > > > > > > info leak. > > > > > > > > One possible fix is to check before calling in4_pton, whether strnl= en(newval->string) > 1. > > > > > > > > If you have any questions or require more information, please feel > > > > free to contact us. > > > > > > > > Reported by Yue Sun > > > > > > > > > > Thanks for the report and analysis. > > > > > > Are you willing to provide a patch ? > > > > > > You would get more credits than a "Reported-by:" tag :) > > > > > > Thanks > > > > Dear Eric, > > > > Thanks for letting me provide a patch! One possible patch > > is listed below. > > > > 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)) { > > netdev_err(bond->dev, "invalid ARP target %pI4 specified\n= ", > > &target); > > return ret; > > You could submit the patch targetting at the latest net tree on your > own instead of replying to this thread. And then people will review it > soon :) > > Thanks, > Jason > Hi Jason, Thanks for replying! Since it is my first time committing a patch, I don't know the standard procedure of patch submission. I saw people discuss patches through emails so I replied to the thread. I will check kernel documentation on submitting patches. Best Regards, Sam