From cdhmanning@gmail.com Fri Aug 21 05:24:47 2020 Received: from mail-lj1-f181.google.com ([209.85.208.181]) by stoneboat.default.lvansomeren.uk0.bigv.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k8yba-0005Re-GV for yaffs@stoneboat.aleph1.co.uk; Fri, 21 Aug 2020 05:24:47 +0100 Received: by mail-lj1-f181.google.com with SMTP id 185so413140ljj.7 for ; Thu, 20 Aug 2020 21:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yaXrR/i6Kg0C0bTE0MYxMUBVFSp/5MIYZkRvfhM6Ne0=; b=JQG1zr4drqpvN5hMGOgUhfG1EnXmdZk5KNbKkTds3SkBldvV5I8v/MeVZarcFSFRUW tYaKQOxaL80eFl74AUQHQmBXAaFA5xYlyVXHaFoYEdY6urZC9GxdzNNWtbaYwvbE+oQE 1HKIhm7C3XU4E9G26MYjoOJinFJ7k35LZddgri/X1srKBaFtBnpdfhVYzVFWNVVdmCd9 WNTNY43CI0eBMSR7odO6rwQl6jw+iq5tKG3MspJzoA5UbIvyAcQvW2LYUAYkr900ZI+M sjAoCpq+/gctDsnZri5sj677T8Etgv7ky0GUuRQxmzxceHBc47nX04bMlC0Ed2YZy9aq 9A3g== 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=yaXrR/i6Kg0C0bTE0MYxMUBVFSp/5MIYZkRvfhM6Ne0=; b=CPK2KhoPmBDXw9hReCcoaayhAFFTktU2AgSTcHu9+FIkuUdLF+G4XmOrJglZTVwpcq lCJ5hghbP0mD5/KarDO4IaevFI1AazMnl/jxEI+ozd9z0AP4NsP32SjIb8Grqf5GmDeM ut07ypI2MU3/rlAfTKg6ztvAxXscLqD6rNSOtc35/s06iRI4RS/WeXO0OjuNTQmQaMLt u+G9qBIqVQ5qSC3b0yrC96j46LUBToAD6kQL89O1y32eAhs8NM1qftRpQYdzSeIskRhp VoP4guz0Luny1UkYbn1UOjuxT7dLs3NZog6k91/ELLdj5QK3WhMdEQj3WfbEbTN9sXLq s1tA== X-Gm-Message-State: AOAM5313ipsgNgokRov+NjA2u0twJ7ZuhRBngSv/gN9a7Je5zXWp12Hp YxmHTXfv/Ejb393h8McM+szyFDiAnX3lAP7fAug= X-Google-Smtp-Source: ABdhPJwnCvPMSFWxMze3hCmL12/jANK2mCpSpVF3T2TVj1NlKDK1eVmgeyIzqv4/FpD5nyBcOaG0PNjSxMxVD/oObD0= X-Received: by 2002:a2e:9a15:: with SMTP id o21mr563230lji.419.1597983881448; Thu, 20 Aug 2020 21:24:41 -0700 (PDT) MIME-Version: 1.0 References: <006d01d67295$fe776760$fb663620$@tsinghua.edu.cn> In-Reply-To: <006d01d67295$fe776760$fb663620$@tsinghua.edu.cn> From: Charles Manning Date: Fri, 21 Aug 2020 16:24:30 +1200 Message-ID: To: Ao Luo Cc: yaffs Content-Type: multipart/alternative; boundary="0000000000009c51e005ad5b9d55" X-Spam_score: -101.9 X-Spam_score_int: -1018 X-Spam_bar: --------------------------------------------------- X-Spam_report: Spam detection software, running on the system "stoneboat.default.lvansomeren.uk0.bigv.io", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hello I will look into this. I was looking at some changes around buffer management and this spurs me to look into it sooner. Thank you Content analysis details: (-101.9 points, 4.9 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 USER_IN_WELCOMELIST user is listed in 'welcomelist_from' -100 USER_IN_WHITELIST DEPRECATED: See USER_IN_WELCOMELIST -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.181 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.208.181 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (cdhmanning[at]gmail.com) 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.2 AWL AWL: Adjusted score from AWL reputation of From: address X-ACL-Warn: warn X-SA-Exim-Connect-IP: 209.85.208.181 X-SA-Exim-Mail-From: cdhmanning@gmail.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on stoneboat.default.lvansomeren.uk0.bigv.io X-Spam-Level: X-Spam-Status: No, score=-101.9 required=4.9 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,USER_IN_WELCOMELIST, USER_IN_WHITELIST autolearn=unavailable autolearn_force=no version=3.4.2 X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on stoneboat.default.lvansomeren.uk0.bigv.io) X-Mailman-Approved-At: Fri, 21 Aug 2020 08:51:40 +0100 Subject: Re: [Yaffs] temp buffer management issues X-BeenThere: yaffs@stoneboat.aleph1.co.uk X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion of YAFFS NAND flash filesystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Aug 2020 04:24:47 -0000 --0000000000009c51e005ad5b9d55 Content-Type: text/plain; charset="UTF-8" Hello I will look into this. I was looking at some changes around buffer management and this spurs me to look into it sooner. Thank you Charles On Sat, Aug 15, 2020 at 11:55 AM Ao Luo wrote: > Two suggested change in temp buffer management: > > 1. When format disk before mounted, the buffer is not allocated and > may return NULL buffer pointers. > 2. The size of unmanaged buffer should use total_bytes_per_chunk, > otherwise it will cause buffer overflow in inband tag mode. > > > > diff --git a/yaffs_guts.c b/yaffs_guts.c > > index c52ff84..94177df 100644 > > --- a/yaffs_guts.c > > +++ b/yaffs_guts.c > > @@ -147,7 +147,7 @@ u8 *yaffs_get_temp_buffer(struct yaffs_dev * dev) > > dev->max_temp = dev->temp_in_use; > > for (i = 0; i < YAFFS_N_TEMP_BUFFERS; i++) { > > - if (dev->temp_buffer[i].in_use == 0) { > > + if (dev->temp_buffer[i].in_use == 0 && > dev->temp_buffer[i].buffer) { > > dev->temp_buffer[i].in_use = 1; > > return dev->temp_buffer[i].buffer; > > } > > @@ -160,7 +160,7 @@ u8 *yaffs_get_temp_buffer(struct yaffs_dev * dev) > > */ > > dev->unmanaged_buffer_allocs++; > > - return kmalloc(dev->data_bytes_per_chunk, GFP_NOFS); > > + return kmalloc(dev->param.total_bytes_per_chunk, GFP_NOFS); > > } > > > _______________________________________________ > yaffs mailing list > yaffs@stoneboat.aleph1.co.uk > http://stoneboat.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs > --0000000000009c51e005ad5b9d55 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello

I will look into this.= I was looking at some changes around buffer management and this spurs me t= o look into it sooner.

Thank you
Charles


On Sat, Aug 15, 2020 at 11:55 AM Ao Luo &= lt;aoluo@tsinghua.edu.cn> w= rote:

Two suggested change in temp buffer management:

  1. When form= at disk before mounted, the buffer is not allocated and may return NULL buf= fer pointers.
  2. The size of unmanaged buffer shoul= d use total_bytes_per_chunk, otherwise it will cause buffer overflow in inb= and tag mode.

=C2=A0

diff --git a/yaffs_guts.c b/yaffs_guts.c=

index c52ff84..94177df 100644<= u>

--- a/yaffs_guts.c

+++ b/yaffs_guts.c

@@ -147,7 +147,7 @@ u8 *yaffs_get_temp_buffer(struct yaffs_dev * dev)

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 dev->max_temp =3D dev->temp_in_use;

=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (i =3D = 0; i < YAFFS_N_TEMP_BUFFERS; i++) {

-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (dev->temp_= buffer[i].in_use =3D=3D 0) {

+=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (dev->temp_buffer[i]= .in_use =3D=3D 0 && dev->temp_buffer[i].buffer) {<= /p>

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 dev->temp_buffer[i].in_use =3D 1;

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return d= ev->temp_buffer[i].buffer;

=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }

<= p class=3D"MsoNormal">@@ -160,7 +160,7 @@ u8 *yaffs_get_temp_buffer(struct = yaffs_dev * dev)

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0*/

=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev->unmanaged_bu= ffer_allocs++;

-=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return kmalloc(dev->data_bytes_per_= chunk, GFP_NOFS);

+=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return kmalloc(dev->param.total_= bytes_per_chunk, GFP_NOFS);

=C2=A0}

=C2=A0

_______________________________= ________________
yaffs mailing list
yaffs@sto= neboat.aleph1.co.uk
http://stoneboat.aleph1.co.uk/cgi-bin/ma= ilman/listinfo/yaffs
--0000000000009c51e005ad5b9d55--